forked from sch/Slixfeed
Add command help
This commit is contained in:
parent
b502e4dbaa
commit
df8bfcf00a
1 changed files with 46 additions and 6 deletions
52
slixfeed.py
52
slixfeed.py
|
@ -77,7 +77,9 @@ class EchoBot(slixmpp.ClientXMPP):
|
||||||
if msg['type'] in ('chat', 'normal'):
|
if msg['type'] in ('chat', 'normal'):
|
||||||
# download_updates(msg['from'])
|
# download_updates(msg['from'])
|
||||||
message = " ".join(msg['body'].split())
|
message = " ".join(msg['body'].split())
|
||||||
if message.startswith('update'):
|
if message.startswith('help'):
|
||||||
|
action = print_help()
|
||||||
|
elif message.startswith('update'):
|
||||||
action = "/me is scanning feeds for updates..."
|
action = "/me is scanning feeds for updates..."
|
||||||
initdb(msg['from'].bare,
|
initdb(msg['from'].bare,
|
||||||
False,
|
False,
|
||||||
|
@ -173,6 +175,42 @@ class EchoBot(slixmpp.ClientXMPP):
|
||||||
asyncio.ensure_future(check_updates(self))
|
asyncio.ensure_future(check_updates(self))
|
||||||
asyncio.ensure_future(send_updates(self))
|
asyncio.ensure_future(send_updates(self))
|
||||||
|
|
||||||
|
|
||||||
|
def print_help():
|
||||||
|
msg = """
|
||||||
|
Slixfeed - News syndication bot for Jabber/XMPP
|
||||||
|
|
||||||
|
DESCRIPTION:
|
||||||
|
Slixfeed is an aggregator bot for online news feeds.
|
||||||
|
|
||||||
|
BASIC USAGE:
|
||||||
|
update
|
||||||
|
Update subscriptions.
|
||||||
|
list feeds
|
||||||
|
List subscriptions list.
|
||||||
|
|
||||||
|
EDIT OPTIONS:
|
||||||
|
feed add URL
|
||||||
|
Add URL to the subscriptions list.
|
||||||
|
feed remove ID
|
||||||
|
Remove feed from subscription list.
|
||||||
|
status ID
|
||||||
|
Toggle update status of feed.
|
||||||
|
|
||||||
|
SEARCH OPTIONS:
|
||||||
|
search TEXT
|
||||||
|
Search news items by given keywords.
|
||||||
|
recent updates N
|
||||||
|
List recent N news items.
|
||||||
|
|
||||||
|
DOCUMENTATION:
|
||||||
|
feedparser
|
||||||
|
https://pythonhosted.org/feedparser
|
||||||
|
Slixmpp
|
||||||
|
https://slixmpp.readthedocs.io/
|
||||||
|
"""
|
||||||
|
return msg
|
||||||
|
|
||||||
# Function from buku
|
# Function from buku
|
||||||
# https://github.com/jarun/buku
|
# https://github.com/jarun/buku
|
||||||
# Arun Prakash Jana (jarun)
|
# Arun Prakash Jana (jarun)
|
||||||
|
@ -300,18 +338,19 @@ def download_updates(conn):
|
||||||
except (IncompleteReadError, IncompleteRead, error.URLError) as e:
|
except (IncompleteReadError, IncompleteRead, error.URLError) as e:
|
||||||
print(e)
|
print(e)
|
||||||
continue
|
continue
|
||||||
|
if feed.bozo:
|
||||||
|
bozo = 'WARNING: Bozo detected for feed <{}>. For more information visit https://pythonhosted.org/feedparser/bozo.html'.format(source)
|
||||||
|
print(bozo)
|
||||||
# TODO Place these couple of lines back down
|
# TODO Place these couple of lines back down
|
||||||
# NOTE Need to correct the SQL statement to do so
|
# NOTE Need to correct the SQL statement to do so
|
||||||
length = len(feed.entries)
|
entries = feed.entries
|
||||||
|
length = len(entries)
|
||||||
remove_entry(conn, source, length)
|
remove_entry(conn, source, length)
|
||||||
for entry in feed.entries:
|
for entry in entries:
|
||||||
title = '*** No title ***' if not entry.title else entry.title
|
title = '*** No title ***' if not entry.title else entry.title
|
||||||
link = source if not entry.link else entry.link
|
link = source if not entry.link else entry.link
|
||||||
exist = check_entry(conn, title, link)
|
exist = check_entry(conn, title, link)
|
||||||
if not exist:
|
if not exist:
|
||||||
if feed.bozo:
|
|
||||||
print('feed.bozo')
|
|
||||||
print(source)
|
|
||||||
if entry.has_key('summary'):
|
if entry.has_key('summary'):
|
||||||
summary = entry.summary
|
summary = entry.summary
|
||||||
# Remove HTML tags
|
# Remove HTML tags
|
||||||
|
@ -342,6 +381,7 @@ def check_feed(conn, url):
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
sql = "SELECT id FROM feeds WHERE address = ?"
|
sql = "SELECT id FROM feeds WHERE address = ?"
|
||||||
cur.execute(sql, (url,))
|
cur.execute(sql, (url,))
|
||||||
|
print(cur.fetchone())
|
||||||
return cur.fetchone()
|
return cur.fetchone()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue