From f489e1f6727341d1b7f842cffbd8c382a8c57b4a Mon Sep 17 00:00:00 2001 From: Schimon Jehudah Date: Thu, 7 Mar 2024 20:20:10 +0000 Subject: [PATCH] Reset setting or settings upon command default key or command defaults. Fix issue of extra placeholder (Thank you mirux). --- slixfeed/sqlite.py | 2 +- slixfeed/version.py | 4 ++-- slixfeed/xmpp/client.py | 12 ++++++------ slixfeed/xmpp/process.py | 2 ++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/slixfeed/sqlite.py b/slixfeed/sqlite.py index 34bc9d2..9676508 100644 --- a/slixfeed/sqlite.py +++ b/slixfeed/sqlite.py @@ -1514,7 +1514,7 @@ async def mark_all_as_read(db_file): Path to database file. """ function_name = sys._getframe().f_code.co_name - logger.debug('{}: db_file: {} ix: {}' + logger.debug('{}: db_file: {}' .format(function_name, db_file)) async with DBLOCK: with create_connection(db_file) as conn: diff --git a/slixfeed/version.py b/slixfeed/version.py index f49fe39..3257c71 100644 --- a/slixfeed/version.py +++ b/slixfeed/version.py @@ -1,2 +1,2 @@ -__version__ = '0.1.31' -__version_info__ = (0, 1, 31) +__version__ = '0.1.32' +__version_info__ = (0, 1, 32) diff --git a/slixfeed/xmpp/client.py b/slixfeed/xmpp/client.py index b58f89f..fab19d3 100644 --- a/slixfeed/xmpp/client.py +++ b/slixfeed/xmpp/client.py @@ -257,6 +257,12 @@ class Slixfeed(slixmpp.ClientXMPP): message_log = '{}' logger.debug(message_log.format(function_name)) # self.send_presence() + bookmarks = await self.plugin['xep_0048'].get_bookmarks() + XmppGroupchat.autojoin(self, bookmarks) + jid_operator = config.get_value('accounts', 'XMPP', 'operator') + if jid_operator: + status_message = 'Slixfeed version {}'.format(__version__) + XmppPresence.send(self, jid_operator, status_message) profile.set_identity(self, 'client') # XmppCommand.adhoc_commands(self) self.adhoc_commands() @@ -265,12 +271,6 @@ class Slixfeed(slixmpp.ClientXMPP): await self.get_roster() await profile.update(self) task.task_ping(self) - bookmarks = await self.plugin['xep_0048'].get_bookmarks() - XmppGroupchat.autojoin(self, bookmarks) - jid_operator = config.get_value('accounts', 'XMPP', 'operator') - if jid_operator: - status_message = 'Slixfeed version {}'.format(__version__) - XmppPresence.send(self, jid_operator, status_message) time_end = time.time() difference = time_end - time_begin if difference > 1: logger.warning('{} (time: {})'.format(function_name, diff --git a/slixfeed/xmpp/process.py b/slixfeed/xmpp/process.py index 3cedfa5..da6c995 100644 --- a/slixfeed/xmpp/process.py +++ b/slixfeed/xmpp/process.py @@ -421,12 +421,14 @@ async def message(self, message): XmppMessage.send_reply(self, message, response) case _ if message_lowercase.startswith('default '): key = message_text[8:] + self.settings[jid_bare][key] = None db_file = config.get_pathname_to_database(jid_file) await sqlite.delete_setting(db_file, key) response = ('Setting {} has been restored to default value.' .format(key)) XmppMessage.send_reply(self, message, response) case 'defaults': + del self.settings[jid_bare] db_file = config.get_pathname_to_database(jid_file) await sqlite.delete_settings(db_file) response = 'Default settings have been restored.'