From be04cfec890d61944d6837e0f337628715bcde97 Mon Sep 17 00:00:00 2001 From: Schimon Jehudah Date: Thu, 30 Jun 2022 15:17:46 +0000 Subject: [PATCH] Update slixfeed.py --- slixfeed.py | 58 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/slixfeed.py b/slixfeed.py index ed5f1f4..bcd2af3 100644 --- a/slixfeed.py +++ b/slixfeed.py @@ -109,6 +109,14 @@ class Slixfeed(slixmpp.ClientXMPP): action = initdb(msg['from'].bare, message[12:], 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: action = "Unknown command. Press \"help\" for list of commands" msg.reply(action).send() @@ -151,26 +159,32 @@ class Slixfeed(slixmpp.ClientXMPP): os.chdir(db_dir) files = os.listdir() for file in files: - jid = file[:-3] - new = initdb(jid, False, get_unread) - if new: - msg = self.make_message(mto=jid, mbody=new, - mtype='chat') - msg.send() - # today = str(date.today()) - # news.insert = [0, 'News fetched on: ' + today] - #news.append('End of News update') - #for new in news: - #print("sending to: jid") - #print("sending to: " + jid) - # self.send_message(mto=jid, - # mbody=new, - # mtype='normal').send() - #msg = self.make_message(mto=jid, - # mbody=new, - # mtype='chat') - #print(msg) - #msg.send() + if not file.endswith('.db-jour.db'): + jid = file[:-3] + # TODO check if jid online + # https://slixmpp.readthedocs.io/en/latest/api/plugins/xep_0199.html + # d = self.send_ping(self, jid) + # print('d') + # print(d) + new = initdb(jid, False, get_unread) + if new: + msg = self.make_message(mto=jid, mbody=new, + mtype='chat') + msg.send() + # today = str(date.today()) + # news.insert = [0, 'News fetched on: ' + today] + #news.append('End of News update') + #for new in news: + #print("sending to: jid") + #print("sending to: " + jid) + # self.send_message(mto=jid, + # mbody=new, + # mtype='normal').send() + #msg = self.make_message(mto=jid, + # mbody=new, + # mtype='chat') + #print(msg) + #msg.send() await asyncio.sleep(15) # asyncio.ensure_future(send_updates(self)) @@ -183,6 +197,10 @@ def print_help(): " Slixfeed is an aggregator bot for online news feeds. \n" "\n" "BASIC USAGE: \n" + " feed enable \n" + " Send updates. \n" + " feed disable \n" + " Don't send updates. \n" " feed list \n" " List subscriptions list. \n" "\n"