forked from sch/Slixfeed
Shorten string formatting.
This commit is contained in:
parent
d6dfbc339e
commit
6a78afd67f
2 changed files with 154 additions and 209 deletions
|
@ -158,39 +158,35 @@ class XmppChat:
|
||||||
command_list = ''.join(command_list)
|
command_list = ''.join(command_list)
|
||||||
response = (command_list)
|
response = (command_list)
|
||||||
else:
|
else:
|
||||||
response = ('KeyError for {} {}'
|
response = f'KeyError for {command_root} {command_name}'
|
||||||
.format(command_root, command_name))
|
|
||||||
elif len(command) == 1:
|
elif len(command) == 1:
|
||||||
command = command[0]
|
command = command[0]
|
||||||
command_list = Documentation.manual(
|
command_list = Documentation.manual(
|
||||||
'commands.toml', command)
|
'commands.toml', command)
|
||||||
if command_list:
|
if command_list:
|
||||||
command_list = ' '.join(command_list)
|
command_list = ' '.join(command_list)
|
||||||
response = ('Available command `{}` keys:\n'
|
response = (f'Available command `{command}` keys:\n'
|
||||||
'```\n{}\n```\n'
|
f'```\n{command_list}\n```\n'
|
||||||
'Usage: `help {} <command>`'
|
f'Usage: `help {command} <command>`')
|
||||||
.format(command, command_list, command))
|
|
||||||
else:
|
else:
|
||||||
response = 'KeyError for {}'.format(command)
|
response = f'KeyError for {command}'
|
||||||
else:
|
else:
|
||||||
response = ('Invalid. Enter command key '
|
response = ('Invalid. Enter command key '
|
||||||
'or command key & name')
|
'or command key & name')
|
||||||
case 'info':
|
case 'info':
|
||||||
entries = XmppCommands.print_info_list(self)
|
entries = XmppCommands.print_info_list(self)
|
||||||
response = ('Available command options:\n'
|
response = ('Available command options:\n'
|
||||||
'```\n{}\n```\n'
|
f'```\n{entries}\n```\n'
|
||||||
'Usage: `info <option>`'
|
'Usage: `info <option>`')
|
||||||
.format(entries))
|
|
||||||
case _ if command_lowercase.startswith('info'):
|
case _ if command_lowercase.startswith('info'):
|
||||||
entry = command[5:].lower()
|
entry = command[5:].lower()
|
||||||
response = XmppCommands.print_info_specific(self, entry)
|
response = XmppCommands.print_info_specific(self, entry)
|
||||||
case _ if command_lowercase in ['greetings', 'hallo', 'hello',
|
case _ if command_lowercase in ['greetings', 'hallo', 'hello',
|
||||||
'hey', 'hi', 'hola', 'holla',
|
'hey', 'hi', 'hola', 'holla',
|
||||||
'hollo']:
|
'hollo']:
|
||||||
response = ('Greeting. My name is {}.\n'
|
response = (f'Greeting. My name is {self.alias}.\n'
|
||||||
'I am an Atom/RSS News Bot.\n'
|
'I am an Atom/RSS News Bot.\n'
|
||||||
'Send "help" for further instructions.\n'
|
'Send "help" for further instructions.\n')
|
||||||
.format(self.alias))
|
|
||||||
case _ if command_lowercase.startswith('add'):
|
case _ if command_lowercase.startswith('add'):
|
||||||
command = command[4:]
|
command = command[4:]
|
||||||
url = command.split(' ')[0]
|
url = command.split(' ')[0]
|
||||||
|
@ -202,24 +198,18 @@ class XmppChat:
|
||||||
if val:
|
if val:
|
||||||
await XmppCommands.set_filter_allow(
|
await XmppCommands.set_filter_allow(
|
||||||
db_file, val, True)
|
db_file, val, True)
|
||||||
response = ('Approved keywords\n'
|
response = f'Approved keywords\n```\n{val}\n```'
|
||||||
'```\n{}\n```'
|
|
||||||
.format(val))
|
|
||||||
else:
|
else:
|
||||||
response = ('No action has been taken.'
|
response = ('No action has been taken.\n'
|
||||||
'\n'
|
|
||||||
'Missing keywords.')
|
'Missing keywords.')
|
||||||
case _ if command_lowercase.startswith('allow -'):
|
case _ if command_lowercase.startswith('allow -'):
|
||||||
val = command[7:]
|
val = command[7:]
|
||||||
if val:
|
if val:
|
||||||
await XmppCommands.set_filter_allow(
|
await XmppCommands.set_filter_allow(
|
||||||
db_file, val, False)
|
db_file, val, False)
|
||||||
response = ('Approved keywords\n'
|
response = f'Approved keywords\n```\n{val}\n```'
|
||||||
'```\n{}\n```'
|
|
||||||
.format(val))
|
|
||||||
else:
|
else:
|
||||||
response = ('No action has been taken.'
|
response = ('No action has been taken.\n'
|
||||||
'\n'
|
|
||||||
'Missing keywords.')
|
'Missing keywords.')
|
||||||
case _ if command_lowercase.startswith('archive'):
|
case _ if command_lowercase.startswith('archive'):
|
||||||
val = command[8:]
|
val = command[8:]
|
||||||
|
@ -265,24 +255,18 @@ class XmppChat:
|
||||||
if val:
|
if val:
|
||||||
await XmppCommands.set_filter_allow(
|
await XmppCommands.set_filter_allow(
|
||||||
db_file, val, True)
|
db_file, val, True)
|
||||||
response = ('Rejected keywords\n'
|
response = f'Rejected keywords\n```\n{val}\n```'
|
||||||
'```\n{}\n```'
|
|
||||||
.format(val))
|
|
||||||
else:
|
else:
|
||||||
response = ('No action has been taken.'
|
response = ('No action has been taken.\n'
|
||||||
'\n'
|
|
||||||
'Missing keywords.')
|
'Missing keywords.')
|
||||||
case _ if command_lowercase.startswith('deny -'):
|
case _ if command_lowercase.startswith('deny -'):
|
||||||
val = command[6:]
|
val = command[6:]
|
||||||
if val:
|
if val:
|
||||||
await XmppCommands.set_filter_allow(
|
await XmppCommands.set_filter_allow(
|
||||||
db_file, val, False)
|
db_file, val, False)
|
||||||
response = ('Rejected keywords\n'
|
response = f'Rejected keywords\n```\n{val}\n```'
|
||||||
'```\n{}\n```'
|
|
||||||
.format(val))
|
|
||||||
else:
|
else:
|
||||||
response = ('No action has been taken.'
|
response = ('No action has been taken.\n'
|
||||||
'\n'
|
|
||||||
'Missing keywords.')
|
'Missing keywords.')
|
||||||
case _ if command_lowercase.startswith('disable'):
|
case _ if command_lowercase.startswith('disable'):
|
||||||
response = await XmppCommands.feed_disable(
|
response = await XmppCommands.feed_disable(
|
||||||
|
@ -296,8 +280,7 @@ class XmppChat:
|
||||||
if ext in ('md', 'opml'): # html xbel
|
if ext in ('md', 'opml'): # html xbel
|
||||||
status_type = 'dnd'
|
status_type = 'dnd'
|
||||||
status_message = ('📤️ Procesing request to '
|
status_message = ('📤️ Procesing request to '
|
||||||
'export feeds into {}...'
|
f'export feeds into {ext.upper()}...')
|
||||||
.format(ext.upper()))
|
|
||||||
# pending_tasks_num = len(self.pending_tasks[jid_bare])
|
# pending_tasks_num = len(self.pending_tasks[jid_bare])
|
||||||
pending_tasks_num = randrange(10000, 99999)
|
pending_tasks_num = randrange(10000, 99999)
|
||||||
self.pending_tasks[jid_bare][pending_tasks_num] = status_message
|
self.pending_tasks[jid_bare][pending_tasks_num] = status_message
|
||||||
|
@ -311,8 +294,8 @@ class XmppChat:
|
||||||
encrypted = True if encrypt_omemo else False
|
encrypted = True if encrypt_omemo else False
|
||||||
url = await XmppUpload.start(self, jid_bare, Path(pathname), encrypted=encrypted)
|
url = await XmppUpload.start(self, jid_bare, Path(pathname), encrypted=encrypted)
|
||||||
# response = (
|
# response = (
|
||||||
# 'Feeds exported successfully to {}.\n{}'
|
# f'Feeds exported successfully to {ex}.\n{url}'
|
||||||
# ).format(ex, url)
|
# )
|
||||||
# XmppMessage.send_oob_reply_message(message, url, response)
|
# XmppMessage.send_oob_reply_message(message, url, response)
|
||||||
if url:
|
if url:
|
||||||
chat_type = await XmppUtilities.get_chat_type(self, jid_bare)
|
chat_type = await XmppUtilities.get_chat_type(self, jid_bare)
|
||||||
|
@ -335,11 +318,11 @@ class XmppChat:
|
||||||
result, number = XmppCommands.list_feeds(db_file, query)
|
result, number = XmppCommands.list_feeds(db_file, query)
|
||||||
if number:
|
if number:
|
||||||
if query:
|
if query:
|
||||||
first_line = 'Subscriptions containing "{}":\n\n```\n'.format(query)
|
first_line = f'Subscriptions containing "{query}":\n\n```\n'
|
||||||
else:
|
else:
|
||||||
first_line = 'Subscriptions:\n\n```\n'
|
first_line = 'Subscriptions:\n\n```\n'
|
||||||
response = (first_line + result +
|
response = (first_line + result +
|
||||||
'\n```\nTotal of {} feeds'.format(number))
|
f'\n```\nTotal of {number} feeds')
|
||||||
case 'goodbye':
|
case 'goodbye':
|
||||||
if message_type == 'groupchat':
|
if message_type == 'groupchat':
|
||||||
await XmppCommands.muc_leave(self, jid_bare)
|
await XmppCommands.muc_leave(self, jid_bare)
|
||||||
|
@ -367,7 +350,7 @@ class XmppChat:
|
||||||
XmppStatusTask.restart_task(self, jid_bare)
|
XmppStatusTask.restart_task(self, jid_bare)
|
||||||
case _ if command_lowercase.startswith('pubsub list'):
|
case _ if command_lowercase.startswith('pubsub list'):
|
||||||
jid_full_pubsub = command[12:]
|
jid_full_pubsub = command[12:]
|
||||||
response = 'List of nodes for {}:\n```\n'.format(jid_full_pubsub)
|
response = f'List of nodes for {jid_full_pubsub}:\n```\n'
|
||||||
response = await XmppCommands.pubsub_list(self, jid_full_pubsub)
|
response = await XmppCommands.pubsub_list(self, jid_full_pubsub)
|
||||||
response += '```'
|
response += '```'
|
||||||
case _ if command_lowercase.startswith('pubsub send'):
|
case _ if command_lowercase.startswith('pubsub send'):
|
||||||
|
@ -390,8 +373,7 @@ class XmppChat:
|
||||||
command_lowercase.startswith('rss:/')):
|
command_lowercase.startswith('rss:/')):
|
||||||
url = command
|
url = command
|
||||||
status_type = 'dnd'
|
status_type = 'dnd'
|
||||||
status_message = ('📫️ Processing request to fetch data from {}'
|
status_message = f'📫️ Processing request to fetch data from {url}'
|
||||||
.format(url))
|
|
||||||
# pending_tasks_num = len(self.pending_tasks[jid_bare])
|
# pending_tasks_num = len(self.pending_tasks[jid_bare])
|
||||||
pending_tasks_num = randrange(10000, 99999)
|
pending_tasks_num = randrange(10000, 99999)
|
||||||
self.pending_tasks[jid_bare][pending_tasks_num] = status_message
|
self.pending_tasks[jid_bare][pending_tasks_num] = status_message
|
||||||
|
@ -406,9 +388,9 @@ class XmppChat:
|
||||||
XmppStatusTask.restart_task(self, jid_bare)
|
XmppStatusTask.restart_task(self, jid_bare)
|
||||||
# except:
|
# except:
|
||||||
# response = (
|
# response = (
|
||||||
# '> {}\nNews source is in the process '
|
# f'> {url}\nNews source is in the process '
|
||||||
# 'of being added to the subscription '
|
# 'of being added to the subscription '
|
||||||
# 'list.'.format(url)
|
# 'list.'
|
||||||
# )
|
# )
|
||||||
case _ if command_lowercase.startswith('interval'):
|
case _ if command_lowercase.startswith('interval'):
|
||||||
val = command[9:]
|
val = command[9:]
|
||||||
|
@ -497,7 +479,7 @@ class XmppChat:
|
||||||
Task.stop(self, jid_bare, 'status')
|
Task.stop(self, jid_bare, 'status')
|
||||||
status_type = 'dnd'
|
status_type = 'dnd'
|
||||||
status_message = ('📫️ Processing request to fetch data '
|
status_message = ('📫️ Processing request to fetch data '
|
||||||
'from {}'.format(url))
|
f'from {url}')
|
||||||
pending_tasks_num = randrange(10000, 99999)
|
pending_tasks_num = randrange(10000, 99999)
|
||||||
self.pending_tasks[jid_bare][pending_tasks_num] = status_message
|
self.pending_tasks[jid_bare][pending_tasks_num] = status_message
|
||||||
response = await XmppCommands.feed_read(
|
response = await XmppCommands.feed_read(
|
||||||
|
@ -513,7 +495,7 @@ class XmppChat:
|
||||||
if not num: num = 5
|
if not num: num = 5
|
||||||
count, result = XmppCommands.print_recent(self, db_file, num)
|
count, result = XmppCommands.print_recent(self, db_file, num)
|
||||||
if count:
|
if count:
|
||||||
response = 'Recent {} fetched titles:\n\n```'.format(num)
|
response = f'Recent {num} fetched titles:\n\n```'
|
||||||
response += result + '```\n'
|
response += result + '```\n'
|
||||||
else:
|
else:
|
||||||
response = result
|
response = result
|
||||||
|
@ -634,7 +616,7 @@ class XmppChat:
|
||||||
else:
|
else:
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
if Config.get_setting_value(self, jid_bare, 'finished'):
|
if Config.get_setting_value(self, jid_bare, 'finished'):
|
||||||
response_finished = 'Finished. Total time: {}s'.format(command_time_total)
|
response_finished = f'Finished. Total time: {command_time_total}s'
|
||||||
XmppMessage.send_reply(self, message, response_finished)
|
XmppMessage.send_reply(self, message, response_finished)
|
||||||
|
|
||||||
# if not response: response = 'EMPTY MESSAGE - ACTION ONLY'
|
# if not response: response = 'EMPTY MESSAGE - ACTION ONLY'
|
||||||
|
@ -651,10 +633,9 @@ class XmppChat:
|
||||||
# jid_bare, response)
|
# jid_bare, response)
|
||||||
|
|
||||||
# print(
|
# print(
|
||||||
# 'Message : {}\n'
|
# f'Message : {command}\n'
|
||||||
# 'JID : {}\n'
|
# f'JID : {jid_bare}\n'
|
||||||
# '{}\n'
|
# f'{response}\n'
|
||||||
# .format(command, jid_bare, response)
|
|
||||||
# )
|
# )
|
||||||
|
|
||||||
|
|
||||||
|
@ -673,7 +654,7 @@ class XmppChatAction:
|
||||||
Number. The default is None.
|
Number. The default is None.
|
||||||
"""
|
"""
|
||||||
function_name = sys._getframe().f_code.co_name
|
function_name = sys._getframe().f_code.co_name
|
||||||
logger.debug('{}: jid: {} num: {}'.format(function_name, jid_bare, num))
|
logger.debug(f'{function_name}: jid: {jid_bare} num: {num}')
|
||||||
db_file = config.get_pathname_to_database(jid_bare)
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
encrypt_omemo = Config.get_setting_value(self, jid_bare, 'omemo')
|
encrypt_omemo = Config.get_setting_value(self, jid_bare, 'omemo')
|
||||||
encrypted = True if encrypt_omemo else False
|
encrypted = True if encrypt_omemo else False
|
||||||
|
@ -851,8 +832,7 @@ class XmppChatAction:
|
||||||
|
|
||||||
async def list_unread_entries(self, result, feed_title, jid):
|
async def list_unread_entries(self, result, feed_title, jid):
|
||||||
function_name = sys._getframe().f_code.co_name
|
function_name = sys._getframe().f_code.co_name
|
||||||
logger.debug('{}: feed_title: {} jid: {}'
|
logger.debug(f'{function_name}: feed_title: {feed_title} jid: {jid}')
|
||||||
.format(function_name, feed_title, jid))
|
|
||||||
# TODO Add filtering
|
# TODO Add filtering
|
||||||
# TODO Do this when entry is added to list and mark it as read
|
# TODO Do this when entry is added to list and mark it as read
|
||||||
# DONE!
|
# DONE!
|
||||||
|
@ -868,7 +848,7 @@ class XmppChatAction:
|
||||||
# print("accepted:", result[1])
|
# print("accepted:", result[1])
|
||||||
# results.extend([result])
|
# results.extend([result])
|
||||||
|
|
||||||
# news_list = "You've got {} news items:\n".format(num)
|
# news_list = f'You have got {num} news items:\n'
|
||||||
# NOTE Why doesn't this work without list?
|
# NOTE Why doesn't this work without list?
|
||||||
# i.e. for result in results
|
# i.e. for result in results
|
||||||
# for result in results.fetchall():
|
# for result in results.fetchall():
|
||||||
|
@ -899,8 +879,7 @@ class XmppChatAction:
|
||||||
link = Url.remove_tracking_parameters(link)
|
link = Url.remove_tracking_parameters(link)
|
||||||
link = await Url.replace_hostname(link, "link") or link
|
link = await Url.replace_hostname(link, "link") or link
|
||||||
feed_id = result[4]
|
feed_id = result[4]
|
||||||
# news_item = ("\n{}\n{}\n{} [{}]\n").format(str(title), str(link),
|
# news_item = (f'\n{str(title)}\n{str(link)}\n{str(feed_title)} [{str(ix)}]\n')
|
||||||
# str(feed_title), str(ix))
|
|
||||||
formatting = Config.get_setting_value(self, jid, 'formatting')
|
formatting = Config.get_setting_value(self, jid, 'formatting')
|
||||||
news_item = formatting.format(feed_title=feed_title,
|
news_item = formatting.format(feed_title=feed_title,
|
||||||
title=title,
|
title=title,
|
||||||
|
@ -952,13 +931,12 @@ class XmppChatTask:
|
||||||
return
|
return
|
||||||
if jid_bare not in self.task_manager:
|
if jid_bare not in self.task_manager:
|
||||||
self.task_manager[jid_bare] = {}
|
self.task_manager[jid_bare] = {}
|
||||||
logger.info('Creating new task manager for JID {}'.format(jid_bare))
|
logger.info(f'Creating new task manager for JID {jid_bare}')
|
||||||
logger.info('Stopping task "interval" for JID {}'.format(jid_bare))
|
logger.info(f'Stopping task "interval" for JID {jid_bare}')
|
||||||
try:
|
try:
|
||||||
self.task_manager[jid_bare]['interval'].cancel()
|
self.task_manager[jid_bare]['interval'].cancel()
|
||||||
except:
|
except:
|
||||||
logger.info('No task "interval" for JID {} (XmppChatTask.task_message)'
|
logger.info('No task "interval" for JID {jid_bare} (XmppChatTask.task_message)')
|
||||||
.format(jid_bare))
|
logger.info('Starting tasks "interval" for JID {jid_bare}')
|
||||||
logger.info('Starting tasks "interval" for JID {}'.format(jid_bare))
|
|
||||||
self.task_manager[jid_bare]['interval'] = asyncio.create_task(
|
self.task_manager[jid_bare]['interval'] = asyncio.create_task(
|
||||||
XmppChatTask.task_message(self, jid_bare))
|
XmppChatTask.task_message(self, jid_bare))
|
||||||
|
|
|
@ -48,7 +48,7 @@ class XmppCommands:
|
||||||
def print_help_list():
|
def print_help_list():
|
||||||
command_list = Documentation.manual('commands.toml', section='all')
|
command_list = Documentation.manual('commands.toml', section='all')
|
||||||
message = ('Complete list of commands:\n'
|
message = ('Complete list of commands:\n'
|
||||||
'```\n{}\n```'.format(command_list))
|
f'```\n{command_list}\n```')
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class XmppCommands:
|
||||||
command_list = ''.join(command_list)
|
command_list = ''.join(command_list)
|
||||||
message = (command_list)
|
message = (command_list)
|
||||||
else:
|
else:
|
||||||
message = 'KeyError for {} {}'.format(command_root, command_name)
|
message = f'KeyError for {command_root} {command_name}'
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,12 +68,11 @@ class XmppCommands:
|
||||||
command_list = Documentation.manual('commands.toml', command)
|
command_list = Documentation.manual('commands.toml', command)
|
||||||
if command_list:
|
if command_list:
|
||||||
command_list = ' '.join(command_list)
|
command_list = ' '.join(command_list)
|
||||||
message = ('Available command `{}` keys:\n'
|
message = (f'Available command `{command}` keys:\n'
|
||||||
'```\n{}\n```\n'
|
f'```\n{command_list}\n```\n'
|
||||||
'Usage: `help {} <command>`'
|
f'Usage: `help {command} <command>`')
|
||||||
.format(command, command_list, command))
|
|
||||||
else:
|
else:
|
||||||
message = 'KeyError for {}'.format(command)
|
message = f'KeyError for {command}'
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +92,7 @@ class XmppCommands:
|
||||||
# command_list = '\n'.join(command_list)
|
# command_list = '\n'.join(command_list)
|
||||||
message = (entries[entry]['info'])
|
message = (entries[entry]['info'])
|
||||||
else:
|
else:
|
||||||
message = 'KeyError for {}'.format(entry)
|
message = f'KeyError for {entry}'
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
@ -187,18 +186,16 @@ class XmppCommands:
|
||||||
# feed_id = feed_id[0]
|
# feed_id = feed_id[0]
|
||||||
# await sqlite.mark_feed_as_read(db_file, feed_id)
|
# await sqlite.mark_feed_as_read(db_file, feed_id)
|
||||||
|
|
||||||
message = ('> {}\n'
|
message = (f'> {url}\n'
|
||||||
'News source has been '
|
'News source has been '
|
||||||
'added to subscription list.'
|
'added to subscription list.')
|
||||||
.format(url))
|
|
||||||
else:
|
else:
|
||||||
ix = exist[0]
|
ix = exist[0]
|
||||||
name = exist[1]
|
name = exist[1]
|
||||||
message = ('> {}\n'
|
message = (f'> {url}\n'
|
||||||
'News source "{}" is already '
|
f'News source "{name}" is already '
|
||||||
'listed in the subscription list at '
|
'listed in the subscription list at '
|
||||||
'index {}'
|
f'index {ix}')
|
||||||
.format(url, name, ix))
|
|
||||||
else:
|
else:
|
||||||
message = ('No action has been taken. Missing URL.')
|
message = ('No action has been taken. Missing URL.')
|
||||||
return message
|
return message
|
||||||
|
@ -248,8 +245,8 @@ class XmppCommands:
|
||||||
val_old = Config.get_setting_value(self, jid_bare, 'archive')
|
val_old = Config.get_setting_value(self, jid_bare, 'archive')
|
||||||
await Config.set_setting_value(
|
await Config.set_setting_value(
|
||||||
self, jid_bare, db_file, 'archive', val_new)
|
self, jid_bare, db_file, 'archive', val_new)
|
||||||
message = ('Maximum archived items has been set to {} (was: {}).'
|
message = ('Maximum archived items has been set to {val_new} '
|
||||||
.format(val_new, val_old))
|
'(was: {val_old}).')
|
||||||
except:
|
except:
|
||||||
message = 'No action has been taken. Enter a numeric value only.'
|
message = 'No action has been taken. Enter a numeric value only.'
|
||||||
return message
|
return message
|
||||||
|
@ -257,15 +254,13 @@ class XmppCommands:
|
||||||
|
|
||||||
async def bookmark_add(self, muc_jid):
|
async def bookmark_add(self, muc_jid):
|
||||||
await XmppBookmark.add(self, jid=muc_jid)
|
await XmppBookmark.add(self, jid=muc_jid)
|
||||||
message = ('Groupchat {} has been added to bookmarks.'
|
message = f'Groupchat {muc_jid} has been added to bookmarks.'
|
||||||
.format(muc_jid))
|
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
async def bookmark_del(self, muc_jid):
|
async def bookmark_del(self, muc_jid):
|
||||||
await XmppBookmark.remove(self, muc_jid)
|
await XmppBookmark.remove(self, muc_jid)
|
||||||
message = ('Groupchat {} has been removed from bookmarks.'
|
message = f'Groupchat {muc_jid} has been removed from bookmarks.'
|
||||||
.format(muc_jid))
|
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,8 +269,7 @@ class XmppCommands:
|
||||||
self.settings[jid_bare][key] = None
|
self.settings[jid_bare][key] = None
|
||||||
db_file = config.get_pathname_to_database(jid_bare)
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
await sqlite.delete_setting(db_file, key)
|
await sqlite.delete_setting(db_file, key)
|
||||||
message = ('Setting {} has been restored to default value.'
|
message = f'Setting {key} has been restored to default value.'
|
||||||
.format(key))
|
|
||||||
else:
|
else:
|
||||||
del self.settings[jid_bare]
|
del self.settings[jid_bare]
|
||||||
db_file = config.get_pathname_to_database(jid_bare)
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
|
@ -286,7 +280,7 @@ class XmppCommands:
|
||||||
|
|
||||||
async def clear_filter(db_file, key):
|
async def clear_filter(db_file, key):
|
||||||
await sqlite.delete_filter(db_file, key)
|
await sqlite.delete_filter(db_file, key)
|
||||||
message = 'Filter {} has been purged.'.format(key)
|
message = f'Filter {key} has been purged.'
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
@ -294,11 +288,11 @@ class XmppCommands:
|
||||||
conferences = await XmppBookmark.get_bookmarks(self)
|
conferences = await XmppBookmark.get_bookmarks(self)
|
||||||
message = '\nList of groupchats:\n\n```\n'
|
message = '\nList of groupchats:\n\n```\n'
|
||||||
for conference in conferences:
|
for conference in conferences:
|
||||||
message += ('Name: {}\n'
|
conference_name = conference['name']
|
||||||
'Room: {}\n'
|
conference_jid = conference['jid']
|
||||||
'\n'
|
message += (f'Name: {conference_name}\n'
|
||||||
.format(conference['name'], conference['jid']))
|
f'Room: {conference_jid}\n\n')
|
||||||
message += ('```\nTotal of {} groupchats.\n'.format(len(conferences)))
|
message += f'```\nTotal of {len(conferences)} groupchats.\n'
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
@ -333,7 +327,7 @@ class XmppCommands:
|
||||||
|
|
||||||
def export_feeds(dir_cache, jid_bare, ext):
|
def export_feeds(dir_cache, jid_bare, ext):
|
||||||
pathname = Feed.export_feeds(dir_cache, jid_bare, ext)
|
pathname = Feed.export_feeds(dir_cache, jid_bare, ext)
|
||||||
message = 'Feeds successfuly exported to {}.'.format(ext)
|
message = f'Feeds successfuly exported to {ext}.'
|
||||||
return pathname, message
|
return pathname, message
|
||||||
|
|
||||||
|
|
||||||
|
@ -347,8 +341,7 @@ class XmppCommands:
|
||||||
result = await fetch.http(url)
|
result = await fetch.http(url)
|
||||||
count = await Opml.import_from_file(db_file, result)
|
count = await Opml.import_from_file(db_file, result)
|
||||||
if count:
|
if count:
|
||||||
message = ('Successfully imported {} feeds.'
|
message = f'Successfully imported {count} feeds.'
|
||||||
.format(count))
|
|
||||||
else:
|
else:
|
||||||
message = 'OPML file was not imported.'
|
message = 'OPML file was not imported.'
|
||||||
return message
|
return message
|
||||||
|
@ -360,7 +353,7 @@ class XmppCommands:
|
||||||
for item in iq['disco_items']:
|
for item in iq['disco_items']:
|
||||||
item_id = item['node']
|
item_id = item['node']
|
||||||
item_name = item['name']
|
item_name = item['name']
|
||||||
message += 'Name: {}\nNode: {}\n\n'.format(item_name, item_id)
|
message += f'Name: {item_name}\nNode: {item_id}\n\n'
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
@ -403,8 +396,7 @@ class XmppCommands:
|
||||||
break
|
break
|
||||||
# task.clean_tasks_xmpp_chat(self, jid_bare, ['status'])
|
# task.clean_tasks_xmpp_chat(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 {url}'
|
||||||
.format(url))
|
|
||||||
# pending_tasks_num = len(self.pending_tasks[jid_bare])
|
# pending_tasks_num = len(self.pending_tasks[jid_bare])
|
||||||
pending_tasks_num = randrange(10000, 99999)
|
pending_tasks_num = randrange(10000, 99999)
|
||||||
self.pending_tasks[jid_bare][pending_tasks_num] = status_message
|
self.pending_tasks[jid_bare][pending_tasks_num] = status_message
|
||||||
|
@ -421,35 +413,36 @@ class XmppCommands:
|
||||||
identifier)
|
identifier)
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
results = result
|
results = result
|
||||||
message = "Syndication feeds found for {}\n\n```\n".format(url)
|
message = f'Syndication feeds found for {url}\n\n```\n'
|
||||||
for result in results:
|
for result in results:
|
||||||
message += ("Title : {}\n"
|
result_name = result['name']
|
||||||
"Link : {}\n"
|
result_link = result['link']
|
||||||
"\n"
|
message += ('Title : {result_name}\n'
|
||||||
.format(result['name'], result['link']))
|
'Link : {result_link}\n\n')
|
||||||
message += '```\nTotal of {} feeds.'.format(len(results))
|
message += '```\nTotal of {len(results)} feeds.'
|
||||||
elif result['exist']:
|
elif result['exist']:
|
||||||
message = ('> {}\nNews source "{}" is already '
|
result_link = result['link']
|
||||||
|
result_name = result['name']
|
||||||
|
result_index = result['index']
|
||||||
|
message = (f'> {result_link}\nNews source "{result_name}" is already '
|
||||||
'listed in the subscription list at '
|
'listed in the subscription list at '
|
||||||
'index {}'
|
f'index {result_index}')
|
||||||
.format(result['link'],
|
|
||||||
result['name'],
|
|
||||||
result['index']))
|
|
||||||
elif result['identifier']:
|
elif result['identifier']:
|
||||||
message = ('> {}\nIdentifier "{}" is already '
|
result_link = result['link']
|
||||||
'allocated to index {}'
|
result_identifier = result['identifier']
|
||||||
.format(result['link'],
|
result_index = result['index']
|
||||||
result['identifier'],
|
message = (f'> {result_link}\nIdentifier "{result_identifier}" is already '
|
||||||
result['index']))
|
f'allocated to index {result_index}')
|
||||||
elif result['error']:
|
elif result['error']:
|
||||||
message = ('> {}\nNo subscriptions were found. '
|
result_message = result['message']
|
||||||
'Reason: {} (status code: {})'
|
result_code = result['code']
|
||||||
.format(url, result['message'],
|
message = (f'> {url}\nNo subscriptions were found. '
|
||||||
result['code']))
|
f'Reason: {result_message} (status code: {result_code})')
|
||||||
else:
|
else:
|
||||||
message = ('> {}\nNews source "{}" has been '
|
result_link = result['link']
|
||||||
'added to subscription list.'
|
result_name = result['name']
|
||||||
.format(result['link'], result['name']))
|
message = (f'> {result_link}\nNews source "{result_name}" has been '
|
||||||
|
'added to subscription list.')
|
||||||
# task.clean_tasks_xmpp_chat(self, jid_bare, ['status'])
|
# task.clean_tasks_xmpp_chat(self, jid_bare, ['status'])
|
||||||
del self.pending_tasks[jid_bare][pending_tasks_num]
|
del self.pending_tasks[jid_bare][pending_tasks_num]
|
||||||
# del self.pending_tasks[jid_bare][self.pending_tasks_counter]
|
# del self.pending_tasks[jid_bare][self.pending_tasks_counter]
|
||||||
|
@ -457,9 +450,9 @@ class XmppCommands:
|
||||||
XmppStatusTask.restart_task(self, jid_bare)
|
XmppStatusTask.restart_task(self, jid_bare)
|
||||||
# except:
|
# except:
|
||||||
# response = (
|
# response = (
|
||||||
# '> {}\nNews source is in the process '
|
# f'> {url}\nNews source is in the process '
|
||||||
# 'of being added to the subscription '
|
# 'of being added to the subscription '
|
||||||
# 'list.'.format(url)
|
# 'list.'
|
||||||
# )
|
# )
|
||||||
else:
|
else:
|
||||||
message = ('No action has been taken.'
|
message = ('No action has been taken.'
|
||||||
|
@ -490,15 +483,13 @@ class XmppCommands:
|
||||||
result = await Feed.add_feed(self, jid_bare, db_file, url, identifier)
|
result = await Feed.add_feed(self, jid_bare, db_file, url, identifier)
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
results = result
|
results = result
|
||||||
message = ("Syndication feeds found for {}\n\n```\n"
|
message = f"Syndication feeds found for {url}\n\n```\n"
|
||||||
.format(url))
|
|
||||||
for result in results:
|
for result in results:
|
||||||
message += ("Title : {}\n"
|
message += ("Title : {}\n"
|
||||||
"Link : {}\n"
|
"Link : {}\n"
|
||||||
"\n"
|
"\n"
|
||||||
.format(result['name'], result['link']))
|
.format(result['name'], result['link']))
|
||||||
message += ('```\nTotal of {} feeds.'
|
message += f'```\nTotal of {results} feeds.'
|
||||||
.format(len(results)))
|
|
||||||
elif result['exist']:
|
elif result['exist']:
|
||||||
message = ('> {}\nNews source "{}" is already '
|
message = ('> {}\nNews source "{}" is already '
|
||||||
'listed in the subscription list at '
|
'listed in the subscription list at '
|
||||||
|
@ -516,9 +507,9 @@ class XmppCommands:
|
||||||
.format(result['link'], result['name']))
|
.format(result['link'], result['name']))
|
||||||
# except:
|
# except:
|
||||||
# response = (
|
# response = (
|
||||||
# '> {}\nNews source is in the process '
|
# f'> {url}\nNews source is in the process '
|
||||||
# 'of being added to the subscription '
|
# 'of being added to the subscription '
|
||||||
# 'list.'.format(url)
|
# 'list.'
|
||||||
# )
|
# )
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
@ -532,12 +523,10 @@ class XmppCommands:
|
||||||
message = ''
|
message = ''
|
||||||
if number:
|
if number:
|
||||||
for id, title, url in feeds:
|
for id, title, url in feeds:
|
||||||
message += ('\nName : {} [{}]'
|
message += (f'\nName : {str(title)} [{str(id)}]'
|
||||||
'\nURL : {}'
|
f'\nURL : {str(url)}\n')
|
||||||
'\n'
|
|
||||||
.format(str(title), str(id), str(url)))
|
|
||||||
elif query:
|
elif query:
|
||||||
message = "No feeds were found for: {}".format(query)
|
message = f"No feeds were found for: {query}"
|
||||||
else:
|
else:
|
||||||
url = Utilities.pick_a_feed()
|
url = Utilities.pick_a_feed()
|
||||||
message = ('List of subscriptions is empty. '
|
message = ('List of subscriptions is empty. '
|
||||||
|
@ -559,8 +548,8 @@ class XmppCommands:
|
||||||
val_old = Config.get_setting_value(self, jid_bare, 'interval')
|
val_old = Config.get_setting_value(self, jid_bare, 'interval')
|
||||||
await Config.set_setting_value(
|
await Config.set_setting_value(
|
||||||
self, jid_bare, db_file, 'interval', val_new)
|
self, jid_bare, db_file, 'interval', val_new)
|
||||||
message = ('Updates will be sent every {} minutes '
|
message = (f'Updates will be sent every {val_new} minutes '
|
||||||
'(was: {}).'.format(val_new, val_old))
|
f'(was: {val_old}).')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(str(e))
|
logger.error(str(e))
|
||||||
message = ('No action has been taken. Enter a numeric value only.')
|
message = ('No action has been taken. Enter a numeric value only.')
|
||||||
|
@ -580,12 +569,12 @@ class XmppCommands:
|
||||||
result = await XmppMuc.join(self, muc_jid)
|
result = await XmppMuc.join(self, muc_jid)
|
||||||
# await XmppBookmark.add(self, jid=muc_jid)
|
# await XmppBookmark.add(self, jid=muc_jid)
|
||||||
if result == 'ban':
|
if result == 'ban':
|
||||||
message = '{} is banned from {}'.format(self.alias, muc_jid)
|
message = f'{self.alias} is banned from {muc_jid}'
|
||||||
else:
|
else:
|
||||||
await XmppBookmark.add(self, muc_jid)
|
await XmppBookmark.add(self, muc_jid)
|
||||||
message = 'Joined groupchat {}'.format(muc_jid)
|
message = f'Joined groupchat {muc_jid}'
|
||||||
else:
|
else:
|
||||||
message = '> {}\nGroupchat JID appears to be invalid.'.format(muc_jid)
|
message = f'> {muc_jid}\nGroupchat JID appears to be invalid.'
|
||||||
else:
|
else:
|
||||||
message = '> {}\nGroupchat JID is missing.'
|
message = '> {}\nGroupchat JID is missing.'
|
||||||
return message
|
return message
|
||||||
|
@ -606,11 +595,10 @@ class XmppCommands:
|
||||||
if not val_new: # i.e. val_new == 0
|
if not val_new: # i.e. val_new == 0
|
||||||
# TODO Add action to disable limit
|
# TODO Add action to disable limit
|
||||||
message = ('Summary length limit is disabled '
|
message = ('Summary length limit is disabled '
|
||||||
'(was: {}).'.format(val_old))
|
f'(was: {val_old}).')
|
||||||
else:
|
else:
|
||||||
message = ('Summary maximum length is set to '
|
message = ('Summary maximum length is set to '
|
||||||
'{} characters (was: {}).'
|
f'{val_new} characters (was: {val_old}).')
|
||||||
.format(val_new, val_old))
|
|
||||||
except:
|
except:
|
||||||
message = ('No action has been taken.'
|
message = ('No action has been taken.'
|
||||||
'\n'
|
'\n'
|
||||||
|
@ -661,7 +649,7 @@ class XmppCommands:
|
||||||
nid = info[1]
|
nid = info[1]
|
||||||
if jid:
|
if jid:
|
||||||
XmppPubsub.delete_node(self, jid, nid)
|
XmppPubsub.delete_node(self, jid, nid)
|
||||||
message = 'Deleted node: {}'.format(nid)
|
message = f'Deleted node: {nid}'
|
||||||
else:
|
else:
|
||||||
message = 'PubSub JID is missing. Enter PubSub JID.'
|
message = 'PubSub JID is missing. Enter PubSub JID.'
|
||||||
else:
|
else:
|
||||||
|
@ -679,7 +667,7 @@ class XmppCommands:
|
||||||
nid = info[1]
|
nid = info[1]
|
||||||
if jid:
|
if jid:
|
||||||
XmppPubsub.purge_node(self, jid, nid)
|
XmppPubsub.purge_node(self, jid, nid)
|
||||||
message = 'Purged node: {}'.format(nid)
|
message = f'Purged node: {nid}'
|
||||||
else:
|
else:
|
||||||
message = 'PubSub JID is missing. Enter PubSub JID.'
|
message = 'PubSub JID is missing. Enter PubSub JID.'
|
||||||
else:
|
else:
|
||||||
|
@ -714,13 +702,12 @@ class XmppCommands:
|
||||||
val_new = int(val)
|
val_new = int(val)
|
||||||
val_old = Config.get_setting_value(self, jid_bare, 'quantum')
|
val_old = Config.get_setting_value(self, jid_bare, 'quantum')
|
||||||
# response = (
|
# response = (
|
||||||
# 'Every update will contain {} news items.'
|
# f'Every update will contain {response} news items.'
|
||||||
# ).format(response)
|
# )
|
||||||
db_file = config.get_pathname_to_database(jid_bare)
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
await Config.set_setting_value(
|
await Config.set_setting_value(
|
||||||
self, jid_bare, db_file, 'quantum', val_new)
|
self, jid_bare, db_file, 'quantum', val_new)
|
||||||
message = ('Next update will contain {} news items (was: {}).'
|
message = f'Next update will contain {val_new} news items (was: {val_old}).'
|
||||||
.format(val_new, val_old))
|
|
||||||
except:
|
except:
|
||||||
message = 'No action has been taken. Enter a numeric value only.'
|
message = 'No action has been taken. Enter a numeric value only.'
|
||||||
return message
|
return message
|
||||||
|
@ -754,25 +741,21 @@ class XmppCommands:
|
||||||
result = await FeedDiscovery.probe_page(url, document)
|
result = await FeedDiscovery.probe_page(url, document)
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
results = result
|
results = result
|
||||||
message = ("Syndication feeds found for {}\n\n```\n"
|
message = f"Syndication feeds found for {url}\n\n```\n"
|
||||||
.format(url))
|
|
||||||
for result in results:
|
for result in results:
|
||||||
message += ("Title : {}\n"
|
result_name = result['name']
|
||||||
"Link : {}\n"
|
result_link = result['link']
|
||||||
"\n"
|
message += ("Title : {result_name}\n"
|
||||||
.format(result['name'], result['link']))
|
"Link : {result_link}\n\n")
|
||||||
message += ('```\nTotal of {} feeds.'
|
message += f'```\nTotal of {results} feeds.'
|
||||||
.format(len(results)))
|
|
||||||
break
|
break
|
||||||
elif not result:
|
elif not result:
|
||||||
message = ('> {}\nNo subscriptions were found.'
|
message = f'> {url}\nNo subscriptions were found.'
|
||||||
.format(url))
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
url = result['link']
|
url = result['link']
|
||||||
else:
|
else:
|
||||||
message = ('> {}\nFailed to load URL. Reason: {}'
|
message = f'> {url}\nFailed to load URL. Reason: {status}'
|
||||||
.format(url, status))
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
message = ('No action has been taken. Missing URL.')
|
message = ('No action has been taken. Missing URL.')
|
||||||
|
@ -792,25 +775,21 @@ class XmppCommands:
|
||||||
result = await FeedDiscovery.probe_page(url, document)
|
result = await FeedDiscovery.probe_page(url, document)
|
||||||
if isinstance(result, list):
|
if isinstance(result, list):
|
||||||
results = result
|
results = result
|
||||||
message = ("Syndication feeds found for {}\n\n```\n"
|
message = f"Syndication feeds found for {url}\n\n```\n"
|
||||||
.format(url))
|
|
||||||
for result in results:
|
for result in results:
|
||||||
message += ("Title : {}\n"
|
result_name = result['name']
|
||||||
"Link : {}\n"
|
result_link = result['link']
|
||||||
"\n"
|
message += (f"Title : {result_name}\n"
|
||||||
.format(result['name'], result['link']))
|
f"Link : {result_link}\\n")
|
||||||
message += ('```\nTotal of {} feeds.'
|
message += f'```\nTotal of {len(results)} feeds.'
|
||||||
.format(len(results)))
|
|
||||||
break
|
break
|
||||||
elif not result:
|
elif not result:
|
||||||
message = ('> {}\nNo subscriptions were found.'
|
message = f'> {url}\nNo subscriptions were found.'
|
||||||
.format(url))
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
url = result['link']
|
url = result['link']
|
||||||
else:
|
else:
|
||||||
message = ('> {}\nFailed to load URL. Reason: {}'
|
message = f'> {url}\nFailed to load URL. Reason: {status}'
|
||||||
.format(url, status))
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
message = ('No action has been taken.'
|
message = ('No action has been taken.'
|
||||||
|
@ -837,7 +816,7 @@ class XmppCommands:
|
||||||
message = ''
|
message = ''
|
||||||
for i in result:
|
for i in result:
|
||||||
title, url, date = i
|
title, url, date = i
|
||||||
message += ('\n{}\n{}\n'.format(title, url))
|
message += f'\n{title}\n{url}\n'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(str(e))
|
logger.error(str(e))
|
||||||
count = False
|
count = False
|
||||||
|
@ -877,13 +856,13 @@ class XmppCommands:
|
||||||
if len(sub_removed):
|
if len(sub_removed):
|
||||||
message += '\nThe following subscriptions have been removed:\n\n'
|
message += '\nThe following subscriptions have been removed:\n\n'
|
||||||
for url in sub_removed:
|
for url in sub_removed:
|
||||||
message += '{}\n'.format(url)
|
message += f'{url}\n'
|
||||||
if len(url_invalid):
|
if len(url_invalid):
|
||||||
urls = ', '.join(url_invalid)
|
urls = ', '.join(url_invalid)
|
||||||
message += '\nThe following URLs do not exist:\n\n{}\n'.format(urls)
|
message += f'\nThe following URLs do not exist:\n\n{urls}\n'
|
||||||
if len(ixs_invalid):
|
if len(ixs_invalid):
|
||||||
ixs = ', '.join(ixs_invalid)
|
ixs = ', '.join(ixs_invalid)
|
||||||
message += '\nThe following indexes do not exist:\n\n{}\n'.format(ixs)
|
message += f'\nThe following indexes do not exist:\n\n{ixs}\n'
|
||||||
message += '\n```'
|
message += '\n```'
|
||||||
else:
|
else:
|
||||||
message = ('No action has been taken.'
|
message = ('No action has been taken.'
|
||||||
|
@ -924,13 +903,13 @@ class XmppCommands:
|
||||||
if len(sub_marked):
|
if len(sub_marked):
|
||||||
message += '\nThe following subscriptions have been marked as read:\n\n'
|
message += '\nThe following subscriptions have been marked as read:\n\n'
|
||||||
for url in sub_marked:
|
for url in sub_marked:
|
||||||
message += '{}\n'.format(url)
|
message += f'{url}\n'
|
||||||
if len(url_invalid):
|
if len(url_invalid):
|
||||||
urls = ', '.join(url_invalid)
|
urls = ', '.join(url_invalid)
|
||||||
message += '\nThe following URLs do not exist:\n\n{}\n'.format(urls)
|
message += f'\nThe following URLs do not exist:\n\n{urls}\n'
|
||||||
if len(ixs_invalid):
|
if len(ixs_invalid):
|
||||||
ixs = ', '.join(ixs_invalid)
|
ixs = ', '.join(ixs_invalid)
|
||||||
message += '\nThe following indexes do not exist:\n\n{}\n'.format(ixs)
|
message += f'\nThe following indexes do not exist:\n\n{ixs}\n'
|
||||||
message += '\n```'
|
message += '\n```'
|
||||||
else:
|
else:
|
||||||
await sqlite.mark_all_as_read(db_file)
|
await sqlite.mark_all_as_read(db_file)
|
||||||
|
@ -942,20 +921,17 @@ class XmppCommands:
|
||||||
if query:
|
if query:
|
||||||
if len(query) > 3:
|
if len(query) > 3:
|
||||||
results = sqlite.search_entries(db_file, query)
|
results = sqlite.search_entries(db_file, query)
|
||||||
message = ("Search results for '{}':\n\n```"
|
message = f"Search results for '{query}':\n\n```"
|
||||||
.format(query))
|
|
||||||
for result in results:
|
for result in results:
|
||||||
message += ("\n{}\n{}\n"
|
message += f'\n{str(result[0])}\n{str(result[1])}\n'
|
||||||
.format(str(result[0]), str(result[1])))
|
|
||||||
if len(results):
|
if len(results):
|
||||||
message += "```\nTotal of {} results".format(len(results))
|
message += f'```\nTotal of {len(results)} results'
|
||||||
else:
|
else:
|
||||||
message = "No results were found for: {}".format(query)
|
message = f'No results were found for: {query}'
|
||||||
else:
|
else:
|
||||||
message = 'Enter at least 4 characters to search'
|
message = 'Enter at least 4 characters to search'
|
||||||
else:
|
else:
|
||||||
message = ('No action has been taken.'
|
message = ('No action has been taken.\n'
|
||||||
'\n'
|
|
||||||
'Missing search query.')
|
'Missing search query.')
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
@ -1010,12 +986,9 @@ class XmppCommands:
|
||||||
"\n"
|
"\n"
|
||||||
"```"
|
"```"
|
||||||
"\n"
|
"\n"
|
||||||
"News items : {}/{}\n"
|
f"News items : {entries_unread}/{entries}\n"
|
||||||
"News sources : {}/{}\n"
|
f"News sources : {feeds_active}/{feeds_all}\n"
|
||||||
"```").format(entries_unread,
|
"```")
|
||||||
entries,
|
|
||||||
feeds_active,
|
|
||||||
feeds_all)
|
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
@ -1028,11 +1001,9 @@ class XmppCommands:
|
||||||
name = name[0]
|
name = name[0]
|
||||||
addr = sqlite.get_feed_url(db_file, feed_id)
|
addr = sqlite.get_feed_url(db_file, feed_id)
|
||||||
addr = addr[0]
|
addr = addr[0]
|
||||||
message = ('Updates are now disabled for subscription:\n{}\n{}'
|
message = f'Updates are now disabled for subscription:\n{addr}\n{name}'
|
||||||
.format(addr, name))
|
|
||||||
except:
|
except:
|
||||||
message = ('No action has been taken. No news source with index {}.'
|
message = f'No action has been taken. No news source with index {feed_id}.'
|
||||||
.format(feed_id))
|
|
||||||
XmppStatusTask.restart_task(self, jid_bare)
|
XmppStatusTask.restart_task(self, jid_bare)
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
@ -1043,13 +1014,11 @@ class XmppCommands:
|
||||||
await sqlite.set_enabled_status(db_file, feed_id, 1)
|
await sqlite.set_enabled_status(db_file, feed_id, 1)
|
||||||
name = sqlite.get_feed_title(db_file, feed_id)[0]
|
name = sqlite.get_feed_title(db_file, feed_id)[0]
|
||||||
addr = sqlite.get_feed_url(db_file, feed_id)[0]
|
addr = sqlite.get_feed_url(db_file, feed_id)[0]
|
||||||
message = ('> {}\n'
|
message = (f'> {addr}\n'
|
||||||
'Updates are now enabled for news source "{}"'
|
f'Updates are now enabled for news source "{name}"')
|
||||||
.format(addr, name))
|
|
||||||
except:
|
except:
|
||||||
message = ('No action has been taken.'
|
message = ('No action has been taken.\n'
|
||||||
'\n'
|
f'No news source with index {feed_id}.')
|
||||||
'No news source with index {}.'.format(feed_id))
|
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
@ -1071,13 +1040,11 @@ class XmppCommands:
|
||||||
else:
|
else:
|
||||||
await sqlite.set_feed_title(db_file, feed_id,
|
await sqlite.set_feed_title(db_file, feed_id,
|
||||||
name)
|
name)
|
||||||
message = ('> {}'
|
message = (f'> {name_old}\n'
|
||||||
'\n'
|
f'Subscription #{feed_id} has been '
|
||||||
'Subscription #{} has been '
|
f'renamed to "{name}".')
|
||||||
'renamed to "{}".'.format(
|
|
||||||
name_old,feed_id, name))
|
|
||||||
else:
|
else:
|
||||||
message = 'Subscription with Id {} does not exist.'.format(feed_id)
|
message = f'Subscription with Id {feed_id} does not exist.'
|
||||||
except:
|
except:
|
||||||
message = ('No action has been taken.'
|
message = ('No action has been taken.'
|
||||||
'\n'
|
'\n'
|
||||||
|
@ -1130,7 +1097,7 @@ class XmppCommands:
|
||||||
|
|
||||||
def print_support_jid():
|
def print_support_jid():
|
||||||
muc_jid = 'slixfeed@chat.woodpeckersnest.space'
|
muc_jid = 'slixfeed@chat.woodpeckersnest.space'
|
||||||
message = 'Join xmpp:{}?join'.format(muc_jid)
|
message = f'Join xmpp:{muc_jid}?join'
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue