forked from sch/Slixfeed
Add missing parameters and rename some instances of jid to jid_bare
This commit is contained in:
parent
31babfa378
commit
da48b429d3
4 changed files with 93 additions and 75 deletions
|
@ -1,2 +1,2 @@
|
||||||
__version__ = '0.1.29'
|
__version__ = '0.1.30'
|
||||||
__version_info__ = (0, 1, 29)
|
__version_info__ = (0, 1, 30)
|
||||||
|
|
|
@ -1145,7 +1145,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
error_count = 0
|
error_count = 0
|
||||||
exist_count = 0
|
exist_count = 0
|
||||||
for url in urls:
|
for url in urls:
|
||||||
result = await action.add_feed(db_file, url)
|
result = await action.add_feed(self, jid_bare, db_file, url)
|
||||||
if result['error']:
|
if result['error']:
|
||||||
error_count += 1
|
error_count += 1
|
||||||
elif result['exist']:
|
elif result['exist']:
|
||||||
|
@ -1169,7 +1169,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
else:
|
else:
|
||||||
if isinstance(url, list):
|
if isinstance(url, list):
|
||||||
url = url[0]
|
url = url[0]
|
||||||
result = await action.add_feed(db_file, url)
|
result = await action.add_feed(self, jid_bare, db_file, url)
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
results = result
|
results = result
|
||||||
form = self['xep_0004'].make_form('form', 'Subscriptions')
|
form = self['xep_0004'].make_form('form', 'Subscriptions')
|
||||||
|
|
|
@ -67,8 +67,8 @@ async def message(self, message):
|
||||||
how it may be used.
|
how it may be used.
|
||||||
"""
|
"""
|
||||||
if message['type'] in ('chat', 'groupchat', 'normal'):
|
if message['type'] in ('chat', 'groupchat', 'normal'):
|
||||||
jid = message['from'].bare
|
jid_bare = message['from'].bare
|
||||||
jid_file = jid
|
jid_file = jid_bare
|
||||||
message_text = ' '.join(message['body'].split())
|
message_text = ' '.join(message['body'].split())
|
||||||
command_time_start = time.time()
|
command_time_start = time.time()
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ async def message(self, message):
|
||||||
if (message['muc']['nick'] == self.alias):
|
if (message['muc']['nick'] == self.alias):
|
||||||
return
|
return
|
||||||
jid_full = str(message['from'])
|
jid_full = str(message['from'])
|
||||||
if not is_moderator(self, jid, jid_full):
|
if not is_moderator(self, jid_bare, jid_full):
|
||||||
return
|
return
|
||||||
|
|
||||||
# NOTE This is an exceptional case in which we treat
|
# NOTE This is an exceptional case in which we treat
|
||||||
|
@ -92,10 +92,11 @@ async def message(self, message):
|
||||||
if (message_text.lower().startswith('http') and
|
if (message_text.lower().startswith('http') and
|
||||||
message_text.lower().endswith('.opml')):
|
message_text.lower().endswith('.opml')):
|
||||||
url = message_text
|
url = message_text
|
||||||
task.clean_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
task.clean_tasks_xmpp(self, jid_bare, key_list)
|
||||||
status_type = 'dnd'
|
status_type = 'dnd'
|
||||||
status_message = '📥️ Procesing request to import feeds...'
|
status_message = '📥️ Procesing request to import feeds...'
|
||||||
XmppPresence.send(self, jid, status_message,
|
XmppPresence.send(self, jid_bare, status_message,
|
||||||
status_type=status_type)
|
status_type=status_type)
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_file)
|
||||||
count = await action.import_opml(db_file, url)
|
count = await action.import_opml(db_file, url)
|
||||||
|
@ -103,7 +104,8 @@ async def message(self, message):
|
||||||
response = 'Successfully imported {} feeds.'.format(count)
|
response = 'Successfully imported {} feeds.'.format(count)
|
||||||
else:
|
else:
|
||||||
response = 'OPML file was not imported.'
|
response = 'OPML file was not imported.'
|
||||||
await task.start_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -116,13 +118,13 @@ async def message(self, message):
|
||||||
not message['body'].startswith('!')):
|
not message['body'].startswith('!')):
|
||||||
return
|
return
|
||||||
# token = await initdb(
|
# token = await initdb(
|
||||||
# jid,
|
# jid_bare,
|
||||||
# sqlite.get_setting_value,
|
# sqlite.get_setting_value,
|
||||||
# 'token'
|
# 'token'
|
||||||
# )
|
# )
|
||||||
# if token == 'accepted':
|
# if token == 'accepted':
|
||||||
# operator = await initdb(
|
# operator = await initdb(
|
||||||
# jid,
|
# jid_bare,
|
||||||
# sqlite.get_setting_value,
|
# sqlite.get_setting_value,
|
||||||
# 'masters'
|
# 'masters'
|
||||||
# )
|
# )
|
||||||
|
@ -131,7 +133,7 @@ async def message(self, message):
|
||||||
# return
|
# return
|
||||||
# approved = False
|
# approved = False
|
||||||
jid_full = str(message['from'])
|
jid_full = str(message['from'])
|
||||||
if not is_moderator(self, jid, jid_full):
|
if not is_moderator(self, jid_bare, jid_full):
|
||||||
return
|
return
|
||||||
# if role == 'moderator':
|
# if role == 'moderator':
|
||||||
# approved = True
|
# approved = True
|
||||||
|
@ -142,7 +144,7 @@ async def message(self, message):
|
||||||
# Changing nickname is fine and consist of no problem.
|
# Changing nickname is fine and consist of no problem.
|
||||||
# if not approved:
|
# if not approved:
|
||||||
# operator = await initdb(
|
# operator = await initdb(
|
||||||
# jid,
|
# jid_bare,
|
||||||
# sqlite.get_setting_value,
|
# sqlite.get_setting_value,
|
||||||
# 'masters'
|
# 'masters'
|
||||||
# )
|
# )
|
||||||
|
@ -159,7 +161,7 @@ async def message(self, message):
|
||||||
# if jid + '.db' not in os.listdir():
|
# if jid + '.db' not in os.listdir():
|
||||||
# await task_jid(jid)
|
# await task_jid(jid)
|
||||||
|
|
||||||
# await compose.message(self, jid, message)
|
# await compose.message(self, jid_bare, message)
|
||||||
|
|
||||||
if message['type'] == 'groupchat':
|
if message['type'] == 'groupchat':
|
||||||
message_text = message_text[1:]
|
message_text = message_text[1:]
|
||||||
|
@ -170,7 +172,7 @@ async def message(self, message):
|
||||||
# Support private message via groupchat
|
# Support private message via groupchat
|
||||||
# See https://codeberg.org/poezio/slixmpp/issues/3506
|
# See https://codeberg.org/poezio/slixmpp/issues/3506
|
||||||
if message['type'] == 'chat' and message.get_plugin('muc', check=True):
|
if message['type'] == 'chat' and message.get_plugin('muc', check=True):
|
||||||
jid_bare = message['from'].bare
|
# jid_bare = message['from'].bare
|
||||||
jid_full = str(message['from'])
|
jid_full = str(message['from'])
|
||||||
if (jid_bare == jid_full[:jid_full.index('/')]):
|
if (jid_bare == jid_full[:jid_full.index('/')]):
|
||||||
jid = str(message['from'])
|
jid = str(message['from'])
|
||||||
|
@ -271,18 +273,18 @@ async def message(self, message):
|
||||||
# if message['type'] == 'groupchat':
|
# if message['type'] == 'groupchat':
|
||||||
# acode = message[9:]
|
# acode = message[9:]
|
||||||
# token = await initdb(
|
# token = await initdb(
|
||||||
# jid,
|
# jid_bare,
|
||||||
# sqlite.get_setting_value,
|
# sqlite.get_setting_value,
|
||||||
# 'token'
|
# 'token'
|
||||||
# )
|
# )
|
||||||
# if int(acode) == token:
|
# if int(acode) == token:
|
||||||
# await initdb(
|
# await initdb(
|
||||||
# jid,
|
# jid_bare,
|
||||||
# sqlite.update_setting_value,
|
# sqlite.update_setting_value,
|
||||||
# ['masters', nick]
|
# ['masters', nick]
|
||||||
# )
|
# )
|
||||||
# await initdb(
|
# await initdb(
|
||||||
# jid,
|
# jid_bare,
|
||||||
# sqlite.update_setting_value,
|
# sqlite.update_setting_value,
|
||||||
# ['token', 'accepted']
|
# ['token', 'accepted']
|
||||||
# )
|
# )
|
||||||
|
@ -308,9 +310,10 @@ async def message(self, message):
|
||||||
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
||||||
old = self.settings[jid_bare]['old'] or self.settings['default']['old']
|
old = self.settings[jid_bare]['old'] or self.settings['default']['old']
|
||||||
if old:
|
if old:
|
||||||
# task.clean_tasks_xmpp(self, jid, ['status'])
|
# task.clean_tasks_xmpp(self, jid_bare, ['status'])
|
||||||
# await send_status(jid)
|
# await send_status(jid)
|
||||||
await task.start_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||||
else:
|
else:
|
||||||
feed_id = await sqlite.get_feed_id(db_file, url)
|
feed_id = await sqlite.get_feed_id(db_file, url)
|
||||||
feed_id = feed_id[0]
|
feed_id = feed_id[0]
|
||||||
|
@ -397,7 +400,7 @@ async def message(self, message):
|
||||||
'Missing value.')
|
'Missing value.')
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
case _ if message_lowercase.startswith('bookmark +'):
|
case _ if message_lowercase.startswith('bookmark +'):
|
||||||
if jid == config.get_value('accounts', 'XMPP', 'operator'):
|
if jid_bare == config.get_value('accounts', 'XMPP', 'operator'):
|
||||||
muc_jid = message_text[11:]
|
muc_jid = message_text[11:]
|
||||||
await XmppBookmark.add(self, jid=muc_jid)
|
await XmppBookmark.add(self, jid=muc_jid)
|
||||||
response = ('Groupchat {} has been added to bookmarks.'
|
response = ('Groupchat {} has been added to bookmarks.'
|
||||||
|
@ -407,7 +410,7 @@ async def message(self, message):
|
||||||
'Type: adding bookmarks.')
|
'Type: adding bookmarks.')
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
case _ if message_lowercase.startswith('bookmark -'):
|
case _ if message_lowercase.startswith('bookmark -'):
|
||||||
if jid == config.get_value('accounts', 'XMPP', 'operator'):
|
if jid_bare == config.get_value('accounts', 'XMPP', 'operator'):
|
||||||
muc_jid = message_text[11:]
|
muc_jid = message_text[11:]
|
||||||
await XmppBookmark.remove(self, muc_jid)
|
await XmppBookmark.remove(self, muc_jid)
|
||||||
response = ('Groupchat {} has been removed from bookmarks.'
|
response = ('Groupchat {} has been removed from bookmarks.'
|
||||||
|
@ -435,7 +438,7 @@ async def message(self, message):
|
||||||
response = 'Filter {} has been purged.'.format(key)
|
response = 'Filter {} has been purged.'.format(key)
|
||||||
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_bare == config.get_value('accounts', 'XMPP', 'operator'):
|
||||||
response = await action.list_bookmarks(self)
|
response = await action.list_bookmarks(self)
|
||||||
else:
|
else:
|
||||||
response = ('This action is restricted. '
|
response = ('This action is restricted. '
|
||||||
|
@ -490,18 +493,19 @@ async def message(self, message):
|
||||||
status_message = ('📤️ Procesing request to '
|
status_message = ('📤️ Procesing request to '
|
||||||
'export feeds into {}...'
|
'export feeds into {}...'
|
||||||
.format(ext.upper()))
|
.format(ext.upper()))
|
||||||
XmppPresence.send(self, jid, status_message,
|
XmppPresence.send(self, jid_bare, status_message,
|
||||||
status_type=status_type)
|
status_type=status_type)
|
||||||
filename = await action.export_feeds(self, jid, jid_file,
|
filename = await action.export_feeds(self, jid_bare,
|
||||||
ext)
|
jid_file, ext)
|
||||||
url = await XmppUpload.start(self, jid, filename)
|
url = await XmppUpload.start(self, jid_bare, filename)
|
||||||
# response = (
|
# response = (
|
||||||
# 'Feeds exported successfully to {}.\n{}'
|
# 'Feeds exported successfully to {}.\n{}'
|
||||||
# ).format(ex, url)
|
# ).format(ex, url)
|
||||||
# XmppMessage.send_oob_reply_message(message, url, response)
|
# XmppMessage.send_oob_reply_message(message, url, response)
|
||||||
chat_type = await get_chat_type(self, jid)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
XmppMessage.send_oob(self, jid, url, chat_type)
|
XmppMessage.send_oob(self, jid_bare, url, chat_type)
|
||||||
await task.start_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||||
else:
|
else:
|
||||||
response = ('Unsupported filetype.\n'
|
response = ('Unsupported filetype.\n'
|
||||||
'Try: md or opml')
|
'Try: md or opml')
|
||||||
|
@ -535,7 +539,7 @@ async def message(self, message):
|
||||||
status_type = 'dnd'
|
status_type = 'dnd'
|
||||||
status_message = ('📃️ Procesing request to produce {} '
|
status_message = ('📃️ Procesing request to produce {} '
|
||||||
'document...'.format(ext.upper()))
|
'document...'.format(ext.upper()))
|
||||||
XmppPresence.send(self, jid, status_message,
|
XmppPresence.send(self, jid_bare, status_message,
|
||||||
status_type=status_type)
|
status_type=status_type)
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_file)
|
||||||
cache_dir = config.get_default_cache_directory()
|
cache_dir = config.get_default_cache_directory()
|
||||||
|
@ -579,16 +583,18 @@ async def message(self, message):
|
||||||
ext.upper(),
|
ext.upper(),
|
||||||
error))
|
error))
|
||||||
else:
|
else:
|
||||||
url = await XmppUpload.start(self, jid,
|
url = await XmppUpload.start(self, jid_bare,
|
||||||
filename)
|
filename)
|
||||||
chat_type = await get_chat_type(self, jid)
|
chat_type = await get_chat_type(self,
|
||||||
XmppMessage.send_oob(self, jid, url,
|
jid_bare)
|
||||||
|
XmppMessage.send_oob(self, jid_bare, url,
|
||||||
chat_type)
|
chat_type)
|
||||||
else:
|
else:
|
||||||
response = ('> {}\n'
|
response = ('> {}\n'
|
||||||
'Failed to fetch URL. Reason: {}'
|
'Failed to fetch URL. Reason: {}'
|
||||||
.format(url, code))
|
.format(url, code))
|
||||||
await task.start_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||||
else:
|
else:
|
||||||
response = ('No action has been taken.'
|
response = ('No action has been taken.'
|
||||||
'\n'
|
'\n'
|
||||||
|
@ -604,10 +610,11 @@ async def message(self, message):
|
||||||
case _ if (message_lowercase.startswith('http')) and(
|
case _ if (message_lowercase.startswith('http')) and(
|
||||||
message_lowercase.endswith('.opml')):
|
message_lowercase.endswith('.opml')):
|
||||||
url = message_text
|
url = message_text
|
||||||
task.clean_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
task.clean_tasks_xmpp(self, jid_bare, key_list)
|
||||||
status_type = 'dnd'
|
status_type = 'dnd'
|
||||||
status_message = '📥️ Procesing request to import feeds...'
|
status_message = '📥️ Procesing request to import feeds...'
|
||||||
XmppPresence.send(self, jid, status_message,
|
XmppPresence.send(self, jid_bare, status_message,
|
||||||
status_type=status_type)
|
status_type=status_type)
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_file)
|
||||||
count = await action.import_opml(db_file, url)
|
count = await action.import_opml(db_file, url)
|
||||||
|
@ -616,16 +623,17 @@ async def message(self, message):
|
||||||
.format(count))
|
.format(count))
|
||||||
else:
|
else:
|
||||||
response = 'OPML file was not imported.'
|
response = 'OPML file was not imported.'
|
||||||
await task.start_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
case _ if (message_lowercase.startswith('http') or
|
case _ if (message_lowercase.startswith('http') or
|
||||||
message_lowercase.startswith('feed:')):
|
message_lowercase.startswith('feed:')):
|
||||||
url = message_text
|
url = message_text
|
||||||
# task.clean_tasks_xmpp(self, jid, ['status'])
|
# task.clean_tasks_xmpp(self, jid_bare, ['status'])
|
||||||
status_type = 'dnd'
|
status_type = 'dnd'
|
||||||
status_message = ('📫️ Processing request to fetch data from {}'
|
status_message = ('📫️ Processing request to fetch data from {}'
|
||||||
.format(url))
|
.format(url))
|
||||||
XmppPresence.send(self, jid, status_message,
|
XmppPresence.send(self, jid_bare, status_message,
|
||||||
status_type=status_type)
|
status_type=status_type)
|
||||||
if url.startswith('feed:'):
|
if url.startswith('feed:'):
|
||||||
url = uri.feed_to_http(url)
|
url = uri.feed_to_http(url)
|
||||||
|
@ -657,8 +665,9 @@ async def message(self, message):
|
||||||
response = ('> {}\nNews source "{}" has been '
|
response = ('> {}\nNews source "{}" has been '
|
||||||
'added to subscription list.'
|
'added to subscription list.'
|
||||||
.format(result['link'], result['name']))
|
.format(result['link'], result['name']))
|
||||||
# task.clean_tasks_xmpp(self, jid, ['status'])
|
# task.clean_tasks_xmpp(self, jid_bare, ['status'])
|
||||||
await task.start_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||||
# except:
|
# except:
|
||||||
# response = (
|
# response = (
|
||||||
# '> {}\nNews source is in the process '
|
# '> {}\nNews source is in the process '
|
||||||
|
@ -681,8 +690,8 @@ async def message(self, message):
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
case 'goodbye':
|
case 'goodbye':
|
||||||
if message['type'] == 'groupchat':
|
if message['type'] == 'groupchat':
|
||||||
XmppGroupchat.leave(self, jid)
|
XmppGroupchat.leave(self, jid_bare)
|
||||||
await XmppBookmark.remove(self, jid)
|
await XmppBookmark.remove(self, jid_bare)
|
||||||
else:
|
else:
|
||||||
response = 'This command is valid in groupchat only.'
|
response = 'This command is valid in groupchat only.'
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
|
@ -696,8 +705,8 @@ async def message(self, message):
|
||||||
await config.set_setting_value(db_file, key, val)
|
await config.set_setting_value(db_file, key, val)
|
||||||
# NOTE Perhaps this should be replaced by functions
|
# NOTE Perhaps this should be replaced by functions
|
||||||
# clean and start
|
# clean and start
|
||||||
await task.refresh_task(self, jid, task.task_send, key,
|
await task.refresh_task(self, jid_bare, task.task_send,
|
||||||
val)
|
key, val)
|
||||||
response = ('Updates will be sent every {} minutes.'
|
response = ('Updates will be sent every {} minutes.'
|
||||||
.format(val))
|
.format(val))
|
||||||
except:
|
except:
|
||||||
|
@ -711,7 +720,7 @@ async def message(self, message):
|
||||||
muc_jid = uri.check_xmpp_uri(message_text[5:])
|
muc_jid = uri.check_xmpp_uri(message_text[5:])
|
||||||
if muc_jid:
|
if muc_jid:
|
||||||
# TODO probe JID and confirm it's a groupchat
|
# TODO probe JID and confirm it's a groupchat
|
||||||
XmppGroupchat.join(self, jid, muc_jid)
|
XmppGroupchat.join(self, jid_bare, muc_jid)
|
||||||
# await XmppBookmark.add(self, jid=muc_jid)
|
# await XmppBookmark.add(self, jid=muc_jid)
|
||||||
response = ('Joined groupchat {}'
|
response = ('Joined groupchat {}'
|
||||||
.format(message_text))
|
.format(message_text))
|
||||||
|
@ -747,7 +756,7 @@ async def message(self, message):
|
||||||
# val = message_text[11:]
|
# val = message_text[11:]
|
||||||
# if val:
|
# if val:
|
||||||
# names = await initdb(
|
# names = await initdb(
|
||||||
# jid,
|
# jid_bare,
|
||||||
# sqlite.get_setting_value,
|
# sqlite.get_setting_value,
|
||||||
# key
|
# key
|
||||||
# )
|
# )
|
||||||
|
@ -756,7 +765,7 @@ async def message(self, message):
|
||||||
# names
|
# names
|
||||||
# )
|
# )
|
||||||
# await initdb(
|
# await initdb(
|
||||||
# jid,
|
# jid_bare,
|
||||||
# sqlite.update_setting_valuevv,
|
# sqlite.update_setting_valuevv,
|
||||||
# [key, val]
|
# [key, val]
|
||||||
# )
|
# )
|
||||||
|
@ -791,10 +800,11 @@ async def message(self, message):
|
||||||
case _ if message_lowercase.startswith('next'):
|
case _ if message_lowercase.startswith('next'):
|
||||||
num = message_text[5:]
|
num = message_text[5:]
|
||||||
if num:
|
if num:
|
||||||
await action.xmpp_send_update(self, jid, num)
|
await action.xmpp_send_update(self, jid_bare, num)
|
||||||
else:
|
else:
|
||||||
await action.xmpp_send_update(self, jid)
|
await action.xmpp_send_update(self, jid_bare)
|
||||||
await task.start_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||||
case 'old':
|
case 'old':
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_file)
|
||||||
key = 'old'
|
key = 'old'
|
||||||
|
@ -834,11 +844,12 @@ async def message(self, message):
|
||||||
data = data.split()
|
data = data.split()
|
||||||
url = data[0]
|
url = data[0]
|
||||||
if url:
|
if url:
|
||||||
task.clean_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
task.clean_tasks_xmpp(self, jid_bare, key_list)
|
||||||
status_type = 'dnd'
|
status_type = 'dnd'
|
||||||
status_message = ('📫️ Processing request to fetch data from {}'
|
status_message = ('📫️ Processing request to fetch data from {}'
|
||||||
.format(url))
|
.format(url))
|
||||||
XmppPresence.send(self, jid, status_message,
|
XmppPresence.send(self, jid_bare, status_message,
|
||||||
status_type=status_type)
|
status_type=status_type)
|
||||||
if url.startswith('feed:'):
|
if url.startswith('feed:'):
|
||||||
url = uri.feed_to_http(url)
|
url = uri.feed_to_http(url)
|
||||||
|
@ -868,7 +879,8 @@ async def message(self, message):
|
||||||
'\n'
|
'\n'
|
||||||
'Missing URL.')
|
'Missing URL.')
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
await task.start_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||||
case _ if message_lowercase.startswith('recent'):
|
case _ if message_lowercase.startswith('recent'):
|
||||||
num = message_text[7:]
|
num = message_text[7:]
|
||||||
if num:
|
if num:
|
||||||
|
@ -925,13 +937,14 @@ async def message(self, message):
|
||||||
.format(url))
|
.format(url))
|
||||||
# await refresh_task(
|
# await refresh_task(
|
||||||
# self,
|
# self,
|
||||||
# jid,
|
# jid_bare,
|
||||||
# send_status,
|
# send_status,
|
||||||
# 'status',
|
# 'status',
|
||||||
# 20
|
# 20
|
||||||
# )
|
# )
|
||||||
# task.clean_tasks_xmpp(self, jid, ['status'])
|
# task.clean_tasks_xmpp(self, jid_bare, ['status'])
|
||||||
await task.start_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||||
else:
|
else:
|
||||||
response = ('No action has been taken.'
|
response = ('No action has been taken.'
|
||||||
'\n'
|
'\n'
|
||||||
|
@ -941,10 +954,11 @@ async def message(self, message):
|
||||||
case _ if message_lowercase.startswith('reset'):
|
case _ if message_lowercase.startswith('reset'):
|
||||||
# TODO Reset also by ID
|
# TODO Reset also by ID
|
||||||
ix_url = message_text[6:]
|
ix_url = message_text[6:]
|
||||||
task.clean_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
task.clean_tasks_xmpp(self, jid_bare, key_list)
|
||||||
status_type = 'dnd'
|
status_type = 'dnd'
|
||||||
status_message = '📫️ Marking entries as read...'
|
status_message = '📫️ Marking entries as read...'
|
||||||
XmppPresence.send(self, jid, status_message,
|
XmppPresence.send(self, jid_bare, status_message,
|
||||||
status_type=status_type)
|
status_type=status_type)
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_file)
|
||||||
if ix_url:
|
if ix_url:
|
||||||
|
@ -985,7 +999,8 @@ async def message(self, message):
|
||||||
await sqlite.mark_all_as_read(db_file)
|
await sqlite.mark_all_as_read(db_file)
|
||||||
response = 'All entries have been marked as read.'
|
response = 'All entries have been marked as read.'
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
await task.start_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||||
case _ if message_lowercase.startswith('search'):
|
case _ if message_lowercase.startswith('search'):
|
||||||
query = message_text[7:]
|
query = message_text[7:]
|
||||||
if query:
|
if query:
|
||||||
|
@ -1007,9 +1022,10 @@ async def message(self, message):
|
||||||
await config.set_setting_value(db_file, key, val)
|
await config.set_setting_value(db_file, key, val)
|
||||||
status_type = 'available'
|
status_type = 'available'
|
||||||
status_message = '📫️ Welcome back!'
|
status_message = '📫️ Welcome back!'
|
||||||
XmppPresence.send(self, jid, status_message, status_type=status_type)
|
XmppPresence.send(self, jid_bare, status_message, status_type=status_type)
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
await task.start_tasks_xmpp(self, jid, ['check', 'status', 'interval'])
|
key_list = ['check', 'status', 'interval']
|
||||||
|
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||||
response = 'Updates are enabled.'
|
response = 'Updates are enabled.'
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
case 'stats':
|
case 'stats':
|
||||||
|
@ -1033,7 +1049,8 @@ async def message(self, message):
|
||||||
'No news source with index {}.'
|
'No news source with index {}.'
|
||||||
.format(feed_id))
|
.format(feed_id))
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
await task.start_tasks_xmpp(self, jid, ['status'])
|
key_list = ['status']
|
||||||
|
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||||
case _ if message_lowercase.startswith('rename'):
|
case _ if message_lowercase.startswith('rename'):
|
||||||
message_text = message_text[7:]
|
message_text = message_text[7:]
|
||||||
feed_id = message_text.split(' ')[0]
|
feed_id = message_text.split(' ')[0]
|
||||||
|
@ -1089,10 +1106,11 @@ async def message(self, message):
|
||||||
val = 0
|
val = 0
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_file)
|
||||||
await config.set_setting_value(db_file, key, val)
|
await config.set_setting_value(db_file, key, val)
|
||||||
task.clean_tasks_xmpp(self, jid, ['interval', 'status'])
|
key_list = ['interval', 'status']
|
||||||
|
task.clean_tasks_xmpp(self, jid_bare, key_list)
|
||||||
status_type = 'xa'
|
status_type = 'xa'
|
||||||
status_message = '📪️ Send "Start" to receive Jabber updates'
|
status_message = '📪️ Send "Start" to receive Jabber updates'
|
||||||
XmppPresence.send(self, jid, status_message,
|
XmppPresence.send(self, jid_bare, status_message,
|
||||||
status_type=status_type)
|
status_type=status_type)
|
||||||
response = 'Updates are disabled.'
|
response = 'Updates are disabled.'
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
|
@ -1100,8 +1118,8 @@ async def message(self, message):
|
||||||
muc_jid = 'slixfeed@chat.woodpeckersnest.space'
|
muc_jid = 'slixfeed@chat.woodpeckersnest.space'
|
||||||
response = 'Join xmpp:{}?join'.format(muc_jid)
|
response = 'Join xmpp:{}?join'.format(muc_jid)
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
if await get_chat_type(self, jid) == 'chat':
|
if await get_chat_type(self, jid_bare) == 'chat':
|
||||||
self.plugin['xep_0045'].invite(muc_jid, jid)
|
self.plugin['xep_0045'].invite(muc_jid, jid_bare)
|
||||||
case 'version':
|
case 'version':
|
||||||
response = __version__
|
response = __version__
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
|
@ -1109,7 +1127,7 @@ async def message(self, message):
|
||||||
muc_jid = uri.check_xmpp_uri(message_text)
|
muc_jid = uri.check_xmpp_uri(message_text)
|
||||||
if muc_jid:
|
if muc_jid:
|
||||||
# TODO probe JID and confirm it's a groupchat
|
# TODO probe JID and confirm it's a groupchat
|
||||||
XmppGroupchat.join(self, jid, muc_jid)
|
XmppGroupchat.join(self, jid_bare, muc_jid)
|
||||||
# await XmppBookmark.add(self, jid=muc_jid)
|
# await XmppBookmark.add(self, jid=muc_jid)
|
||||||
response = ('Joined groupchat {}'
|
response = ('Joined groupchat {}'
|
||||||
.format(message_text))
|
.format(message_text))
|
||||||
|
@ -1141,15 +1159,15 @@ async def message(self, message):
|
||||||
os.mkdir(data_dir + '/logs/')
|
os.mkdir(data_dir + '/logs/')
|
||||||
action.log_to_markdown(
|
action.log_to_markdown(
|
||||||
dt.current_time(), os.path.join(data_dir, 'logs', jid_file),
|
dt.current_time(), os.path.join(data_dir, 'logs', jid_file),
|
||||||
jid, message_text)
|
jid_bare, message_text)
|
||||||
action.log_to_markdown(
|
action.log_to_markdown(
|
||||||
dt.current_time(), os.path.join(data_dir, 'logs', jid_file),
|
dt.current_time(), os.path.join(data_dir, 'logs', jid_file),
|
||||||
self.boundjid.bare, response)
|
jid_bare, response)
|
||||||
|
|
||||||
print(
|
print(
|
||||||
'Message : {}\n'
|
'Message : {}\n'
|
||||||
'JID : {}\n'
|
'JID : {}\n'
|
||||||
'File : {}\n'
|
'File : {}\n'
|
||||||
'{}\n'
|
'{}\n'
|
||||||
.format(message_text, jid, jid_file, response)
|
.format(message_text, jid_bare, jid_file, response)
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,9 +7,9 @@ import logging
|
||||||
# class XmppChat
|
# class XmppChat
|
||||||
# class XmppUtility:
|
# class XmppUtility:
|
||||||
|
|
||||||
def is_moderator(self, jid, jid_full):
|
def is_moderator(self, jid_bare, jid_full):
|
||||||
alias = jid_full[jid_full.index('/')+1:]
|
alias = jid_full[jid_full.index('/')+1:]
|
||||||
role = self.plugin['xep_0045'].get_jid_property(jid, alias, 'role')
|
role = self.plugin['xep_0045'].get_jid_property(jid_bare, alias, 'role')
|
||||||
if role == 'moderator':
|
if role == 'moderator':
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue