Update slixfeed.py

This commit is contained in:
Schimon Jehudah 2022-06-30 15:17:46 +00:00
parent 51df9cc9d2
commit be04cfec89

View file

@ -109,6 +109,14 @@ class Slixfeed(slixmpp.ClientXMPP):
action = initdb(msg['from'].bare, action = initdb(msg['from'].bare,
message[12:], message[12:],
toggle_status) toggle_status)
elif message.startswith('feed enable'):
action = initdb(msg['from'].bare,
message[11:],
toggle_state)
elif message.startswith('feed disable'):
action = initdb(msg['from'].bare,
message[12:],
toggle_state)
else: else:
action = "Unknown command. Press \"help\" for list of commands" action = "Unknown command. Press \"help\" for list of commands"
msg.reply(action).send() msg.reply(action).send()
@ -151,26 +159,32 @@ class Slixfeed(slixmpp.ClientXMPP):
os.chdir(db_dir) os.chdir(db_dir)
files = os.listdir() files = os.listdir()
for file in files: for file in files:
jid = file[:-3] if not file.endswith('.db-jour.db'):
new = initdb(jid, False, get_unread) jid = file[:-3]
if new: # TODO check if jid online
msg = self.make_message(mto=jid, mbody=new, # https://slixmpp.readthedocs.io/en/latest/api/plugins/xep_0199.html
mtype='chat') # d = self.send_ping(self, jid)
msg.send() # print('d')
# today = str(date.today()) # print(d)
# news.insert = [0, 'News fetched on: ' + today] new = initdb(jid, False, get_unread)
#news.append('End of News update') if new:
#for new in news: msg = self.make_message(mto=jid, mbody=new,
#print("sending to: jid") mtype='chat')
#print("sending to: " + jid) msg.send()
# self.send_message(mto=jid, # today = str(date.today())
# mbody=new, # news.insert = [0, 'News fetched on: ' + today]
# mtype='normal').send() #news.append('End of News update')
#msg = self.make_message(mto=jid, #for new in news:
# mbody=new, #print("sending to: jid")
# mtype='chat') #print("sending to: " + jid)
#print(msg) # self.send_message(mto=jid,
#msg.send() # mbody=new,
# mtype='normal').send()
#msg = self.make_message(mto=jid,
# mbody=new,
# mtype='chat')
#print(msg)
#msg.send()
await asyncio.sleep(15) await asyncio.sleep(15)
# asyncio.ensure_future(send_updates(self)) # asyncio.ensure_future(send_updates(self))
@ -183,6 +197,10 @@ def print_help():
" Slixfeed is an aggregator bot for online news feeds. \n" " Slixfeed is an aggregator bot for online news feeds. \n"
"\n" "\n"
"BASIC USAGE: \n" "BASIC USAGE: \n"
" feed enable \n"
" Send updates. \n"
" feed disable \n"
" Don't send updates. \n"
" feed list \n" " feed list \n"
" List subscriptions list. \n" " List subscriptions list. \n"
"\n" "\n"