Accept only numerical value for key interval

This commit is contained in:
Schimon Jehudah 2024-02-12 09:53:49 +00:00
parent f6bc76fdf8
commit e0864cc84e
3 changed files with 20 additions and 21 deletions

View file

@ -293,6 +293,12 @@ async def xmpp_change_interval(self, key, val, jid, jid_file, message=None,
XmppMessage.send(self, jid, response, chat_type='chat')
async def reset_settings(jid_file):
db_file = config.get_pathname_to_database(jid_file)
await sqlite.delete_settings(db_file)
response = 'Default settings have been restored.'
return response
async def xmpp_start_updates(self, message, jid, jid_file):
key = 'enabled'
val = 1

View file

@ -3,12 +3,6 @@
"""
FIXME
1) Function check_readiness or event "changed_status" is causing for
triple status messages and also false ones that indicate of lack
of feeds.
TODO
1) Use loop (with gather) instead of TaskGroup.
@ -29,15 +23,7 @@ Parse me!
NOTE
1) Self presence
Apparently, it is possible to view self presence.
This means that there is no need to store presences in order to switch or restore presence.
check_readiness
📂 Send a URL from a blog or a news website.
JID: self.boundjid.bare
MUC: self.alias
2) Extracting attribute using xmltodict.
1) Extracting attribute using xmltodict.
import xmltodict
message = xmltodict.parse(str(message))
jid = message["message"]["x"]["@jid"]

View file

@ -390,10 +390,11 @@ async def message(self, message):
response = ('This action is restricted. '
'Type: removing bookmarks.')
XmppMessage.send_reply(self, message, response)
case 'default':
db_file = config.get_pathname_to_database(jid_file)
await sqlite.delete_settings(db_file)
response = ('Default settings have been restored.')
case 'default': # TODO Set default per key
response = action.reset_settings(jid_file)
XmppMessage.send_reply(self, message, response)
case 'defaults':
response = action.reset_settings(jid_file)
XmppMessage.send_reply(self, message, response)
case 'bookmarks':
if jid == config.get_value('accounts', 'XMPP', 'operator'):
@ -558,8 +559,14 @@ async def message(self, message):
case _ if message_lowercase.startswith('interval'):
key = message_text[:8]
val = message_text[9:]
await action.xmpp_change_interval(
self, key, val, jid, jid_file, message=message)
try:
val = int(val)
await action.xmpp_change_interval(self, key, val, jid,
jid_file,
message=message)
except:
response = 'Enter a numeric value only.'
XmppMessage.send_reply(self, message, response)
case _ if message_lowercase.startswith('join'):
muc_jid = uri.check_xmpp_uri(message_text[5:])
if muc_jid: