Reset setting or settings upon command default key or command defaults.

Fix issue of extra placeholder (Thank you mirux).
This commit is contained in:
Schimon Jehudah 2024-03-07 20:20:10 +00:00
parent 05168afa14
commit f489e1f672
4 changed files with 11 additions and 9 deletions

View file

@ -1514,7 +1514,7 @@ async def mark_all_as_read(db_file):
Path to database file. Path to database file.
""" """
function_name = sys._getframe().f_code.co_name function_name = sys._getframe().f_code.co_name
logger.debug('{}: db_file: {} ix: {}' logger.debug('{}: db_file: {}'
.format(function_name, db_file)) .format(function_name, db_file))
async with DBLOCK: async with DBLOCK:
with create_connection(db_file) as conn: with create_connection(db_file) as conn:

View file

@ -1,2 +1,2 @@
__version__ = '0.1.31' __version__ = '0.1.32'
__version_info__ = (0, 1, 31) __version_info__ = (0, 1, 32)

View file

@ -257,6 +257,12 @@ class Slixfeed(slixmpp.ClientXMPP):
message_log = '{}' message_log = '{}'
logger.debug(message_log.format(function_name)) logger.debug(message_log.format(function_name))
# self.send_presence() # 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') profile.set_identity(self, 'client')
# XmppCommand.adhoc_commands(self) # XmppCommand.adhoc_commands(self)
self.adhoc_commands() self.adhoc_commands()
@ -265,12 +271,6 @@ class Slixfeed(slixmpp.ClientXMPP):
await self.get_roster() await self.get_roster()
await profile.update(self) await profile.update(self)
task.task_ping(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() time_end = time.time()
difference = time_end - time_begin difference = time_end - time_begin
if difference > 1: logger.warning('{} (time: {})'.format(function_name, if difference > 1: logger.warning('{} (time: {})'.format(function_name,

View file

@ -421,12 +421,14 @@ async def message(self, message):
XmppMessage.send_reply(self, message, response) XmppMessage.send_reply(self, message, response)
case _ if message_lowercase.startswith('default '): case _ if message_lowercase.startswith('default '):
key = message_text[8:] key = message_text[8:]
self.settings[jid_bare][key] = None
db_file = config.get_pathname_to_database(jid_file) db_file = config.get_pathname_to_database(jid_file)
await sqlite.delete_setting(db_file, key) await sqlite.delete_setting(db_file, key)
response = ('Setting {} has been restored to default value.' response = ('Setting {} has been restored to default value.'
.format(key)) .format(key))
XmppMessage.send_reply(self, message, response) XmppMessage.send_reply(self, message, response)
case 'defaults': case 'defaults':
del self.settings[jid_bare]
db_file = config.get_pathname_to_database(jid_file) db_file = config.get_pathname_to_database(jid_file)
await sqlite.delete_settings(db_file) await sqlite.delete_settings(db_file)
response = 'Default settings have been restored.' response = 'Default settings have been restored.'