Fix automatic update; Fix command search.

This commit is contained in:
Schimon Jehudah, Adv. 2024-06-02 11:23:26 +03:00
parent 5ee75572ab
commit 5a2a2f9e3f
8 changed files with 920 additions and 548 deletions

View file

@ -178,22 +178,28 @@ def main():
# Try configuration file
if 'client' in account_xmpp:
from slixfeed.xmpp.client import Slixfeed
from slixfeed.xmpp.client import XmppClient
jid = account_xmpp['client']['jid']
password = account_xmpp['client']['password']
alias = account_xmpp['client']['alias'] if 'alias' in account_xmpp['client'] else None
hostname = account_xmpp['client']['hostname'] if 'hostname' in account_xmpp['client'] else None
port = account_xmpp['client']['port'] if 'port' in account_xmpp['client'] else None
Slixfeed(jid, password, hostname, port, alias)
XmppClient(jid, password, hostname, port, alias)
# xmpp_client = Slixfeed(jid, password, hostname, port, alias)
# xmpp_client.connect((hostname, port)) if hostname and port else xmpp_client.connect()
# xmpp_client.process()
if 'component' in account_xmpp:
from slixfeed.xmpp.component import SlixfeedComponent
from slixfeed.xmpp.component import XmppComponent
jid = account_xmpp['component']['jid']
password = account_xmpp['component']['password']
secret = account_xmpp['component']['password']
alias = account_xmpp['component']['alias'] if 'alias' in account_xmpp['component'] else None
hostname = account_xmpp['component']['hostname'] if 'hostname' in account_xmpp['component'] else None
port = account_xmpp['component']['port'] if 'port' in account_xmpp['component'] else None
SlixfeedComponent(jid, password, hostname, port, alias).process()
XmppComponent(jid, secret, hostname, port, alias)
# xmpp_component = SlixfeedComponent(jid, secret, hostname, port, alias)
# xmpp_component.connect()
# xmpp_component.process()
sys.exit(0)

View file

@ -71,9 +71,9 @@ except:
logger = Logger(__name__)
def export_feeds(self, jid, jid_file, ext):
def export_feeds(self, jid_bare, ext):
function_name = sys._getframe().f_code.co_name
logger.debug('{}: jid: {}: jid_file: {}: ext: {}'.format(function_name, jid, jid_file, ext))
logger.debug('{}: jid_bare: {}: ext: {}'.format(function_name, jid_bare, ext))
cache_dir = config.get_default_cache_directory()
if not os.path.isdir(cache_dir):
os.mkdir(cache_dir)
@ -81,15 +81,15 @@ def export_feeds(self, jid, jid_file, ext):
os.mkdir(cache_dir + '/' + ext)
filename = os.path.join(
cache_dir, ext, 'slixfeed_' + dt.timestamp() + '.' + ext)
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
results = sqlite.get_feeds(db_file)
match ext:
# case 'html':
# response = 'Not yet implemented.'
case 'md':
export_to_markdown(jid, filename, results)
export_to_markdown(jid_bare, filename, results)
case 'opml':
export_to_opml(jid, filename, results)
export_to_opml(jid_bare, filename, results)
# case 'xbel':
# response = 'Not yet implemented.'
return filename
@ -144,7 +144,7 @@ if (await get_chat_type(self, jid_bare) == 'chat' and
"""
async def xmpp_send_status_message(self, jid):
async def xmpp_send_status_message(self, jid_bare):
"""
Send status message.
@ -154,13 +154,12 @@ async def xmpp_send_status_message(self, jid):
Jabber ID.
"""
function_name = sys._getframe().f_code.co_name
logger.debug('{}: jid: {}'.format(function_name, jid))
logger.debug('{}: jid: {}'.format(function_name, jid_bare))
status_text = '📜️ Slixfeed RSS News Bot'
jid_file = jid.replace('/', '_')
db_file = config.get_pathname_to_database(jid_file)
enabled = Config.get_setting_value(self.settings, jid, 'enabled')
db_file = config.get_pathname_to_database(jid_bare)
enabled = Config.get_setting_value(self.settings, jid_bare, 'enabled')
if enabled:
jid_task = self.pending_tasks[jid]
jid_task = self.pending_tasks[jid_bare]
if len(jid_task):
status_mode = 'dnd'
status_text = jid_task[list(jid_task.keys())[0]]
@ -189,7 +188,7 @@ async def xmpp_send_status_message(self, jid):
status_text = '📪️ Send "Start" to receive updates'
# breakpoint()
# print(await current_time(), status_text, "for", jid)
XmppPresence.send(self, jid, status_text, status_type=status_mode)
XmppPresence.send(self, jid_bare, status_text, status_type=status_mode)
# await asyncio.sleep(60 * 20)
# await refresh_task(self, jid, send_status, 'status', '90')
# loop.call_at(
@ -250,7 +249,7 @@ async def xmpp_pubsub_send_unread_items(self, jid_bare):
"""
function_name = sys._getframe().f_code.co_name
logger.debug('{}: jid_bare: {}'.format(function_name, jid_bare))
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
report = {}
subscriptions = sqlite.get_active_feeds_url(db_file)
for url in subscriptions:
@ -491,7 +490,7 @@ def create_rfc4287_entry(feed_entry):
return node_entry
async def xmpp_chat_send_unread_items(self, jid, num=None):
async def xmpp_chat_send_unread_items(self, jid_bare, num=None):
"""
Send news items as messages.
@ -503,18 +502,17 @@ async def xmpp_chat_send_unread_items(self, jid, num=None):
Number. The default is None.
"""
function_name = sys._getframe().f_code.co_name
logger.debug('{}: jid: {} num: {}'.format(function_name, jid, num))
jid_file = jid.replace('/', '_')
db_file = config.get_pathname_to_database(jid_file)
show_media = Config.get_setting_value(self.settings, jid, 'media')
logger.debug('{}: jid: {} num: {}'.format(function_name, jid_bare, num))
db_file = config.get_pathname_to_database(jid_bare)
show_media = Config.get_setting_value(self.settings, jid_bare, 'media')
if not num:
num = Config.get_setting_value(self.settings, jid, 'quantum')
num = Config.get_setting_value(self.settings, jid_bare, 'quantum')
else:
num = int(num)
results = sqlite.get_unread_entries(db_file, num)
news_digest = ''
media = None
chat_type = await get_chat_type(self, jid)
chat_type = await get_chat_type(self, jid_bare)
for result in results:
ix = result[0]
title_e = result[1]
@ -526,7 +524,7 @@ async def xmpp_chat_send_unread_items(self, jid, num=None):
if enclosure: enclosure = enclosure[0]
title_f = sqlite.get_feed_title(db_file, feed_id)
title_f = title_f[0]
news_digest += await list_unread_entries(self, result, title_f, jid)
news_digest += await list_unread_entries(self, result, title_f, jid_bare)
# print(db_file)
# print(result[0])
# breakpoint()
@ -546,14 +544,14 @@ async def xmpp_chat_send_unread_items(self, jid, num=None):
if media and news_digest:
# Send textual message
XmppMessage.send(self, jid, news_digest, chat_type)
XmppMessage.send(self, jid_bare, news_digest, chat_type)
news_digest = ''
# Send media
XmppMessage.send_oob(self, jid, media, chat_type)
XmppMessage.send_oob(self, jid_bare, media, chat_type)
media = None
if news_digest:
XmppMessage.send(self, jid, news_digest, chat_type)
XmppMessage.send(self, jid_bare, news_digest, chat_type)
# TODO Add while loop to assure delivery.
# print(await current_time(), ">>> ACT send_message",jid)
# NOTE Do we need "if statement"? See NOTE at is_muc.

View file

@ -2989,7 +2989,7 @@ async def search_entries(db_file, query):
LIMIT 50
"""
)
par = (f'%{query}%', f'%{query}%')
par = [f'%{query}%']
result = cur.execute(sql, par).fetchall()
return result

View file

@ -165,7 +165,7 @@ async def start_tasks_xmpp_pubsub(self, jid_bare, tasks=None):
async def task_publish(self, jid_bare):
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
if jid_bare not in self.settings:
Config.add_settings_jid(self.settings, jid_bare, db_file)
while True:
@ -232,7 +232,7 @@ async def task_status_message(self, jid):
async def task_message(self, jid_bare):
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
if jid_bare not in self.settings:
Config.add_settings_jid(self.settings, jid_bare, db_file)
update_interval = Config.get_setting_value(self.settings, jid_bare, 'interval')
@ -291,7 +291,7 @@ def refresh_task(self, jid_bare, callback, key, val=None):
"""
logging.info('Refreshing task {} for JID {}'.format(callback, jid_bare))
if not val:
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
if jid_bare not in self.settings:
Config.add_settings_jid(self.settings, jid_bare, db_file)
val = Config.get_setting_value(self.settings, jid_bare, key)
@ -342,7 +342,7 @@ async def check_updates(self, jid_bare):
# print('Scanning for updates for JID {}'.format(jid_bare))
logging.info('Scanning for updates for JID {}'.format(jid_bare))
while True:
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
urls = sqlite.get_active_feeds_url(db_file)
for url in urls:
url = url[0]

View file

@ -1,2 +1,2 @@
__version__ = '0.1.71'
__version_info__ = (0, 1, 71)
__version__ = '0.1.72'
__version_info__ = (0, 1, 72)

View file

@ -79,7 +79,6 @@ class Chat:
"""
if message['type'] in ('chat', 'groupchat', 'normal'):
jid_bare = message['from'].bare
jid_file = jid_bare
message_text = ' '.join(message['body'].split())
command_time_start = time.time()
@ -114,7 +113,7 @@ class Chat:
# self.pending_tasks[jid_bare][self.pending_tasks_counter] = status_message
XmppPresence.send(self, jid_bare, status_message,
status_type=status_type)
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
result = await fetch.http(url)
count = await action.import_opml(db_file, result)
if count:
@ -324,7 +323,7 @@ class Chat:
if url.startswith('http'):
if not title:
title = uri.get_hostname(url)
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
counter = 0
hostname = uri.get_hostname(url)
hostname = hostname.replace('.','-')
@ -407,7 +406,7 @@ class Chat:
key = message_text[:5].lower()
val = message_text[7:]
if val:
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
keywords = sqlite.get_filter_value(db_file, key)
if keywords: keywords = str(keywords[0])
val = await config.add_to_list(val, keywords)
@ -428,7 +427,7 @@ class Chat:
key = message_text[:5].lower()
val = message_text[7:]
if val:
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
keywords = sqlite.get_filter_value(db_file, key)
if keywords: keywords = str(keywords[0])
val = await config.remove_from_list(val, keywords)
@ -456,7 +455,7 @@ class Chat:
else:
val_old = Config.get_setting_value(
self.settings, jid_bare, key)
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
await Config.set_setting_value(
self.settings, jid_bare, db_file, key, val_new)
response = ('Maximum archived items has '
@ -494,20 +493,20 @@ class Chat:
case _ if message_lowercase.startswith('default '):
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_bare)
await sqlite.delete_setting(db_file, key)
response = ('Setting {} has been restored to default value.'
.format(key))
XmppMessage.send_reply(self, message, response)
case 'defaults':
del self.settings[jid_bare]
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
await sqlite.delete_settings(db_file)
response = 'Default settings have been restored.'
XmppMessage.send_reply(self, message, response)
case _ if message_lowercase.startswith('clear '):
key = message_text[6:]
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
await sqlite.delete_filter(db_file, key)
response = 'Filter {} has been purged.'.format(key)
XmppMessage.send_reply(self, message, response)
@ -523,7 +522,7 @@ class Chat:
key = message_text[:4].lower()
val = message_text[6:]
if val:
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
keywords = sqlite.get_filter_value(db_file, key)
if keywords: keywords = str(keywords[0])
val = await config.add_to_list(val, keywords)
@ -544,7 +543,7 @@ class Chat:
key = message_text[:4].lower()
val = message_text[6:]
if val:
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
keywords = sqlite.get_filter_value(db_file, key)
if keywords: keywords = str(keywords[0])
val = await config.remove_from_list(val, keywords)
@ -575,7 +574,7 @@ class Chat:
# self.pending_tasks[jid_bare][self.pending_tasks_counter] = status_message
XmppPresence.send(self, jid_bare, status_message,
status_type=status_type)
filename = action.export_feeds(self, jid_bare, jid_file, ext)
filename = action.export_feeds(self, jid_bare, ext)
url = await XmppUpload.start(self, jid_bare, filename)
# response = (
# 'Feeds exported successfully to {}.\n{}'
@ -609,7 +608,7 @@ class Chat:
# self.pending_tasks[jid_bare][self.pending_tasks_counter] = status_message
XmppPresence.send(self, jid_bare, status_message,
status_type=status_type)
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
result = await fetch.http(url)
count = await action.import_opml(db_file, result)
if count:
@ -778,7 +777,7 @@ class Chat:
if url.startswith('feed:/') or url.startswith('rss:/'):
url = uri.feed_to_http(url)
url = (await uri.replace_hostname(url, 'feed')) or url
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
counter = 0
hostname = uri.get_hostname(url)
hostname = hostname.replace('.','-')
@ -835,13 +834,13 @@ class Chat:
query = message_text[6:]
if query:
if len(query) > 3:
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
result = sqlite.search_feeds(db_file, query)
response = action.list_feeds_by_query(query, result)
else:
response = 'Enter at least 4 characters to search'
else:
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
result = sqlite.get_feeds(db_file)
response = action.list_feeds(result)
XmppMessage.send_reply(self, message, response)
@ -859,7 +858,7 @@ class Chat:
try:
val_new = int(val)
val_old = Config.get_setting_value(self.settings, jid_bare, key)
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
await Config.set_setting_value(
self.settings, jid_bare, db_file, key, val_new)
# NOTE Perhaps this should be replaced by functions
@ -901,7 +900,7 @@ class Chat:
val_new = int(val)
val_old = Config.get_setting_value(
self.settings, jid_bare, key)
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
await Config.set_setting_value(
self.settings, jid_bare, db_file, key, val_new)
if val_new == 0: # if not val:
@ -945,7 +944,7 @@ class Chat:
# response = 'Missing value.'
XmppMessage.send_reply(self, message, response)
case 'media off':
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
key = 'media'
val = 0
await Config.set_setting_value(
@ -953,7 +952,7 @@ class Chat:
response = 'Media is disabled.'
XmppMessage.send_reply(self, message, response)
case 'media on':
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
key = 'media'
val = 1
await Config.set_setting_value(self.settings, jid_bare,
@ -961,7 +960,7 @@ class Chat:
response = 'Media is enabled.'
XmppMessage.send_reply(self, message, response)
case 'new':
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
key = 'old'
val = 0
await Config.set_setting_value(self.settings, jid_bare,
@ -1022,7 +1021,7 @@ class Chat:
key_list = ['status']
await task.start_tasks_xmpp_chat(self, jid_bare, key_list)
case 'old':
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
key = 'old'
val = 1
await Config.set_setting_value(self.settings, jid_bare,
@ -1053,7 +1052,7 @@ class Chat:
# response = (
# 'Every update will contain {} news items.'
# ).format(response)
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
await Config.set_setting_value(self.settings, jid_bare,
db_file, key, val_new)
response = ('Next update will contain {} news items '
@ -1183,7 +1182,7 @@ class Chat:
if num < 1 or num > 50:
response = 'Value must be ranged from 1 to 50.'
else:
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
result = sqlite.get_last_entries(db_file, num)
response = action.list_last_entries(result, num)
except:
@ -1201,7 +1200,7 @@ class Chat:
if ix_url:
for i in ix_url:
if i:
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
try:
ix = int(i)
url = sqlite.get_feed_url(db_file, ix)
@ -1256,9 +1255,9 @@ class Chat:
# self.pending_tasks[jid_bare][self.pending_tasks_counter] = status_message
XmppPresence.send(self, jid_bare, status_message,
status_type=status_type)
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
if ix_url:
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
try:
ix = int(ix_url)
url = sqlite.get_feed_url(db_file, ix)
@ -1303,7 +1302,7 @@ class Chat:
query = message_text[7:]
if query:
if len(query) > 1:
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
results = await sqlite.search_entries(db_file, query)
response = action.list_search_results(query, results)
else:
@ -1316,7 +1315,7 @@ class Chat:
case 'start':
key = 'enabled'
val = 1
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
await Config.set_setting_value(self.settings, jid_bare,
db_file, key, val)
status_type = 'available'
@ -1329,12 +1328,12 @@ class Chat:
response = 'Updates are enabled.'
XmppMessage.send_reply(self, message, response)
case 'stats':
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
response = await action.list_statistics(db_file)
XmppMessage.send_reply(self, message, response)
case _ if message_lowercase.startswith('disable '):
feed_id = message_text[8:]
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
try:
await sqlite.set_enabled_status(db_file, feed_id, 0)
await sqlite.mark_feed_as_read(db_file, feed_id)
@ -1358,7 +1357,7 @@ class Chat:
if name:
try:
feed_id = int(feed_id)
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
name_old = sqlite.get_feed_title(db_file, feed_id)
if name_old:
name_old = name_old[0]
@ -1390,7 +1389,7 @@ class Chat:
XmppMessage.send_reply(self, message, response)
case _ if message_lowercase.startswith('enable '):
feed_id = message_text[7:]
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
try:
await sqlite.set_enabled_status(db_file, feed_id, 1)
name = sqlite.get_feed_title(db_file, feed_id)[0]
@ -1406,7 +1405,7 @@ class Chat:
case 'stop':
key = 'enabled'
val = 0
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
await Config.set_setting_value(
self.settings, jid_bare, db_file, key, val)
key_list = ['interval', 'status']
@ -1461,16 +1460,15 @@ class Chat:
if not os.path.isdir(data_dir + '/logs/'):
os.mkdir(data_dir + '/logs/')
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_bare),
jid_bare, message_text)
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_bare),
jid_bare, response)
print(
'Message : {}\n'
'JID : {}\n'
'File : {}\n'
'{}\n'
.format(message_text, jid_bare, jid_file, response)
.format(message_text, jid_bare, response)
)

View file

@ -108,7 +108,7 @@ loop = asyncio.get_event_loop()
logger = Logger(__name__)
class Slixfeed(slixmpp.ClientXMPP):
class XmppClient(slixmpp.ClientXMPP):
"""
Slixfeed:
News bot that sends updates from RSS feeds.
@ -250,10 +250,7 @@ class Slixfeed(slixmpp.ClientXMPP):
self.on_session_end)
# Connect to the XMPP server and start processing XMPP stanzas.
if hostname and port:
self.connect((hostname, port))
else:
self.connect()
self.connect((hostname, port)) if hostname and port else self.connect()
self.process()
@ -414,8 +411,7 @@ class Slixfeed(slixmpp.ClientXMPP):
message_log = '{}: jid_full: {}'
logger.debug(message_log.format(function_name, jid_full))
jid_bare = message['from'].bare
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
if jid_bare not in self.settings:
Config.add_settings_jid(self.settings, jid_bare, db_file)
if jid_bare == self.boundjid.bare:
@ -926,7 +922,7 @@ class Slixfeed(slixmpp.ClientXMPP):
ftype='list-single',
label='Jabber ID',
value=jid_bare,
var='jid_file')
var='jid_bare')
jids = []
contacts = await XmppRoster.get_contacts(self)
for contact in contacts:
@ -1030,7 +1026,7 @@ class Slixfeed(slixmpp.ClientXMPP):
session['prev'] = None
session['payload'] = None
return session
jid_file = values['jid_file']
jid_bare = values['jid_bare']
node = values['node']
# xep = values['xep']
if not node:
@ -1046,11 +1042,11 @@ class Slixfeed(slixmpp.ClientXMPP):
form.add_field(var='jid',
ftype='hidden',
value=jid)
form.add_field(var='jid_file',
form.add_field(var='jid_bare',
ftype='hidden',
value=jid_file)
value=jid_bare)
num = 100
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
results = sqlite.get_entries(db_file, num)
subtitle = 'Recent {} updates'.format(num)
if results:
@ -1081,9 +1077,9 @@ class Slixfeed(slixmpp.ClientXMPP):
async def _handle_publish_db_complete(self, payload, session):
values = payload['values']
jid_file = values['jid_file'][0]
print('jid_file')
print(jid_file)
jid_bare = values['jid_bare'][0]
print('jid_bare')
print(jid_bare)
print("values['node']")
print(values['node'])
node_id = values['node'][0]
@ -1105,7 +1101,7 @@ class Slixfeed(slixmpp.ClientXMPP):
# xep = None
for ix in ixs:
await action.xmpp_pubsub_send_selected_entry(self, jid, jid_file, node_id, ix)
await action.xmpp_pubsub_send_selected_entry(self, jid, jid_bare, node_id, ix)
text_info = 'Posted {} entries.'.format(len(ixs))
session['allow_prev'] = False
session['has_next'] = False
@ -1317,8 +1313,7 @@ class Slixfeed(slixmpp.ClientXMPP):
logger.debug('{}: jid_full: {}'
.format(function_name, jid_full))
jid_bare = session['from'].bare
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
if jid_bare not in self.settings:
Config.add_settings_jid(self.settings, jid_bare, db_file)
form = self['xep_0004'].make_form('form', 'Profile')
@ -1423,8 +1418,7 @@ class Slixfeed(slixmpp.ClientXMPP):
chat_type = await get_chat_type(self, jid_bare)
if is_access(self, jid_bare, jid_full, chat_type):
jid = session['from'].bare
jid_file = jid
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
form = self['xep_0004'].make_form('form', 'Filters')
form['instructions'] = ('Filters allow you to skip news items '
'that you may not be interested at. Use '
@ -1499,8 +1493,7 @@ class Slixfeed(slixmpp.ClientXMPP):
jid_bare = session['from'].bare
# form = self['xep_0004'].make_form('result', 'Done')
# form['instructions'] = ('✅️ Filters have been updated')
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
# In this case (as is typical), the payload is a form
values = payload['values']
for key in values:
@ -1648,14 +1641,11 @@ class Slixfeed(slixmpp.ClientXMPP):
values = payload['values']
form = self['xep_0004'].make_form('form', 'Updates')
if is_operator(self, jid_bare) and 'jid' in values:
jid = values['jid']
jid_file = jid
jid_bare = values['jid']
form.add_field(var='jid',
ftype='hidden',
value=jid)
else:
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
value=jid_bare)
db_file = config.get_pathname_to_database(jid_bare)
num = 100
match values['action']:
case 'all':
@ -1710,13 +1700,11 @@ class Slixfeed(slixmpp.ClientXMPP):
form = self['xep_0004'].make_form('form', 'Article')
if is_operator(self, jid_bare) and 'jid' in values:
jid = values['jid']
jid_file = jid[0] if isinstance(jid, list) else jid
jid_bare = jid[0] if isinstance(jid, list) else jid
form.add_field(var='jid',
ftype='hidden',
value=jid)
else:
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
title = sqlite.get_entry_title(db_file, ix)
title = title[0] if title else 'Untitled'
form['instructions'] = title
@ -1786,13 +1774,11 @@ class Slixfeed(slixmpp.ClientXMPP):
jid_bare = session['from'].bare
if is_operator(self, jid_bare) and 'jid' in values:
jid = values['jid']
jid_file = jid[0] if isinstance(jid, list) else jid
jid_bare = jid[0] if isinstance(jid, list) else jid
form.add_field(var='jid',
ftype='hidden',
value=jid)
else:
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
if identifier and sqlite.check_identifier_exist(db_file, identifier):
form['title'] = 'Conflict'
form['instructions'] = ('Name "{}" already exists. Choose a '
@ -1990,12 +1976,9 @@ class Slixfeed(slixmpp.ClientXMPP):
jid_bare = session['from'].bare
values = payload['values']
if is_operator(self, jid_bare) and 'jid' in values:
jid = values['jid'][0]
jid_file = jid
jid_bare = values['jid'][0]
del values['jid']
else:
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
for key in values:
value = 1 if values[key] else 0
await sqlite.set_enabled_status(db_file, key, value)
@ -2018,12 +2001,9 @@ class Slixfeed(slixmpp.ClientXMPP):
jid_bare = session['from'].bare
values = payload['values']
if is_operator(self, jid_bare) and 'jid' in values:
jid = values['jid'][0]
jid_file = jid
jid_bare = values['jid'][0]
del values['jid']
else:
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
subscriptions =''
ixs = values['subscriptions']
for ix in ixs:
@ -2252,14 +2232,11 @@ class Slixfeed(slixmpp.ClientXMPP):
jid_bare = session['from'].bare
form = self['xep_0004'].make_form('form', 'Subscriptions')
if is_operator(self, jid_bare) and 'jid' in values:
jid = values['jid']
jid_file = jid
jid_bare = values['jid']
form.add_field(ftype='hidden',
value=jid,
value=jid_bare,
var='jid')
else:
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
match values['action']:
case 'browse':
form['instructions'] = 'Editing subscriptions'
@ -2349,14 +2326,11 @@ class Slixfeed(slixmpp.ClientXMPP):
jid_bare = session['from'].bare
values = payload['values']
if is_operator(self, jid_bare) and 'jid' in values:
jid = values['jid'][0]
jid_file = jid
jid_bare = values['jid'][0]
form.add_field(ftype='hidden',
value=jid,
value=jid_bare,
var='jid')
else:
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
tag_id = values['tag']
tag_name = sqlite.get_tag_name(db_file, tag_id)[0]
form['instructions'] = 'Subscriptions tagged with "{}"'.format(tag_name)
@ -2390,14 +2364,11 @@ class Slixfeed(slixmpp.ClientXMPP):
jid_bare = session['from'].bare
values = payload['values']
if is_operator(self, jid_bare) and 'jid' in values:
jid = values['jid'][0] if values['jid'] else jid_bare
jid_file = jid
jid_bare = values['jid'][0] if values['jid'] else jid_bare
form.add_field(ftype='hidden',
value=jid,
value=jid_bare,
var='jid')
else:
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
if 'subscription' in values: urls = values['subscription']
elif 'subscriptions' in values: urls = values['subscriptions']
url_count = len(urls)
@ -2489,11 +2460,8 @@ class Slixfeed(slixmpp.ClientXMPP):
jid_bare = session['from'].bare
values = payload['values']
if is_operator(self, jid_bare) and 'jid' in values:
jid = values['jid'][0]
jid_file = jid
else:
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
jid_bare = values['jid'][0]
db_file = config.get_pathname_to_database(jid_bare)
# url = values['url']
# feed_id = sqlite.get_feed_id(db_file, url)
# feed_id = feed_id[0]
@ -2894,10 +2862,8 @@ class Slixfeed(slixmpp.ClientXMPP):
jid_bare = session['from'].bare
if is_operator(self, jid_bare) and 'jid' in values:
jid = values['jid']
jid_file = jid[0] if isinstance(jid, list) else jid
else:
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
jid_bare = jid[0] if isinstance(jid, list) else jid
db_file = config.get_pathname_to_database(jid_bare)
result = await fetch.http(url)
count = await action.import_opml(db_file, result)
try:
@ -2937,14 +2903,12 @@ class Slixfeed(slixmpp.ClientXMPP):
jid_bare = session['from'].bare
if is_operator(self, jid_bare) and 'jid' in values:
jid = values['jid']
jid_file = jid[0] if isinstance(jid, list) else jid
else:
jid_file = jid_bare
jid_bare = jid[0] if isinstance(jid, list) else jid
# form = self['xep_0004'].make_form('result', 'Done')
# form['instructions'] = ('✅️ Feeds have been exported')
exts = values['filetype']
for ext in exts:
filename = action.export_feeds(self, jid_file, jid_file, ext)
filename = action.export_feeds(self, jid_bare, ext)
url = await XmppUpload.start(self, jid_bare, filename)
chat_type = await get_chat_type(self, jid_bare)
XmppMessage.send_oob(self, jid_bare, url, chat_type)
@ -3411,8 +3375,7 @@ class Slixfeed(slixmpp.ClientXMPP):
if key:
jid_bare = key
value = values[key]
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
if jid_bare not in self.settings:
Config.add_settings_jid(self.settings, jid_bare, db_file)
await Config.set_setting_value(self.settings, jid_bare,
@ -3674,8 +3637,7 @@ class Slixfeed(slixmpp.ClientXMPP):
jid_bare = session['from'].bare
chat_type = await get_chat_type(self, jid_bare)
if is_access(self, jid_bare, jid_full, chat_type):
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
if jid_bare not in self.settings:
Config.add_settings_jid(self.settings, jid_bare, db_file)
form = self['xep_0004'].make_form('form', 'Settings')
@ -3792,8 +3754,7 @@ class Slixfeed(slixmpp.ClientXMPP):
logger.debug('{}: jid_full: {}'
.format(function_name, jid_full))
jid_bare = session['from'].bare
jid_file = jid_bare
db_file = config.get_pathname_to_database(jid_file)
db_file = config.get_pathname_to_database(jid_bare)
if jid_bare not in self.settings:
Config.add_settings_jid(self.settings, jid_bare, db_file)
# In this case (as is typical), the payload is a form

File diff suppressed because it is too large Load diff