forked from sch/Slixfeed
Fix automatic update; Fix command search.
This commit is contained in:
parent
5ee75572ab
commit
5a2a2f9e3f
8 changed files with 920 additions and 548 deletions
|
@ -178,22 +178,28 @@ def main():
|
||||||
|
|
||||||
# Try configuration file
|
# Try configuration file
|
||||||
if 'client' in account_xmpp:
|
if 'client' in account_xmpp:
|
||||||
from slixfeed.xmpp.client import Slixfeed
|
from slixfeed.xmpp.client import XmppClient
|
||||||
jid = account_xmpp['client']['jid']
|
jid = account_xmpp['client']['jid']
|
||||||
password = account_xmpp['client']['password']
|
password = account_xmpp['client']['password']
|
||||||
alias = account_xmpp['client']['alias'] if 'alias' in account_xmpp['client'] else None
|
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
|
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
|
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:
|
if 'component' in account_xmpp:
|
||||||
from slixfeed.xmpp.component import SlixfeedComponent
|
from slixfeed.xmpp.component import XmppComponent
|
||||||
jid = account_xmpp['component']['jid']
|
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
|
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
|
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
|
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)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
|
@ -71,9 +71,9 @@ except:
|
||||||
logger = Logger(__name__)
|
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
|
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()
|
cache_dir = config.get_default_cache_directory()
|
||||||
if not os.path.isdir(cache_dir):
|
if not os.path.isdir(cache_dir):
|
||||||
os.mkdir(cache_dir)
|
os.mkdir(cache_dir)
|
||||||
|
@ -81,15 +81,15 @@ def export_feeds(self, jid, jid_file, ext):
|
||||||
os.mkdir(cache_dir + '/' + ext)
|
os.mkdir(cache_dir + '/' + ext)
|
||||||
filename = os.path.join(
|
filename = os.path.join(
|
||||||
cache_dir, ext, 'slixfeed_' + dt.timestamp() + '.' + ext)
|
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)
|
results = sqlite.get_feeds(db_file)
|
||||||
match ext:
|
match ext:
|
||||||
# case 'html':
|
# case 'html':
|
||||||
# response = 'Not yet implemented.'
|
# response = 'Not yet implemented.'
|
||||||
case 'md':
|
case 'md':
|
||||||
export_to_markdown(jid, filename, results)
|
export_to_markdown(jid_bare, filename, results)
|
||||||
case 'opml':
|
case 'opml':
|
||||||
export_to_opml(jid, filename, results)
|
export_to_opml(jid_bare, filename, results)
|
||||||
# case 'xbel':
|
# case 'xbel':
|
||||||
# response = 'Not yet implemented.'
|
# response = 'Not yet implemented.'
|
||||||
return filename
|
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.
|
Send status message.
|
||||||
|
|
||||||
|
@ -154,13 +154,12 @@ async def xmpp_send_status_message(self, jid):
|
||||||
Jabber ID.
|
Jabber ID.
|
||||||
"""
|
"""
|
||||||
function_name = sys._getframe().f_code.co_name
|
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'
|
status_text = '📜️ Slixfeed RSS News Bot'
|
||||||
jid_file = jid.replace('/', '_')
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
enabled = Config.get_setting_value(self.settings, jid_bare, 'enabled')
|
||||||
enabled = Config.get_setting_value(self.settings, jid, 'enabled')
|
|
||||||
if enabled:
|
if enabled:
|
||||||
jid_task = self.pending_tasks[jid]
|
jid_task = self.pending_tasks[jid_bare]
|
||||||
if len(jid_task):
|
if len(jid_task):
|
||||||
status_mode = 'dnd'
|
status_mode = 'dnd'
|
||||||
status_text = jid_task[list(jid_task.keys())[0]]
|
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'
|
status_text = '📪️ Send "Start" to receive updates'
|
||||||
# breakpoint()
|
# breakpoint()
|
||||||
# print(await current_time(), status_text, "for", jid)
|
# 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 asyncio.sleep(60 * 20)
|
||||||
# await refresh_task(self, jid, send_status, 'status', '90')
|
# await refresh_task(self, jid, send_status, 'status', '90')
|
||||||
# loop.call_at(
|
# 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
|
function_name = sys._getframe().f_code.co_name
|
||||||
logger.debug('{}: jid_bare: {}'.format(function_name, jid_bare))
|
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 = {}
|
report = {}
|
||||||
subscriptions = sqlite.get_active_feeds_url(db_file)
|
subscriptions = sqlite.get_active_feeds_url(db_file)
|
||||||
for url in subscriptions:
|
for url in subscriptions:
|
||||||
|
@ -491,7 +490,7 @@ def create_rfc4287_entry(feed_entry):
|
||||||
return node_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.
|
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.
|
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, num))
|
logger.debug('{}: jid: {} num: {}'.format(function_name, jid_bare, num))
|
||||||
jid_file = jid.replace('/', '_')
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
show_media = Config.get_setting_value(self.settings, jid_bare, 'media')
|
||||||
show_media = Config.get_setting_value(self.settings, jid, 'media')
|
|
||||||
if not num:
|
if not num:
|
||||||
num = Config.get_setting_value(self.settings, jid, 'quantum')
|
num = Config.get_setting_value(self.settings, jid_bare, 'quantum')
|
||||||
else:
|
else:
|
||||||
num = int(num)
|
num = int(num)
|
||||||
results = sqlite.get_unread_entries(db_file, num)
|
results = sqlite.get_unread_entries(db_file, num)
|
||||||
news_digest = ''
|
news_digest = ''
|
||||||
media = None
|
media = None
|
||||||
chat_type = await get_chat_type(self, jid)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
for result in results:
|
for result in results:
|
||||||
ix = result[0]
|
ix = result[0]
|
||||||
title_e = result[1]
|
title_e = result[1]
|
||||||
|
@ -526,7 +524,7 @@ async def xmpp_chat_send_unread_items(self, jid, num=None):
|
||||||
if enclosure: enclosure = enclosure[0]
|
if enclosure: enclosure = enclosure[0]
|
||||||
title_f = sqlite.get_feed_title(db_file, feed_id)
|
title_f = sqlite.get_feed_title(db_file, feed_id)
|
||||||
title_f = title_f[0]
|
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(db_file)
|
||||||
# print(result[0])
|
# print(result[0])
|
||||||
# breakpoint()
|
# breakpoint()
|
||||||
|
@ -546,14 +544,14 @@ async def xmpp_chat_send_unread_items(self, jid, num=None):
|
||||||
|
|
||||||
if media and news_digest:
|
if media and news_digest:
|
||||||
# Send textual message
|
# Send textual message
|
||||||
XmppMessage.send(self, jid, news_digest, chat_type)
|
XmppMessage.send(self, jid_bare, news_digest, chat_type)
|
||||||
news_digest = ''
|
news_digest = ''
|
||||||
# Send media
|
# Send media
|
||||||
XmppMessage.send_oob(self, jid, media, chat_type)
|
XmppMessage.send_oob(self, jid_bare, media, chat_type)
|
||||||
media = None
|
media = None
|
||||||
|
|
||||||
if news_digest:
|
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.
|
# TODO Add while loop to assure delivery.
|
||||||
# print(await current_time(), ">>> ACT send_message",jid)
|
# print(await current_time(), ">>> ACT send_message",jid)
|
||||||
# NOTE Do we need "if statement"? See NOTE at is_muc.
|
# NOTE Do we need "if statement"? See NOTE at is_muc.
|
||||||
|
|
|
@ -2989,7 +2989,7 @@ async def search_entries(db_file, query):
|
||||||
LIMIT 50
|
LIMIT 50
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
par = (f'%{query}%', f'%{query}%')
|
par = [f'%{query}%']
|
||||||
result = cur.execute(sql, par).fetchall()
|
result = cur.execute(sql, par).fetchall()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ async def start_tasks_xmpp_pubsub(self, jid_bare, tasks=None):
|
||||||
|
|
||||||
|
|
||||||
async def task_publish(self, jid_bare):
|
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:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
||||||
while True:
|
while True:
|
||||||
|
@ -232,7 +232,7 @@ async def task_status_message(self, jid):
|
||||||
|
|
||||||
|
|
||||||
async def task_message(self, jid_bare):
|
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:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
||||||
update_interval = Config.get_setting_value(self.settings, jid_bare, 'interval')
|
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))
|
logging.info('Refreshing task {} for JID {}'.format(callback, jid_bare))
|
||||||
if not val:
|
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:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
||||||
val = Config.get_setting_value(self.settings, jid_bare, key)
|
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))
|
# print('Scanning for updates for JID {}'.format(jid_bare))
|
||||||
logging.info('Scanning for updates for JID {}'.format(jid_bare))
|
logging.info('Scanning for updates for JID {}'.format(jid_bare))
|
||||||
while True:
|
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)
|
urls = sqlite.get_active_feeds_url(db_file)
|
||||||
for url in urls:
|
for url in urls:
|
||||||
url = url[0]
|
url = url[0]
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
__version__ = '0.1.71'
|
__version__ = '0.1.72'
|
||||||
__version_info__ = (0, 1, 71)
|
__version_info__ = (0, 1, 72)
|
||||||
|
|
|
@ -79,7 +79,6 @@ class Chat:
|
||||||
"""
|
"""
|
||||||
if message['type'] in ('chat', 'groupchat', 'normal'):
|
if message['type'] in ('chat', 'groupchat', 'normal'):
|
||||||
jid_bare = message['from'].bare
|
jid_bare = message['from'].bare
|
||||||
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()
|
||||||
|
|
||||||
|
@ -114,7 +113,7 @@ class Chat:
|
||||||
# self.pending_tasks[jid_bare][self.pending_tasks_counter] = status_message
|
# self.pending_tasks[jid_bare][self.pending_tasks_counter] = status_message
|
||||||
XmppPresence.send(self, jid_bare, 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_bare)
|
||||||
result = await fetch.http(url)
|
result = await fetch.http(url)
|
||||||
count = await action.import_opml(db_file, result)
|
count = await action.import_opml(db_file, result)
|
||||||
if count:
|
if count:
|
||||||
|
@ -324,7 +323,7 @@ class Chat:
|
||||||
if url.startswith('http'):
|
if url.startswith('http'):
|
||||||
if not title:
|
if not title:
|
||||||
title = uri.get_hostname(url)
|
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
|
counter = 0
|
||||||
hostname = uri.get_hostname(url)
|
hostname = uri.get_hostname(url)
|
||||||
hostname = hostname.replace('.','-')
|
hostname = hostname.replace('.','-')
|
||||||
|
@ -407,7 +406,7 @@ class Chat:
|
||||||
key = message_text[:5].lower()
|
key = message_text[:5].lower()
|
||||||
val = message_text[7:]
|
val = message_text[7:]
|
||||||
if val:
|
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)
|
keywords = sqlite.get_filter_value(db_file, key)
|
||||||
if keywords: keywords = str(keywords[0])
|
if keywords: keywords = str(keywords[0])
|
||||||
val = await config.add_to_list(val, keywords)
|
val = await config.add_to_list(val, keywords)
|
||||||
|
@ -428,7 +427,7 @@ class Chat:
|
||||||
key = message_text[:5].lower()
|
key = message_text[:5].lower()
|
||||||
val = message_text[7:]
|
val = message_text[7:]
|
||||||
if val:
|
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)
|
keywords = sqlite.get_filter_value(db_file, key)
|
||||||
if keywords: keywords = str(keywords[0])
|
if keywords: keywords = str(keywords[0])
|
||||||
val = await config.remove_from_list(val, keywords)
|
val = await config.remove_from_list(val, keywords)
|
||||||
|
@ -456,7 +455,7 @@ class Chat:
|
||||||
else:
|
else:
|
||||||
val_old = Config.get_setting_value(
|
val_old = Config.get_setting_value(
|
||||||
self.settings, jid_bare, key)
|
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(
|
await Config.set_setting_value(
|
||||||
self.settings, jid_bare, db_file, key, val_new)
|
self.settings, jid_bare, db_file, key, val_new)
|
||||||
response = ('Maximum archived items has '
|
response = ('Maximum archived items has '
|
||||||
|
@ -494,20 +493,20 @@ class Chat:
|
||||||
case _ if message_lowercase.startswith('default '):
|
case _ if message_lowercase.startswith('default '):
|
||||||
key = message_text[8:]
|
key = message_text[8:]
|
||||||
self.settings[jid_bare][key] = None
|
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)
|
await sqlite.delete_setting(db_file, key)
|
||||||
response = ('Setting {} has been restored to default value.'
|
response = ('Setting {} has been restored to default value.'
|
||||||
.format(key))
|
.format(key))
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
case 'defaults':
|
case 'defaults':
|
||||||
del self.settings[jid_bare]
|
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)
|
await sqlite.delete_settings(db_file)
|
||||||
response = 'Default settings have been restored.'
|
response = 'Default settings have been restored.'
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
case _ if message_lowercase.startswith('clear '):
|
case _ if message_lowercase.startswith('clear '):
|
||||||
key = message_text[6:]
|
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)
|
await sqlite.delete_filter(db_file, key)
|
||||||
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)
|
||||||
|
@ -523,7 +522,7 @@ class Chat:
|
||||||
key = message_text[:4].lower()
|
key = message_text[:4].lower()
|
||||||
val = message_text[6:]
|
val = message_text[6:]
|
||||||
if val:
|
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)
|
keywords = sqlite.get_filter_value(db_file, key)
|
||||||
if keywords: keywords = str(keywords[0])
|
if keywords: keywords = str(keywords[0])
|
||||||
val = await config.add_to_list(val, keywords)
|
val = await config.add_to_list(val, keywords)
|
||||||
|
@ -544,7 +543,7 @@ class Chat:
|
||||||
key = message_text[:4].lower()
|
key = message_text[:4].lower()
|
||||||
val = message_text[6:]
|
val = message_text[6:]
|
||||||
if val:
|
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)
|
keywords = sqlite.get_filter_value(db_file, key)
|
||||||
if keywords: keywords = str(keywords[0])
|
if keywords: keywords = str(keywords[0])
|
||||||
val = await config.remove_from_list(val, keywords)
|
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
|
# self.pending_tasks[jid_bare][self.pending_tasks_counter] = status_message
|
||||||
XmppPresence.send(self, jid_bare, status_message,
|
XmppPresence.send(self, jid_bare, status_message,
|
||||||
status_type=status_type)
|
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)
|
url = await XmppUpload.start(self, jid_bare, filename)
|
||||||
# response = (
|
# response = (
|
||||||
# 'Feeds exported successfully to {}.\n{}'
|
# 'Feeds exported successfully to {}.\n{}'
|
||||||
|
@ -609,7 +608,7 @@ class Chat:
|
||||||
# self.pending_tasks[jid_bare][self.pending_tasks_counter] = status_message
|
# self.pending_tasks[jid_bare][self.pending_tasks_counter] = status_message
|
||||||
XmppPresence.send(self, jid_bare, 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_bare)
|
||||||
result = await fetch.http(url)
|
result = await fetch.http(url)
|
||||||
count = await action.import_opml(db_file, result)
|
count = await action.import_opml(db_file, result)
|
||||||
if count:
|
if count:
|
||||||
|
@ -778,7 +777,7 @@ class Chat:
|
||||||
if url.startswith('feed:/') or url.startswith('rss:/'):
|
if url.startswith('feed:/') or url.startswith('rss:/'):
|
||||||
url = uri.feed_to_http(url)
|
url = uri.feed_to_http(url)
|
||||||
url = (await uri.replace_hostname(url, 'feed')) or 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
|
counter = 0
|
||||||
hostname = uri.get_hostname(url)
|
hostname = uri.get_hostname(url)
|
||||||
hostname = hostname.replace('.','-')
|
hostname = hostname.replace('.','-')
|
||||||
|
@ -835,13 +834,13 @@ class Chat:
|
||||||
query = message_text[6:]
|
query = message_text[6:]
|
||||||
if query:
|
if query:
|
||||||
if len(query) > 3:
|
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)
|
result = sqlite.search_feeds(db_file, query)
|
||||||
response = action.list_feeds_by_query(query, result)
|
response = action.list_feeds_by_query(query, result)
|
||||||
else:
|
else:
|
||||||
response = 'Enter at least 4 characters to search'
|
response = 'Enter at least 4 characters to search'
|
||||||
else:
|
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)
|
result = sqlite.get_feeds(db_file)
|
||||||
response = action.list_feeds(result)
|
response = action.list_feeds(result)
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
|
@ -859,7 +858,7 @@ class Chat:
|
||||||
try:
|
try:
|
||||||
val_new = int(val)
|
val_new = int(val)
|
||||||
val_old = Config.get_setting_value(self.settings, jid_bare, key)
|
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(
|
await Config.set_setting_value(
|
||||||
self.settings, jid_bare, db_file, key, val_new)
|
self.settings, jid_bare, db_file, key, val_new)
|
||||||
# NOTE Perhaps this should be replaced by functions
|
# NOTE Perhaps this should be replaced by functions
|
||||||
|
@ -901,7 +900,7 @@ class Chat:
|
||||||
val_new = int(val)
|
val_new = int(val)
|
||||||
val_old = Config.get_setting_value(
|
val_old = Config.get_setting_value(
|
||||||
self.settings, jid_bare, key)
|
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(
|
await Config.set_setting_value(
|
||||||
self.settings, jid_bare, db_file, key, val_new)
|
self.settings, jid_bare, db_file, key, val_new)
|
||||||
if val_new == 0: # if not val:
|
if val_new == 0: # if not val:
|
||||||
|
@ -945,7 +944,7 @@ class Chat:
|
||||||
# response = 'Missing value.'
|
# response = 'Missing value.'
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
case 'media off':
|
case 'media off':
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
key = 'media'
|
key = 'media'
|
||||||
val = 0
|
val = 0
|
||||||
await Config.set_setting_value(
|
await Config.set_setting_value(
|
||||||
|
@ -953,7 +952,7 @@ class Chat:
|
||||||
response = 'Media is disabled.'
|
response = 'Media is disabled.'
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
case 'media on':
|
case 'media on':
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
key = 'media'
|
key = 'media'
|
||||||
val = 1
|
val = 1
|
||||||
await Config.set_setting_value(self.settings, jid_bare,
|
await Config.set_setting_value(self.settings, jid_bare,
|
||||||
|
@ -961,7 +960,7 @@ class Chat:
|
||||||
response = 'Media is enabled.'
|
response = 'Media is enabled.'
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
case 'new':
|
case 'new':
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
key = 'old'
|
key = 'old'
|
||||||
val = 0
|
val = 0
|
||||||
await Config.set_setting_value(self.settings, jid_bare,
|
await Config.set_setting_value(self.settings, jid_bare,
|
||||||
|
@ -1022,7 +1021,7 @@ class Chat:
|
||||||
key_list = ['status']
|
key_list = ['status']
|
||||||
await task.start_tasks_xmpp_chat(self, jid_bare, key_list)
|
await task.start_tasks_xmpp_chat(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_bare)
|
||||||
key = 'old'
|
key = 'old'
|
||||||
val = 1
|
val = 1
|
||||||
await Config.set_setting_value(self.settings, jid_bare,
|
await Config.set_setting_value(self.settings, jid_bare,
|
||||||
|
@ -1053,7 +1052,7 @@ class Chat:
|
||||||
# response = (
|
# response = (
|
||||||
# 'Every update will contain {} news items.'
|
# 'Every update will contain {} news items.'
|
||||||
# ).format(response)
|
# ).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,
|
await Config.set_setting_value(self.settings, jid_bare,
|
||||||
db_file, key, val_new)
|
db_file, key, val_new)
|
||||||
response = ('Next update will contain {} news items '
|
response = ('Next update will contain {} news items '
|
||||||
|
@ -1183,7 +1182,7 @@ class Chat:
|
||||||
if num < 1 or num > 50:
|
if num < 1 or num > 50:
|
||||||
response = 'Value must be ranged from 1 to 50.'
|
response = 'Value must be ranged from 1 to 50.'
|
||||||
else:
|
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)
|
result = sqlite.get_last_entries(db_file, num)
|
||||||
response = action.list_last_entries(result, num)
|
response = action.list_last_entries(result, num)
|
||||||
except:
|
except:
|
||||||
|
@ -1201,7 +1200,7 @@ class Chat:
|
||||||
if ix_url:
|
if ix_url:
|
||||||
for i in ix_url:
|
for i in ix_url:
|
||||||
if i:
|
if i:
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
try:
|
try:
|
||||||
ix = int(i)
|
ix = int(i)
|
||||||
url = sqlite.get_feed_url(db_file, ix)
|
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
|
# self.pending_tasks[jid_bare][self.pending_tasks_counter] = status_message
|
||||||
XmppPresence.send(self, jid_bare, 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_bare)
|
||||||
if ix_url:
|
if ix_url:
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
try:
|
try:
|
||||||
ix = int(ix_url)
|
ix = int(ix_url)
|
||||||
url = sqlite.get_feed_url(db_file, ix)
|
url = sqlite.get_feed_url(db_file, ix)
|
||||||
|
@ -1303,7 +1302,7 @@ class Chat:
|
||||||
query = message_text[7:]
|
query = message_text[7:]
|
||||||
if query:
|
if query:
|
||||||
if len(query) > 1:
|
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)
|
results = await sqlite.search_entries(db_file, query)
|
||||||
response = action.list_search_results(query, results)
|
response = action.list_search_results(query, results)
|
||||||
else:
|
else:
|
||||||
|
@ -1316,7 +1315,7 @@ class Chat:
|
||||||
case 'start':
|
case 'start':
|
||||||
key = 'enabled'
|
key = 'enabled'
|
||||||
val = 1
|
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,
|
await Config.set_setting_value(self.settings, jid_bare,
|
||||||
db_file, key, val)
|
db_file, key, val)
|
||||||
status_type = 'available'
|
status_type = 'available'
|
||||||
|
@ -1329,12 +1328,12 @@ class Chat:
|
||||||
response = 'Updates are enabled.'
|
response = 'Updates are enabled.'
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
case 'stats':
|
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)
|
response = await action.list_statistics(db_file)
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
case _ if message_lowercase.startswith('disable '):
|
case _ if message_lowercase.startswith('disable '):
|
||||||
feed_id = message_text[8:]
|
feed_id = message_text[8:]
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
try:
|
try:
|
||||||
await sqlite.set_enabled_status(db_file, feed_id, 0)
|
await sqlite.set_enabled_status(db_file, feed_id, 0)
|
||||||
await sqlite.mark_feed_as_read(db_file, feed_id)
|
await sqlite.mark_feed_as_read(db_file, feed_id)
|
||||||
|
@ -1358,7 +1357,7 @@ class Chat:
|
||||||
if name:
|
if name:
|
||||||
try:
|
try:
|
||||||
feed_id = int(feed_id)
|
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)
|
name_old = sqlite.get_feed_title(db_file, feed_id)
|
||||||
if name_old:
|
if name_old:
|
||||||
name_old = name_old[0]
|
name_old = name_old[0]
|
||||||
|
@ -1390,7 +1389,7 @@ class Chat:
|
||||||
XmppMessage.send_reply(self, message, response)
|
XmppMessage.send_reply(self, message, response)
|
||||||
case _ if message_lowercase.startswith('enable '):
|
case _ if message_lowercase.startswith('enable '):
|
||||||
feed_id = message_text[7:]
|
feed_id = message_text[7:]
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
try:
|
try:
|
||||||
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]
|
||||||
|
@ -1406,7 +1405,7 @@ class Chat:
|
||||||
case 'stop':
|
case 'stop':
|
||||||
key = 'enabled'
|
key = 'enabled'
|
||||||
val = 0
|
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(
|
await Config.set_setting_value(
|
||||||
self.settings, jid_bare, db_file, key, val)
|
self.settings, jid_bare, db_file, key, val)
|
||||||
key_list = ['interval', 'status']
|
key_list = ['interval', 'status']
|
||||||
|
@ -1461,16 +1460,15 @@ class Chat:
|
||||||
if not os.path.isdir(data_dir + '/logs/'):
|
if not os.path.isdir(data_dir + '/logs/'):
|
||||||
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_bare),
|
||||||
jid_bare, 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_bare),
|
||||||
jid_bare, response)
|
jid_bare, response)
|
||||||
|
|
||||||
print(
|
print(
|
||||||
'Message : {}\n'
|
'Message : {}\n'
|
||||||
'JID : {}\n'
|
'JID : {}\n'
|
||||||
'File : {}\n'
|
|
||||||
'{}\n'
|
'{}\n'
|
||||||
.format(message_text, jid_bare, jid_file, response)
|
.format(message_text, jid_bare, response)
|
||||||
)
|
)
|
||||||
|
|
|
@ -108,7 +108,7 @@ loop = asyncio.get_event_loop()
|
||||||
|
|
||||||
logger = Logger(__name__)
|
logger = Logger(__name__)
|
||||||
|
|
||||||
class Slixfeed(slixmpp.ClientXMPP):
|
class XmppClient(slixmpp.ClientXMPP):
|
||||||
"""
|
"""
|
||||||
Slixfeed:
|
Slixfeed:
|
||||||
News bot that sends updates from RSS feeds.
|
News bot that sends updates from RSS feeds.
|
||||||
|
@ -250,10 +250,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
self.on_session_end)
|
self.on_session_end)
|
||||||
|
|
||||||
# Connect to the XMPP server and start processing XMPP stanzas.
|
# Connect to the XMPP server and start processing XMPP stanzas.
|
||||||
if hostname and port:
|
self.connect((hostname, port)) if hostname and port else self.connect()
|
||||||
self.connect((hostname, port))
|
|
||||||
else:
|
|
||||||
self.connect()
|
|
||||||
self.process()
|
self.process()
|
||||||
|
|
||||||
|
|
||||||
|
@ -414,8 +411,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
message_log = '{}: jid_full: {}'
|
message_log = '{}: jid_full: {}'
|
||||||
logger.debug(message_log.format(function_name, jid_full))
|
logger.debug(message_log.format(function_name, jid_full))
|
||||||
jid_bare = message['from'].bare
|
jid_bare = message['from'].bare
|
||||||
jid_file = jid_bare
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
||||||
if jid_bare == self.boundjid.bare:
|
if jid_bare == self.boundjid.bare:
|
||||||
|
@ -926,7 +922,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
ftype='list-single',
|
ftype='list-single',
|
||||||
label='Jabber ID',
|
label='Jabber ID',
|
||||||
value=jid_bare,
|
value=jid_bare,
|
||||||
var='jid_file')
|
var='jid_bare')
|
||||||
jids = []
|
jids = []
|
||||||
contacts = await XmppRoster.get_contacts(self)
|
contacts = await XmppRoster.get_contacts(self)
|
||||||
for contact in contacts:
|
for contact in contacts:
|
||||||
|
@ -1030,7 +1026,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
session['prev'] = None
|
session['prev'] = None
|
||||||
session['payload'] = None
|
session['payload'] = None
|
||||||
return session
|
return session
|
||||||
jid_file = values['jid_file']
|
jid_bare = values['jid_bare']
|
||||||
node = values['node']
|
node = values['node']
|
||||||
# xep = values['xep']
|
# xep = values['xep']
|
||||||
if not node:
|
if not node:
|
||||||
|
@ -1046,11 +1042,11 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
form.add_field(var='jid',
|
form.add_field(var='jid',
|
||||||
ftype='hidden',
|
ftype='hidden',
|
||||||
value=jid)
|
value=jid)
|
||||||
form.add_field(var='jid_file',
|
form.add_field(var='jid_bare',
|
||||||
ftype='hidden',
|
ftype='hidden',
|
||||||
value=jid_file)
|
value=jid_bare)
|
||||||
num = 100
|
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)
|
results = sqlite.get_entries(db_file, num)
|
||||||
subtitle = 'Recent {} updates'.format(num)
|
subtitle = 'Recent {} updates'.format(num)
|
||||||
if results:
|
if results:
|
||||||
|
@ -1081,9 +1077,9 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
|
|
||||||
async def _handle_publish_db_complete(self, payload, session):
|
async def _handle_publish_db_complete(self, payload, session):
|
||||||
values = payload['values']
|
values = payload['values']
|
||||||
jid_file = values['jid_file'][0]
|
jid_bare = values['jid_bare'][0]
|
||||||
print('jid_file')
|
print('jid_bare')
|
||||||
print(jid_file)
|
print(jid_bare)
|
||||||
print("values['node']")
|
print("values['node']")
|
||||||
print(values['node'])
|
print(values['node'])
|
||||||
node_id = values['node'][0]
|
node_id = values['node'][0]
|
||||||
|
@ -1105,7 +1101,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
# xep = None
|
# xep = None
|
||||||
|
|
||||||
for ix in ixs:
|
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))
|
text_info = 'Posted {} entries.'.format(len(ixs))
|
||||||
session['allow_prev'] = False
|
session['allow_prev'] = False
|
||||||
session['has_next'] = False
|
session['has_next'] = False
|
||||||
|
@ -1317,8 +1313,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
logger.debug('{}: jid_full: {}'
|
logger.debug('{}: jid_full: {}'
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
jid_file = jid_bare
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
||||||
form = self['xep_0004'].make_form('form', 'Profile')
|
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)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
if is_access(self, jid_bare, jid_full, chat_type):
|
if is_access(self, jid_bare, jid_full, chat_type):
|
||||||
jid = session['from'].bare
|
jid = session['from'].bare
|
||||||
jid_file = jid
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
form = self['xep_0004'].make_form('form', 'Filters')
|
form = self['xep_0004'].make_form('form', 'Filters')
|
||||||
form['instructions'] = ('Filters allow you to skip news items '
|
form['instructions'] = ('Filters allow you to skip news items '
|
||||||
'that you may not be interested at. Use '
|
'that you may not be interested at. Use '
|
||||||
|
@ -1499,8 +1493,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
# form = self['xep_0004'].make_form('result', 'Done')
|
# form = self['xep_0004'].make_form('result', 'Done')
|
||||||
# form['instructions'] = ('✅️ Filters have been updated')
|
# form['instructions'] = ('✅️ Filters have been updated')
|
||||||
jid_file = jid_bare
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
# In this case (as is typical), the payload is a form
|
# In this case (as is typical), the payload is a form
|
||||||
values = payload['values']
|
values = payload['values']
|
||||||
for key in values:
|
for key in values:
|
||||||
|
@ -1648,14 +1641,11 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
values = payload['values']
|
values = payload['values']
|
||||||
form = self['xep_0004'].make_form('form', 'Updates')
|
form = self['xep_0004'].make_form('form', 'Updates')
|
||||||
if is_operator(self, jid_bare) and 'jid' in values:
|
if is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid = values['jid']
|
jid_bare = values['jid']
|
||||||
jid_file = jid
|
|
||||||
form.add_field(var='jid',
|
form.add_field(var='jid',
|
||||||
ftype='hidden',
|
ftype='hidden',
|
||||||
value=jid)
|
value=jid_bare)
|
||||||
else:
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
jid_file = jid_bare
|
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
num = 100
|
num = 100
|
||||||
match values['action']:
|
match values['action']:
|
||||||
case 'all':
|
case 'all':
|
||||||
|
@ -1710,13 +1700,11 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
form = self['xep_0004'].make_form('form', 'Article')
|
form = self['xep_0004'].make_form('form', 'Article')
|
||||||
if is_operator(self, jid_bare) and 'jid' in values:
|
if is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid = values['jid']
|
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',
|
form.add_field(var='jid',
|
||||||
ftype='hidden',
|
ftype='hidden',
|
||||||
value=jid)
|
value=jid)
|
||||||
else:
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
jid_file = jid_bare
|
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
title = sqlite.get_entry_title(db_file, ix)
|
title = sqlite.get_entry_title(db_file, ix)
|
||||||
title = title[0] if title else 'Untitled'
|
title = title[0] if title else 'Untitled'
|
||||||
form['instructions'] = title
|
form['instructions'] = title
|
||||||
|
@ -1786,13 +1774,11 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
if is_operator(self, jid_bare) and 'jid' in values:
|
if is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid = values['jid']
|
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',
|
form.add_field(var='jid',
|
||||||
ftype='hidden',
|
ftype='hidden',
|
||||||
value=jid)
|
value=jid)
|
||||||
else:
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
jid_file = jid_bare
|
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
if identifier and sqlite.check_identifier_exist(db_file, identifier):
|
if identifier and sqlite.check_identifier_exist(db_file, identifier):
|
||||||
form['title'] = 'Conflict'
|
form['title'] = 'Conflict'
|
||||||
form['instructions'] = ('Name "{}" already exists. Choose a '
|
form['instructions'] = ('Name "{}" already exists. Choose a '
|
||||||
|
@ -1990,12 +1976,9 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
values = payload['values']
|
values = payload['values']
|
||||||
if is_operator(self, jid_bare) and 'jid' in values:
|
if is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid = values['jid'][0]
|
jid_bare = values['jid'][0]
|
||||||
jid_file = jid
|
|
||||||
del values['jid']
|
del values['jid']
|
||||||
else:
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
jid_file = jid_bare
|
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
for key in values:
|
for key in values:
|
||||||
value = 1 if values[key] else 0
|
value = 1 if values[key] else 0
|
||||||
await sqlite.set_enabled_status(db_file, key, value)
|
await sqlite.set_enabled_status(db_file, key, value)
|
||||||
|
@ -2018,12 +2001,9 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
values = payload['values']
|
values = payload['values']
|
||||||
if is_operator(self, jid_bare) and 'jid' in values:
|
if is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid = values['jid'][0]
|
jid_bare = values['jid'][0]
|
||||||
jid_file = jid
|
|
||||||
del values['jid']
|
del values['jid']
|
||||||
else:
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
jid_file = jid_bare
|
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
subscriptions =''
|
subscriptions =''
|
||||||
ixs = values['subscriptions']
|
ixs = values['subscriptions']
|
||||||
for ix in ixs:
|
for ix in ixs:
|
||||||
|
@ -2252,14 +2232,11 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
form = self['xep_0004'].make_form('form', 'Subscriptions')
|
form = self['xep_0004'].make_form('form', 'Subscriptions')
|
||||||
if is_operator(self, jid_bare) and 'jid' in values:
|
if is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid = values['jid']
|
jid_bare = values['jid']
|
||||||
jid_file = jid
|
|
||||||
form.add_field(ftype='hidden',
|
form.add_field(ftype='hidden',
|
||||||
value=jid,
|
value=jid_bare,
|
||||||
var='jid')
|
var='jid')
|
||||||
else:
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
jid_file = jid_bare
|
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
match values['action']:
|
match values['action']:
|
||||||
case 'browse':
|
case 'browse':
|
||||||
form['instructions'] = 'Editing subscriptions'
|
form['instructions'] = 'Editing subscriptions'
|
||||||
|
@ -2349,14 +2326,11 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
values = payload['values']
|
values = payload['values']
|
||||||
if is_operator(self, jid_bare) and 'jid' in values:
|
if is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid = values['jid'][0]
|
jid_bare = values['jid'][0]
|
||||||
jid_file = jid
|
|
||||||
form.add_field(ftype='hidden',
|
form.add_field(ftype='hidden',
|
||||||
value=jid,
|
value=jid_bare,
|
||||||
var='jid')
|
var='jid')
|
||||||
else:
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
jid_file = jid_bare
|
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
tag_id = values['tag']
|
tag_id = values['tag']
|
||||||
tag_name = sqlite.get_tag_name(db_file, tag_id)[0]
|
tag_name = sqlite.get_tag_name(db_file, tag_id)[0]
|
||||||
form['instructions'] = 'Subscriptions tagged with "{}"'.format(tag_name)
|
form['instructions'] = 'Subscriptions tagged with "{}"'.format(tag_name)
|
||||||
|
@ -2390,14 +2364,11 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
values = payload['values']
|
values = payload['values']
|
||||||
if is_operator(self, jid_bare) and 'jid' in values:
|
if is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid = values['jid'][0] if values['jid'] else jid_bare
|
jid_bare = values['jid'][0] if values['jid'] else jid_bare
|
||||||
jid_file = jid
|
|
||||||
form.add_field(ftype='hidden',
|
form.add_field(ftype='hidden',
|
||||||
value=jid,
|
value=jid_bare,
|
||||||
var='jid')
|
var='jid')
|
||||||
else:
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
jid_file = jid_bare
|
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
if 'subscription' in values: urls = values['subscription']
|
if 'subscription' in values: urls = values['subscription']
|
||||||
elif 'subscriptions' in values: urls = values['subscriptions']
|
elif 'subscriptions' in values: urls = values['subscriptions']
|
||||||
url_count = len(urls)
|
url_count = len(urls)
|
||||||
|
@ -2489,11 +2460,8 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
values = payload['values']
|
values = payload['values']
|
||||||
if is_operator(self, jid_bare) and 'jid' in values:
|
if is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid = values['jid'][0]
|
jid_bare = values['jid'][0]
|
||||||
jid_file = jid
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
else:
|
|
||||||
jid_file = jid_bare
|
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
# url = values['url']
|
# url = values['url']
|
||||||
# feed_id = sqlite.get_feed_id(db_file, url)
|
# feed_id = sqlite.get_feed_id(db_file, url)
|
||||||
# feed_id = feed_id[0]
|
# feed_id = feed_id[0]
|
||||||
|
@ -2894,10 +2862,8 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
if is_operator(self, jid_bare) and 'jid' in values:
|
if is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid = values['jid']
|
jid = values['jid']
|
||||||
jid_file = jid[0] if isinstance(jid, list) else jid
|
jid_bare = jid[0] if isinstance(jid, list) else jid
|
||||||
else:
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
jid_file = jid_bare
|
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
result = await fetch.http(url)
|
result = await fetch.http(url)
|
||||||
count = await action.import_opml(db_file, result)
|
count = await action.import_opml(db_file, result)
|
||||||
try:
|
try:
|
||||||
|
@ -2937,14 +2903,12 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
if is_operator(self, jid_bare) and 'jid' in values:
|
if is_operator(self, jid_bare) and 'jid' in values:
|
||||||
jid = values['jid']
|
jid = values['jid']
|
||||||
jid_file = jid[0] if isinstance(jid, list) else jid
|
jid_bare = jid[0] if isinstance(jid, list) else jid
|
||||||
else:
|
|
||||||
jid_file = jid_bare
|
|
||||||
# form = self['xep_0004'].make_form('result', 'Done')
|
# form = self['xep_0004'].make_form('result', 'Done')
|
||||||
# form['instructions'] = ('✅️ Feeds have been exported')
|
# form['instructions'] = ('✅️ Feeds have been exported')
|
||||||
exts = values['filetype']
|
exts = values['filetype']
|
||||||
for ext in exts:
|
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)
|
url = await XmppUpload.start(self, jid_bare, filename)
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
XmppMessage.send_oob(self, jid_bare, url, chat_type)
|
XmppMessage.send_oob(self, jid_bare, url, chat_type)
|
||||||
|
@ -3411,8 +3375,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
if key:
|
if key:
|
||||||
jid_bare = key
|
jid_bare = key
|
||||||
value = values[key]
|
value = values[key]
|
||||||
jid_file = jid_bare
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
||||||
await Config.set_setting_value(self.settings, jid_bare,
|
await Config.set_setting_value(self.settings, jid_bare,
|
||||||
|
@ -3674,8 +3637,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
chat_type = await get_chat_type(self, jid_bare)
|
chat_type = await get_chat_type(self, jid_bare)
|
||||||
if is_access(self, jid_bare, jid_full, chat_type):
|
if is_access(self, jid_bare, jid_full, chat_type):
|
||||||
jid_file = jid_bare
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
||||||
form = self['xep_0004'].make_form('form', 'Settings')
|
form = self['xep_0004'].make_form('form', 'Settings')
|
||||||
|
@ -3792,8 +3754,7 @@ class Slixfeed(slixmpp.ClientXMPP):
|
||||||
logger.debug('{}: jid_full: {}'
|
logger.debug('{}: jid_full: {}'
|
||||||
.format(function_name, jid_full))
|
.format(function_name, jid_full))
|
||||||
jid_bare = session['from'].bare
|
jid_bare = session['from'].bare
|
||||||
jid_file = jid_bare
|
db_file = config.get_pathname_to_database(jid_bare)
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
|
||||||
if jid_bare not in self.settings:
|
if jid_bare not in self.settings:
|
||||||
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
||||||
# In this case (as is typical), the payload is a form
|
# In this case (as is typical), the payload is a form
|
||||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue