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') 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): async def xmpp_start_updates(self, message, jid, jid_file):
key = 'enabled' key = 'enabled'
val = 1 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 TODO
1) Use loop (with gather) instead of TaskGroup. 1) Use loop (with gather) instead of TaskGroup.
@ -29,15 +23,7 @@ Parse me!
NOTE NOTE
1) Self presence 1) Extracting attribute using xmltodict.
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.
import xmltodict import xmltodict
message = xmltodict.parse(str(message)) message = xmltodict.parse(str(message))
jid = message["message"]["x"]["@jid"] jid = message["message"]["x"]["@jid"]

View file

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