Improve About form.
Improve handling of setting change.
This commit is contained in:
parent
8d9b060314
commit
e553166954
9 changed files with 1008 additions and 614 deletions
|
@ -54,11 +54,15 @@ from slixfeed.xmpp.presence import XmppPresence
|
|||
from slixfeed.xmpp.upload import XmppUpload
|
||||
from slixfeed.xmpp.utility import get_chat_type
|
||||
import sys
|
||||
import tomllib
|
||||
from urllib import error
|
||||
from urllib.parse import parse_qs, urlsplit
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
try:
|
||||
import tomllib
|
||||
except:
|
||||
import tomli as tomllib
|
||||
|
||||
logger = Logger(__name__)
|
||||
|
||||
try:
|
||||
|
@ -655,10 +659,12 @@ def list_feeds(results):
|
|||
.format(len(results)))
|
||||
else:
|
||||
url = pick_a_feed()
|
||||
message = ('List of subscriptions is empty. To add a feed, send a URL.'
|
||||
'Featured feed:\n*{}*\n{}'
|
||||
.format(url['name'],
|
||||
url['link']))
|
||||
message = ('List of subscriptions is empty.'
|
||||
'\n'
|
||||
'To add a feed, send a URL.'
|
||||
'\n'
|
||||
'Featured news:\n*{}*\n{}'
|
||||
.format(url['name'], url['link']))
|
||||
return message
|
||||
|
||||
|
||||
|
|
|
@ -76,6 +76,12 @@ name = "classless Kulla"
|
|||
link = "https://www.classless.org/feed/atom/"
|
||||
tags = ["europe ,germany ,history ,literature ,war"]
|
||||
|
||||
[[feeds]]
|
||||
lang = "de-de"
|
||||
name = "Die Unbestechlichen"
|
||||
link = "https://dieunbestechlichen.com/feed/"
|
||||
tags = ["culture", "germany", "local", "news"]
|
||||
|
||||
[[feeds]]
|
||||
lang = "de-de"
|
||||
name = "Digitalcourage"
|
||||
|
@ -286,6 +292,12 @@ name = "Ctrl blog"
|
|||
link = "https://feed.ctrl.blog/latest.atom"
|
||||
tags = ["computer", "technology"]
|
||||
|
||||
[[feeds]]
|
||||
lang = "en-us"
|
||||
name = "Delta Chat - Messenger based on e-mail"
|
||||
link = "https://delta.chat/feed.xml"
|
||||
tags = ["email", "telecommunication"]
|
||||
|
||||
[[feeds]]
|
||||
lang = "en-us"
|
||||
name = "Disroot Blog"
|
||||
|
@ -478,6 +490,12 @@ name = "Project Gemini news"
|
|||
link = "https://gemini.circumlunar.space/news/atom.xml"
|
||||
tags = ["gemini", "internet"]
|
||||
|
||||
[[feeds]]
|
||||
lang = "en-us"
|
||||
name = "Public Intelligence Blog"
|
||||
link = "https://phibetaiota.net/feed/"
|
||||
tags = ["cia", "conspiracy", "health", "government", "war"]
|
||||
|
||||
[[feeds]]
|
||||
lang = "en-us"
|
||||
name = "PUNCH"
|
||||
|
@ -578,13 +596,7 @@ tags = ["3d", "architecture", "design", "game"]
|
|||
lang = "en-us"
|
||||
name = "Take Back Our Tech"
|
||||
link = "https://takebackourtech.org/rss/"
|
||||
tags = ["internet", "privacy", "surveillance"]
|
||||
|
||||
[[feeds]]
|
||||
lang = "en-us"
|
||||
name = "The Bald Brothers"
|
||||
link = "https://thebaldbrothers.com/feed/"
|
||||
tags = ["lifestyle", "men"]
|
||||
tags = ["computer", "internet", "privacy", "surveillance"]
|
||||
|
||||
[[feeds]]
|
||||
lang = "en-us"
|
||||
|
@ -592,12 +604,24 @@ name = "The 250kb Club"
|
|||
link = "https://250kb.club/rss.xml"
|
||||
tags = ["webring"]
|
||||
|
||||
[[feeds]]
|
||||
lang = "en-us"
|
||||
name = "The Bald Brothers"
|
||||
link = "https://thebaldbrothers.com/feed/"
|
||||
tags = ["lifestyle", "men"]
|
||||
|
||||
[[feeds]]
|
||||
lang = "en-us"
|
||||
name = "The Conscious Resistance Network"
|
||||
link = "https://theconsciousresistance.com/feed/"
|
||||
tags = ["culture", "government", "podcast", "politics", "privacy", "surveillance", "usa"]
|
||||
|
||||
[[feeds]]
|
||||
lang = "en-us"
|
||||
name = "Lazy Reading | The Cyber Vanguard"
|
||||
link = "https://cyber.dabamos.de/blog/feed.rss"
|
||||
tags = ["computer", "internet", "linux", "software", "telecommunication"]
|
||||
|
||||
[[feeds]]
|
||||
lang = "en-us"
|
||||
name = "The Corbett Report"
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -80,6 +80,14 @@ class Config:
|
|||
else:
|
||||
await sqlite.set_setting_value(db_file, key_val)
|
||||
|
||||
def get_setting_value(settings, jid_bare, key):
|
||||
if key in settings[jid_bare]:
|
||||
value = settings[jid_bare][key]
|
||||
else:
|
||||
value = settings['default'][key]
|
||||
return value
|
||||
|
||||
|
||||
# self.settings = {}
|
||||
# initiate an empty dict and the rest would be:
|
||||
# settings['account'] = {}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
__version__ = '0.1.34'
|
||||
__version_info__ = (0, 1, 34)
|
||||
__version__ = '0.1.35'
|
||||
__version_info__ = (0, 1, 35)
|
||||
|
|
|
@ -59,6 +59,11 @@ from slixfeed.xmpp.utility import get_chat_type
|
|||
import sys
|
||||
import time
|
||||
|
||||
try:
|
||||
import tomllib
|
||||
except:
|
||||
import tomli as tomllib
|
||||
|
||||
import asyncio
|
||||
from datetime import datetime
|
||||
import logging
|
||||
|
@ -2072,18 +2077,13 @@ class Slixfeed(slixmpp.ClientXMPP):
|
|||
ftype='list-single',
|
||||
label='About',
|
||||
required=True)
|
||||
options.addOption('Slixfeed', 'about')
|
||||
options.addOption('RSS Task Force', 'rtf')
|
||||
# options.addOption('Manual', 'manual')
|
||||
options.addOption('Tips', 'tips')
|
||||
options.addOption('Services for syndication', 'services')
|
||||
options.addOption('Software for syndication', 'software')
|
||||
options.addOption('Terms and conditions', 'terms')
|
||||
options.addOption('Privacy policy', 'policy')
|
||||
options.addOption('License', 'license')
|
||||
options.addOption('Authors', 'author')
|
||||
options.addOption('Translators', 'translators')
|
||||
options.addOption('Thanks', 'thanks')
|
||||
config_dir = config.get_default_config_directory()
|
||||
with open(config_dir + '/' + 'information.toml', mode="rb") as information:
|
||||
entries = tomllib.load(information)
|
||||
for entry in entries:
|
||||
label = entries[entry][0]['title']
|
||||
options.addOption(label, entry)
|
||||
# options.addOption('Tips', 'tips')
|
||||
session['payload'] = form
|
||||
session['next'] = self._handle_about_result
|
||||
session['has_next'] = True
|
||||
|
@ -2095,71 +2095,49 @@ class Slixfeed(slixmpp.ClientXMPP):
|
|||
function_name = sys._getframe().f_code.co_name
|
||||
logger.debug('{}: jid_full: {}'
|
||||
.format(function_name, jid_full))
|
||||
match payload['values']['option']:
|
||||
case 'about':
|
||||
title = 'About'
|
||||
subtitle = 'Slixfeed {}\n\n'.format(__version__)
|
||||
content = action.manual('information.toml', 'about')
|
||||
content += ['\nslixmpp\n']
|
||||
content += action.manual('information.toml', 'slixmpp')
|
||||
content += ['\nSleekXMPP\n']
|
||||
content += action.manual('information.toml', 'sleekxmpp')
|
||||
content += ['\nXMPP\n']
|
||||
content += action.manual('information.toml', 'xmpp')
|
||||
case 'rtf':
|
||||
title = 'About'
|
||||
subtitle = 'RSS Task Force'
|
||||
content = action.manual('information.toml', 'rtf')
|
||||
case 'author':
|
||||
title = 'Authors'
|
||||
subtitle = 'The People Who Made This To Happen'
|
||||
content = action.manual('information.toml', 'authors')
|
||||
# case 'manual':
|
||||
# title = 'Manual'
|
||||
# subtitle = 'Slixfeed Manual'
|
||||
# content = action.manual('information.toml', 'manual')
|
||||
case 'license':
|
||||
title = 'License'
|
||||
subtitle = 'Slixfeed Software License'
|
||||
content = action.manual('information.toml', 'license')
|
||||
case 'policy':
|
||||
title = 'Policies'
|
||||
subtitle = 'Privacy Policy'
|
||||
content = action.manual('information.toml', 'privacy')
|
||||
case 'services':
|
||||
title = 'Services'
|
||||
subtitle = ('Below are online services that extend the '
|
||||
'syndication experience by means of bookmarking '
|
||||
'and multimedia, and also enhance it by restoring '
|
||||
'access to news web feeds.')
|
||||
content = action.manual('information.toml', 'services')
|
||||
case 'software':
|
||||
title = 'Software'
|
||||
subtitle = ('Take back control of your news. With free, high-'
|
||||
'quality, software for your desktop, home and '
|
||||
'mobile devices.')
|
||||
content = action.manual('information.toml', 'software')
|
||||
case 'terms':
|
||||
title = 'Policies'
|
||||
subtitle = 'Terms and Conditions'
|
||||
content = action.manual('information.toml', 'terms')
|
||||
case 'thanks':
|
||||
title = 'Thanks'
|
||||
subtitle = 'We are XMPP'
|
||||
content = action.manual('information.toml', 'thanks')
|
||||
case 'tips':
|
||||
# Tips and tricks you might have not known about Slixfeed and XMPP!
|
||||
title = 'Help'
|
||||
subtitle = 'Tips & Tricks'
|
||||
content = 'This page is not yet available.'
|
||||
case 'translators':
|
||||
title = 'Translators'
|
||||
subtitle = 'From all across the world'
|
||||
content = action.manual('information.toml', 'translators')
|
||||
form = self['xep_0004'].make_form('result', title)
|
||||
form['instructions'] = subtitle
|
||||
form.add_field(ftype="text-multi",
|
||||
value=content)
|
||||
config_dir = config.get_default_config_directory()
|
||||
with open(config_dir + '/' + 'information.toml', mode="rb") as information:
|
||||
entries = tomllib.load(information)
|
||||
entry_key = payload['values']['option']
|
||||
# case 'terms':
|
||||
# title = 'Policies'
|
||||
# subtitle = 'Terms and Conditions'
|
||||
# content = action.manual('information.toml', 'terms')
|
||||
# case 'tips':
|
||||
# # Tips and tricks you might have not known about Slixfeed and XMPP!
|
||||
# title = 'Help'
|
||||
# subtitle = 'Tips & Tricks'
|
||||
# content = 'This page is not yet available.'
|
||||
# case 'translators':
|
||||
# title = 'Translators'
|
||||
# subtitle = 'From all across the world'
|
||||
# content = action.manual('information.toml', 'translators')
|
||||
# title = entry_key.capitalize()
|
||||
# form = self['xep_0004'].make_form('result', title)
|
||||
for entry in entries[entry_key]:
|
||||
if 'title' in entry:
|
||||
title = entry['title']
|
||||
form = self['xep_0004'].make_form('result', title)
|
||||
subtitle = entry['subtitle']
|
||||
form['instructions'] = subtitle
|
||||
continue
|
||||
for e_key in entry:
|
||||
e_val = entry[e_key]
|
||||
e_key = e_key.capitalize()
|
||||
# form.add_field(ftype='fixed',
|
||||
# value=e_val)
|
||||
print(type(e_val))
|
||||
if e_key == 'Name':
|
||||
form.add_field(ftype='fixed',
|
||||
value=e_val)
|
||||
continue
|
||||
if isinstance(e_val, list):
|
||||
form_type = 'text-multi'
|
||||
else:
|
||||
form_type = 'text-single'
|
||||
form.add_field(label=e_key,
|
||||
ftype=form_type,
|
||||
value=e_val)
|
||||
# Gajim displays all form['instructions'] on top
|
||||
# Psi ignore the latter form['instructions']
|
||||
# form['instructions'] = 'YOU!\n🫵️\n- Join us -'
|
||||
|
@ -2192,7 +2170,6 @@ class Slixfeed(slixmpp.ClientXMPP):
|
|||
logger.debug('{}: jid_full: {}'
|
||||
.format(function_name, jid_full))
|
||||
|
||||
import tomllib
|
||||
config_dir = config.get_default_config_directory()
|
||||
with open(config_dir + '/' + 'commands.toml', mode="rb") as commands:
|
||||
cmds = tomllib.load(commands)
|
||||
|
|
|
@ -333,7 +333,7 @@ class XmppCommand:
|
|||
options.addOption('All news', 'all')
|
||||
# options.addOption('News by subscription', 'feed')
|
||||
# options.addOption('News by tag', 'tag')
|
||||
options.addOption('Rejected news', 'rejected')
|
||||
options.addOption('Rejected news', 'reject')
|
||||
options.addOption('Unread news', 'unread')
|
||||
session['allow_prev'] = False # Cheogram changes style if that button - which should not be on this form - is present
|
||||
session['has_next'] = True
|
||||
|
@ -354,14 +354,20 @@ class XmppCommand:
|
|||
num = 100
|
||||
match payload['values']['action']:
|
||||
case 'all':
|
||||
results = sqlite.get_entries(db_file, num) # FIXME
|
||||
case 'rejected':
|
||||
results = sqlite.get_entries_rejected(db_file, num) # FIXME
|
||||
results = sqlite.get_entries(db_file, num)
|
||||
subtitle = 'Recent {} updates'.format(num)
|
||||
message = 'There are no news'
|
||||
case 'reject':
|
||||
results = sqlite.get_entries_rejected(db_file, num)
|
||||
subtitle = 'Recent {} updates (rejected)'.format(num)
|
||||
message = 'There are no rejected news'
|
||||
case 'unread':
|
||||
results = sqlite.get_unread_entries(db_file, num)
|
||||
subtitle = 'Recent {} updates (unread)'.format(num)
|
||||
message = 'There are no unread news.'
|
||||
if results:
|
||||
form = self['xep_0004'].make_form('form', 'Updates')
|
||||
form['instructions'] = 'Recent {} updates'.format(num)
|
||||
form['instructions'] = subtitle
|
||||
options = form.add_field(var='update',
|
||||
ftype='list-single',
|
||||
label='News',
|
||||
|
@ -377,8 +383,13 @@ class XmppCommand:
|
|||
session['payload'] = form
|
||||
session['prev'] = None # Cheogram works as expected with 'allow_prev' set to False Just in case
|
||||
else:
|
||||
text_info = 'There are no unread news.'
|
||||
text_info = message
|
||||
session['allow_prev'] = True
|
||||
session['has_next'] = False
|
||||
session['next'] = None
|
||||
session['notes'] = [['info', text_info]]
|
||||
session['payload'] = None
|
||||
session['prev'] = self._handle_recent
|
||||
return session
|
||||
|
||||
|
||||
|
@ -520,7 +531,7 @@ class XmppCommand:
|
|||
error_count = 0
|
||||
exist_count = 0
|
||||
for url in urls:
|
||||
result = await action.add_feed(db_file, url)
|
||||
result = await action.add_feed(self, jid_bare, db_file, url)
|
||||
if result['error']:
|
||||
error_count += 1
|
||||
elif result['exist']:
|
||||
|
@ -544,7 +555,7 @@ class XmppCommand:
|
|||
else:
|
||||
if isinstance(url, list):
|
||||
url = url[0]
|
||||
result = await action.add_feed(db_file, url)
|
||||
result = await action.add_feed(self, jid_bare, db_file, url)
|
||||
if isinstance(result, list):
|
||||
results = result
|
||||
form = self['xep_0004'].make_form('form', 'Subscriptions')
|
||||
|
@ -1435,18 +1446,13 @@ class XmppCommand:
|
|||
ftype='list-single',
|
||||
label='About',
|
||||
required=True)
|
||||
options.addOption('Slixfeed', 'about')
|
||||
options.addOption('RSS Task Force', 'rtf')
|
||||
# options.addOption('Manual', 'manual')
|
||||
options.addOption('Tips', 'tips')
|
||||
options.addOption('Services for syndication', 'services')
|
||||
options.addOption('Software for syndication', 'software')
|
||||
options.addOption('Terms and conditions', 'terms')
|
||||
options.addOption('Privacy policy', 'policy')
|
||||
options.addOption('License', 'license')
|
||||
options.addOption('Authors', 'author')
|
||||
options.addOption('Translators', 'translators')
|
||||
options.addOption('Thanks', 'thanks')
|
||||
config_dir = config.get_default_config_directory()
|
||||
with open(config_dir + '/' + 'information.toml', mode="rb") as information:
|
||||
entries = tomllib.load(information)
|
||||
for entry in entries:
|
||||
label = entries[entry][0]['title']
|
||||
options.addOption(label, entry)
|
||||
# options.addOption('Tips', 'tips')
|
||||
session['payload'] = form
|
||||
session['next'] = self._handle_about_result
|
||||
session['has_next'] = True
|
||||
|
@ -1458,71 +1464,49 @@ class XmppCommand:
|
|||
function_name = sys._getframe().f_code.co_name
|
||||
logger.debug('{}: jid_full: {}'
|
||||
.format(function_name, jid_full))
|
||||
match payload['values']['option']:
|
||||
case 'about':
|
||||
title = 'About'
|
||||
subtitle = 'Slixfeed {}\n\n'.format(__version__)
|
||||
content = action.manual('information.toml', 'about')
|
||||
content += ['\nslixmpp\n']
|
||||
content += action.manual('information.toml', 'slixmpp')
|
||||
content += ['\nSleekXMPP\n']
|
||||
content += action.manual('information.toml', 'sleekxmpp')
|
||||
content += ['\nXMPP\n']
|
||||
content += action.manual('information.toml', 'xmpp')
|
||||
case 'rtf':
|
||||
title = 'About'
|
||||
subtitle = 'RSS Task Force'
|
||||
content = action.manual('information.toml', 'rtf')
|
||||
case 'author':
|
||||
title = 'Authors'
|
||||
subtitle = 'The People Who Made This To Happen'
|
||||
content = action.manual('information.toml', 'authors')
|
||||
# case 'manual':
|
||||
# title = 'Manual'
|
||||
# subtitle = 'Slixfeed Manual'
|
||||
# content = action.manual('information.toml', 'manual')
|
||||
case 'license':
|
||||
title = 'License'
|
||||
subtitle = 'Slixfeed Software License'
|
||||
content = action.manual('information.toml', 'license')
|
||||
case 'policy':
|
||||
title = 'Policies'
|
||||
subtitle = 'Privacy Policy'
|
||||
content = action.manual('information.toml', 'privacy')
|
||||
case 'services':
|
||||
title = 'Services'
|
||||
subtitle = ('Below are online services that extend the '
|
||||
'syndication experience by means of bookmarking '
|
||||
'and multimedia, and also enhance it by restoring '
|
||||
'access to news web feeds.')
|
||||
content = action.manual('information.toml', 'services')
|
||||
case 'software':
|
||||
title = 'Software'
|
||||
subtitle = ('Take back control of your news. With free, high-'
|
||||
'quality, software for your desktop, home and '
|
||||
'mobile devices.')
|
||||
content = action.manual('information.toml', 'software')
|
||||
case 'terms':
|
||||
title = 'Policies'
|
||||
subtitle = 'Terms and Conditions'
|
||||
content = action.manual('information.toml', 'terms')
|
||||
case 'thanks':
|
||||
title = 'Thanks'
|
||||
subtitle = 'We are XMPP'
|
||||
content = action.manual('information.toml', 'thanks')
|
||||
case 'tips':
|
||||
# Tips and tricks you might have not known about Slixfeed and XMPP!
|
||||
title = 'Help'
|
||||
subtitle = 'Tips & Tricks'
|
||||
content = 'This page is not yet available.'
|
||||
case 'translators':
|
||||
title = 'Translators'
|
||||
subtitle = 'From all across the world'
|
||||
content = action.manual('information.toml', 'translators')
|
||||
form = self['xep_0004'].make_form('result', title)
|
||||
form['instructions'] = subtitle
|
||||
form.add_field(ftype="text-multi",
|
||||
value=content)
|
||||
config_dir = config.get_default_config_directory()
|
||||
with open(config_dir + '/' + 'information.toml', mode="rb") as information:
|
||||
entries = tomllib.load(information)
|
||||
entry_key = payload['values']['option']
|
||||
# case 'terms':
|
||||
# title = 'Policies'
|
||||
# subtitle = 'Terms and Conditions'
|
||||
# content = action.manual('information.toml', 'terms')
|
||||
# case 'tips':
|
||||
# # Tips and tricks you might have not known about Slixfeed and XMPP!
|
||||
# title = 'Help'
|
||||
# subtitle = 'Tips & Tricks'
|
||||
# content = 'This page is not yet available.'
|
||||
# case 'translators':
|
||||
# title = 'Translators'
|
||||
# subtitle = 'From all across the world'
|
||||
# content = action.manual('information.toml', 'translators')
|
||||
# title = entry_key.capitalize()
|
||||
# form = self['xep_0004'].make_form('result', title)
|
||||
for entry in entries[entry_key]:
|
||||
if 'title' in entry:
|
||||
title = entry['title']
|
||||
form = self['xep_0004'].make_form('result', title)
|
||||
subtitle = entry['subtitle']
|
||||
form['instructions'] = subtitle
|
||||
continue
|
||||
for e_key in entry:
|
||||
e_val = entry[e_key]
|
||||
e_key = e_key.capitalize()
|
||||
# form.add_field(ftype='fixed',
|
||||
# value=e_val)
|
||||
print(type(e_val))
|
||||
if e_key == 'Name':
|
||||
form.add_field(ftype='fixed',
|
||||
value=e_val)
|
||||
continue
|
||||
if isinstance(e_val, list):
|
||||
form_type = 'text-multi'
|
||||
else:
|
||||
form_type = 'text-single'
|
||||
form.add_field(label=e_key,
|
||||
ftype=form_type,
|
||||
value=e_val)
|
||||
# Gajim displays all form['instructions'] on top
|
||||
# Psi ignore the latter form['instructions']
|
||||
# form['instructions'] = 'YOU!\n🫵️\n- Join us -'
|
||||
|
@ -1555,7 +1539,6 @@ class XmppCommand:
|
|||
logger.debug('{}: jid_full: {}'
|
||||
.format(function_name, jid_full))
|
||||
|
||||
import tomllib
|
||||
config_dir = config.get_default_config_directory()
|
||||
with open(config_dir + '/' + 'commands.toml', mode="rb") as commands:
|
||||
cmds = tomllib.load(commands)
|
||||
|
@ -2127,7 +2110,6 @@ class XmppCommand:
|
|||
i += 1
|
||||
value = self.settings[jid_bare]['quantum'] or self.settings['default']['quantum']
|
||||
value = str(value)
|
||||
value = str(value)
|
||||
options = form.add_field(var='quantum',
|
||||
ftype='list-single',
|
||||
label='Amount',
|
||||
|
@ -2142,7 +2124,6 @@ class XmppCommand:
|
|||
i += 1
|
||||
value = self.settings[jid_bare]['archive'] or self.settings['default']['archive']
|
||||
value = str(value)
|
||||
value = str(value)
|
||||
options = form.add_field(var='archive',
|
||||
ftype='list-single',
|
||||
label='Archive',
|
||||
|
@ -2170,7 +2151,7 @@ class XmppCommand:
|
|||
jid_full = str(session['from'])
|
||||
function_name = sys._getframe().f_code.co_name
|
||||
logger.debug('{}: jid_full: {}'
|
||||
.format(function_name, jid_full))
|
||||
.format(function_name, jid_full))
|
||||
jid_bare = session['from'].bare
|
||||
form = payload
|
||||
jid_file = jid_bare
|
||||
|
@ -2183,14 +2164,23 @@ class XmppCommand:
|
|||
key = value
|
||||
val = values[value]
|
||||
|
||||
if key == 'interval':
|
||||
if key in ('enabled', 'media', 'old'):
|
||||
if val == True:
|
||||
val = 1
|
||||
elif val == False:
|
||||
val = 0
|
||||
|
||||
if key in ('archive', 'interval', 'quantum'):
|
||||
val = int(val)
|
||||
|
||||
if key == 'interval':
|
||||
if val < 1: val = 1
|
||||
val = val * 60
|
||||
|
||||
is_enabled = self.settings[jid_bare]['enabled'] or self.settings['default']['enabled']
|
||||
|
||||
if (key == 'enabled' and val == 1 and
|
||||
if (key == 'enabled' and
|
||||
val == 1 and
|
||||
str(is_enabled) == 0):
|
||||
logger.info('Slixfeed has been enabled for {}'.format(jid_bare))
|
||||
status_type = 'available'
|
||||
|
@ -2201,7 +2191,8 @@ class XmppCommand:
|
|||
key_list = ['check', 'status', 'interval']
|
||||
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||
|
||||
if (key == 'enabled' and val == 0 and
|
||||
if (key == 'enabled' and
|
||||
val == 0 and
|
||||
str(is_enabled) == 1):
|
||||
logger.info('Slixfeed has been disabled for {}'.format(jid_bare))
|
||||
key_list = ['interval', 'status']
|
||||
|
@ -2211,10 +2202,8 @@ class XmppCommand:
|
|||
XmppPresence.send(self, jid_bare, status_message,
|
||||
status_type=status_type)
|
||||
|
||||
# These three ilnes (getting value after setting it) might be removed
|
||||
await config.set_setting_value(db_file, key, val)
|
||||
val = sqlite.get_setting_value(db_file, key)
|
||||
val = val[0]
|
||||
await Config.set_setting_value(self.settings, jid_bare, db_file, key, val)
|
||||
val = self.settings[jid_bare][key]
|
||||
|
||||
# if key == 'enabled':
|
||||
# if str(setting.enabled) == 0:
|
||||
|
|
|
@ -31,6 +31,7 @@ import slixfeed.task as task
|
|||
# from lxml import etree
|
||||
|
||||
import slixfeed.config as config
|
||||
from slixfeed.config import Config
|
||||
from slixfeed.log import Logger
|
||||
from slixfeed.version import __version__
|
||||
from slixfeed.xmpp.connect import XmppConnect
|
||||
|
@ -49,6 +50,11 @@ from slixfeed.xmpp.utility import get_chat_type
|
|||
import sys
|
||||
import time
|
||||
|
||||
try:
|
||||
import tomllib
|
||||
except:
|
||||
import tomli as tomllib
|
||||
|
||||
import asyncio
|
||||
from datetime import datetime
|
||||
import logging
|
||||
|
@ -918,7 +924,7 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
|||
options.addOption('All news', 'all')
|
||||
# options.addOption('News by subscription', 'feed')
|
||||
# options.addOption('News by tag', 'tag')
|
||||
options.addOption('Rejected news', 'rejected')
|
||||
options.addOption('Rejected news', 'reject')
|
||||
options.addOption('Unread news', 'unread')
|
||||
session['allow_prev'] = False # Cheogram changes style if that button - which should not be on this form - is present
|
||||
session['has_next'] = True
|
||||
|
@ -939,14 +945,20 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
|||
num = 100
|
||||
match payload['values']['action']:
|
||||
case 'all':
|
||||
results = sqlite.get_entries(db_file, num) # FIXME
|
||||
case 'rejected':
|
||||
results = sqlite.get_entries_rejected(db_file, num) # FIXME
|
||||
results = sqlite.get_entries(db_file, num)
|
||||
subtitle = 'Recent {} updates'.format(num)
|
||||
message = 'There are no news'
|
||||
case 'reject':
|
||||
results = sqlite.get_entries_rejected(db_file, num)
|
||||
subtitle = 'Recent {} updates (rejected)'.format(num)
|
||||
message = 'There are no rejected news'
|
||||
case 'unread':
|
||||
results = sqlite.get_unread_entries(db_file, num)
|
||||
subtitle = 'Recent {} updates (unread)'.format(num)
|
||||
message = 'There are no unread news.'
|
||||
if results:
|
||||
form = self['xep_0004'].make_form('form', 'Updates')
|
||||
form['instructions'] = 'Recent {} updates'.format(num)
|
||||
form['instructions'] = subtitle
|
||||
options = form.add_field(var='update',
|
||||
ftype='list-single',
|
||||
label='News',
|
||||
|
@ -962,8 +974,13 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
|||
session['payload'] = form
|
||||
session['prev'] = None # Cheogram works as expected with 'allow_prev' set to False Just in case
|
||||
else:
|
||||
text_info = 'There are no unread news.'
|
||||
text_info = message
|
||||
session['allow_prev'] = True
|
||||
session['has_next'] = False
|
||||
session['next'] = None
|
||||
session['notes'] = [['info', text_info]]
|
||||
session['payload'] = None
|
||||
session['prev'] = self._handle_recent
|
||||
return session
|
||||
|
||||
|
||||
|
@ -2020,18 +2037,13 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
|||
ftype='list-single',
|
||||
label='About',
|
||||
required=True)
|
||||
options.addOption('Slixfeed', 'about')
|
||||
options.addOption('RSS Task Force', 'rtf')
|
||||
# options.addOption('Manual', 'manual')
|
||||
options.addOption('Tips', 'tips')
|
||||
options.addOption('Services for syndication', 'services')
|
||||
options.addOption('Software for syndication', 'software')
|
||||
options.addOption('Terms and conditions', 'terms')
|
||||
options.addOption('Privacy policy', 'policy')
|
||||
options.addOption('License', 'license')
|
||||
options.addOption('Authors', 'author')
|
||||
options.addOption('Translators', 'translators')
|
||||
options.addOption('Thanks', 'thanks')
|
||||
config_dir = config.get_default_config_directory()
|
||||
with open(config_dir + '/' + 'information.toml', mode="rb") as information:
|
||||
entries = tomllib.load(information)
|
||||
for entry in entries:
|
||||
label = entries[entry][0]['title']
|
||||
options.addOption(label, entry)
|
||||
# options.addOption('Tips', 'tips')
|
||||
session['payload'] = form
|
||||
session['next'] = self._handle_about_result
|
||||
session['has_next'] = True
|
||||
|
@ -2043,71 +2055,49 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
|||
function_name = sys._getframe().f_code.co_name
|
||||
logger.debug('{}: jid_full: {}'
|
||||
.format(function_name, jid_full))
|
||||
match payload['values']['option']:
|
||||
case 'about':
|
||||
title = 'About'
|
||||
subtitle = 'Slixfeed {}\n\n'.format(__version__)
|
||||
content = action.manual('information.toml', 'about')
|
||||
content += ['\nslixmpp\n']
|
||||
content += action.manual('information.toml', 'slixmpp')
|
||||
content += ['\nSleekXMPP\n']
|
||||
content += action.manual('information.toml', 'sleekxmpp')
|
||||
content += ['\nXMPP\n']
|
||||
content += action.manual('information.toml', 'xmpp')
|
||||
case 'rtf':
|
||||
title = 'About'
|
||||
subtitle = 'RSS Task Force'
|
||||
content = action.manual('information.toml', 'rtf')
|
||||
case 'author':
|
||||
title = 'Authors'
|
||||
subtitle = 'The People Who Made This To Happen'
|
||||
content = action.manual('information.toml', 'authors')
|
||||
# case 'manual':
|
||||
# title = 'Manual'
|
||||
# subtitle = 'Slixfeed Manual'
|
||||
# content = action.manual('information.toml', 'manual')
|
||||
case 'license':
|
||||
title = 'License'
|
||||
subtitle = 'Slixfeed Software License'
|
||||
content = action.manual('information.toml', 'license')
|
||||
case 'policy':
|
||||
title = 'Policies'
|
||||
subtitle = 'Privacy Policy'
|
||||
content = action.manual('information.toml', 'privacy')
|
||||
case 'services':
|
||||
title = 'Services'
|
||||
subtitle = ('Below are online services that extend the '
|
||||
'syndication experience by means of bookmarking '
|
||||
'and multimedia, and also enhance it by restoring '
|
||||
'access to news web feeds.')
|
||||
content = action.manual('information.toml', 'services')
|
||||
case 'software':
|
||||
title = 'Software'
|
||||
subtitle = ('Take back control of your news. With free, high-'
|
||||
'quality, software for your desktop, home and '
|
||||
'mobile devices.')
|
||||
content = action.manual('information.toml', 'software')
|
||||
case 'terms':
|
||||
title = 'Policies'
|
||||
subtitle = 'Terms and Conditions'
|
||||
content = action.manual('information.toml', 'terms')
|
||||
case 'thanks':
|
||||
title = 'Thanks'
|
||||
subtitle = 'We are XMPP'
|
||||
content = action.manual('information.toml', 'thanks')
|
||||
case 'tips':
|
||||
# Tips and tricks you might have not known about Slixfeed and XMPP!
|
||||
title = 'Help'
|
||||
subtitle = 'Tips & Tricks'
|
||||
content = 'This page is not yet available.'
|
||||
case 'translators':
|
||||
title = 'Translators'
|
||||
subtitle = 'From all across the world'
|
||||
content = action.manual('information.toml', 'translators')
|
||||
form = self['xep_0004'].make_form('result', title)
|
||||
form['instructions'] = subtitle
|
||||
form.add_field(ftype="text-multi",
|
||||
value=content)
|
||||
config_dir = config.get_default_config_directory()
|
||||
with open(config_dir + '/' + 'information.toml', mode="rb") as information:
|
||||
entries = tomllib.load(information)
|
||||
entry_key = payload['values']['option']
|
||||
# case 'terms':
|
||||
# title = 'Policies'
|
||||
# subtitle = 'Terms and Conditions'
|
||||
# content = action.manual('information.toml', 'terms')
|
||||
# case 'tips':
|
||||
# # Tips and tricks you might have not known about Slixfeed and XMPP!
|
||||
# title = 'Help'
|
||||
# subtitle = 'Tips & Tricks'
|
||||
# content = 'This page is not yet available.'
|
||||
# case 'translators':
|
||||
# title = 'Translators'
|
||||
# subtitle = 'From all across the world'
|
||||
# content = action.manual('information.toml', 'translators')
|
||||
# title = entry_key.capitalize()
|
||||
# form = self['xep_0004'].make_form('result', title)
|
||||
for entry in entries[entry_key]:
|
||||
if 'title' in entry:
|
||||
title = entry['title']
|
||||
form = self['xep_0004'].make_form('result', title)
|
||||
subtitle = entry['subtitle']
|
||||
form['instructions'] = subtitle
|
||||
continue
|
||||
for e_key in entry:
|
||||
e_val = entry[e_key]
|
||||
e_key = e_key.capitalize()
|
||||
# form.add_field(ftype='fixed',
|
||||
# value=e_val)
|
||||
print(type(e_val))
|
||||
if e_key == 'Name':
|
||||
form.add_field(ftype='fixed',
|
||||
value=e_val)
|
||||
continue
|
||||
if isinstance(e_val, list):
|
||||
form_type = 'text-multi'
|
||||
else:
|
||||
form_type = 'text-single'
|
||||
form.add_field(label=e_key,
|
||||
ftype=form_type,
|
||||
value=e_val)
|
||||
# Gajim displays all form['instructions'] on top
|
||||
# Psi ignore the latter form['instructions']
|
||||
# form['instructions'] = 'YOU!\n🫵️\n- Join us -'
|
||||
|
@ -2140,7 +2130,6 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
|
|||
logger.debug('{}: jid_full: {}'
|
||||
.format(function_name, jid_full))
|
||||
|
||||
import tomllib
|
||||
config_dir = config.get_default_config_directory()
|
||||
with open(config_dir + '/' + 'commands.toml', mode="rb") as commands:
|
||||
cmds = tomllib.load(commands)
|
||||
|
|
|
@ -307,8 +307,10 @@ async def message(self, message):
|
|||
await sqlite.insert_feed(db_file, url, title)
|
||||
await action.scan(self, jid_bare, db_file, url)
|
||||
if jid_bare not in self.settings:
|
||||
Config.add_settings_jid(self.settings, jid_bare, db_file)
|
||||
old = self.settings[jid_bare]['old'] or self.settings['default']['old']
|
||||
Config.add_settings_jid(self.settings, jid_bare,
|
||||
db_file)
|
||||
old = Config.get_setting_value(self.settings, jid_bare,
|
||||
'old')
|
||||
if old:
|
||||
# task.clean_tasks_xmpp(self, jid_bare, ['status'])
|
||||
# await send_status(jid)
|
||||
|
@ -382,14 +384,18 @@ async def message(self, message):
|
|||
val = message_text[8:]
|
||||
if val:
|
||||
try:
|
||||
if int(val) > 500:
|
||||
val_new = int(val)
|
||||
if val_new > 500:
|
||||
response = 'Value may not be greater than 500.'
|
||||
else:
|
||||
val_old = Config.get_setting_value(
|
||||
self.settings, jid_bare, key)
|
||||
db_file = config.get_pathname_to_database(jid_file)
|
||||
await Config.set_setting_value(self.settings, jid_bare, db_file, key, val)
|
||||
await Config.set_setting_value(
|
||||
self.settings, jid_bare, db_file, key, val_new)
|
||||
response = ('Maximum archived items has '
|
||||
'been set to {}.'
|
||||
.format(val))
|
||||
'been set to {} (was: {}).'
|
||||
.format(val_new, val_old))
|
||||
except:
|
||||
response = ('No action has been taken.'
|
||||
'\n'
|
||||
|
@ -581,12 +587,11 @@ async def message(self, message):
|
|||
if error:
|
||||
response = ('> {}\n'
|
||||
'Failed to export {}. '
|
||||
'Reason: {}'.format(url,
|
||||
ext.upper(),
|
||||
error))
|
||||
'Reason: {}'.format(
|
||||
url, ext.upper(), error))
|
||||
else:
|
||||
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)
|
||||
XmppMessage.send_oob(self, jid_bare, url,
|
||||
|
@ -661,8 +666,8 @@ async def message(self, message):
|
|||
result['name'],
|
||||
result['index']))
|
||||
elif result['error']:
|
||||
response = ('> {}\nFailed to find subscriptions. Reason: {}'
|
||||
.format(url, result['code']))
|
||||
response = ('> {}\nFailed to find subscriptions. '
|
||||
'Reason: {}'.format(url, result['code']))
|
||||
else:
|
||||
response = ('> {}\nNews source "{}" has been '
|
||||
'added to subscription list.'
|
||||
|
@ -702,15 +707,17 @@ async def message(self, message):
|
|||
val = message_text[9:]
|
||||
if val:
|
||||
try:
|
||||
val = int(val)
|
||||
val_new = int(val)
|
||||
val_old = Config.get_setting_value(self.settings, jid_bare, key)
|
||||
db_file = config.get_pathname_to_database(jid_file)
|
||||
await Config.set_setting_value(self.settings, jid_bare, db_file, key, val)
|
||||
await Config.set_setting_value(
|
||||
self.settings, jid_bare, db_file, key, val_new)
|
||||
# NOTE Perhaps this should be replaced by functions
|
||||
# clean and start
|
||||
task.refresh_task(self, jid_bare, task.task_send, key,
|
||||
val)
|
||||
response = ('Updates will be sent every {} minutes.'
|
||||
.format(val))
|
||||
val_new)
|
||||
response = ('Updates will be sent every {} minutes '
|
||||
'(was: {}).'.format(val_new, val_old))
|
||||
except:
|
||||
response = ('No action has been taken.'
|
||||
'\n'
|
||||
|
@ -736,15 +743,19 @@ async def message(self, message):
|
|||
val = message_text[7:]
|
||||
if val:
|
||||
try:
|
||||
val = int(val)
|
||||
val_new = int(val)
|
||||
val_old = Config.get_setting_value(
|
||||
self.settings, jid_bare, key)
|
||||
db_file = config.get_pathname_to_database(jid_file)
|
||||
await Config.set_setting_value(self.settings, jid_bare, db_file, key, val)
|
||||
if val == 0: # if not val:
|
||||
response = 'Summary length limit is disabled.'
|
||||
await Config.set_setting_value(
|
||||
self.settings, jid_bare, db_file, key, val_new)
|
||||
if val_new == 0: # if not val:
|
||||
response = ('Summary length limit is disabled '
|
||||
'(was: {}).'.format(val_old))
|
||||
else:
|
||||
response = ('Summary maximum length '
|
||||
'is set to {} characters.'
|
||||
.format(val))
|
||||
response = ('Summary maximum length is set to '
|
||||
'{} characters (was: {}).'
|
||||
.format(val_new, val_old))
|
||||
except:
|
||||
response = ('No action has been taken.'
|
||||
'\n'
|
||||
|
@ -782,21 +793,24 @@ async def message(self, message):
|
|||
db_file = config.get_pathname_to_database(jid_file)
|
||||
key = 'media'
|
||||
val = 0
|
||||
await Config.set_setting_value(self.settings, jid_bare, db_file, key, val)
|
||||
await Config.set_setting_value(
|
||||
self.settings, jid_bare, db_file, key, val)
|
||||
response = 'Media is disabled.'
|
||||
XmppMessage.send_reply(self, message, response)
|
||||
case 'media on':
|
||||
db_file = config.get_pathname_to_database(jid_file)
|
||||
key = 'media'
|
||||
val = 1
|
||||
await Config.set_setting_value(self.settings, jid_bare, db_file, key, val)
|
||||
await Config.set_setting_value(self.settings, jid_bare,
|
||||
db_file, key, val)
|
||||
response = 'Media is enabled.'
|
||||
XmppMessage.send_reply(self, message, response)
|
||||
case 'new':
|
||||
db_file = config.get_pathname_to_database(jid_file)
|
||||
key = 'old'
|
||||
val = 0
|
||||
await Config.set_setting_value(self.settings, jid_bare, db_file, key, val)
|
||||
await Config.set_setting_value(self.settings, jid_bare,
|
||||
db_file, key, val)
|
||||
response = 'Only new items of newly added feeds be delivered.'
|
||||
XmppMessage.send_reply(self, message, response)
|
||||
case _ if message_lowercase.startswith('next'):
|
||||
|
@ -811,7 +825,8 @@ async def message(self, message):
|
|||
db_file = config.get_pathname_to_database(jid_file)
|
||||
key = 'old'
|
||||
val = 1
|
||||
await Config.set_setting_value(self.settings, jid_bare, db_file, key, val)
|
||||
await Config.set_setting_value(self.settings, jid_bare,
|
||||
db_file, key, val)
|
||||
response = 'All items of newly added feeds be delivered.'
|
||||
XmppMessage.send_reply(self, message, response)
|
||||
case _ if message_lowercase.startswith('quantum'):
|
||||
|
@ -819,14 +834,17 @@ async def message(self, message):
|
|||
val = message_text[8:]
|
||||
if val:
|
||||
try:
|
||||
val = int(val)
|
||||
val_new = int(val)
|
||||
val_old = Config.get_setting_value(self.settings,
|
||||
jid_bare, key)
|
||||
# response = (
|
||||
# 'Every update will contain {} news items.'
|
||||
# ).format(response)
|
||||
db_file = config.get_pathname_to_database(jid_file)
|
||||
await Config.set_setting_value(self.settings, jid_bare, db_file, key, val)
|
||||
response = ('Next update will contain {} news items.'
|
||||
.format(val))
|
||||
await Config.set_setting_value(self.settings, jid_bare,
|
||||
db_file, key, val_new)
|
||||
response = ('Next update will contain {} news items '
|
||||
'(was: {}).'.format(val_new, val_old))
|
||||
except:
|
||||
response = ('No action has been taken.'
|
||||
'\n'
|
||||
|
@ -849,8 +867,8 @@ async def message(self, message):
|
|||
key_list = ['status']
|
||||
task.clean_tasks_xmpp(self, jid_bare, key_list)
|
||||
status_type = 'dnd'
|
||||
status_message = ('📫️ Processing request to fetch data from {}'
|
||||
.format(url))
|
||||
status_message = ('📫️ Processing request to fetch data '
|
||||
'from {}'.format(url))
|
||||
XmppPresence.send(self, jid_bare, status_message,
|
||||
status_type=status_type)
|
||||
if url.startswith('feed:'):
|
||||
|
@ -1015,10 +1033,12 @@ async def message(self, message):
|
|||
key = 'enabled'
|
||||
val = 1
|
||||
db_file = config.get_pathname_to_database(jid_file)
|
||||
await Config.set_setting_value(self.settings, jid_bare, db_file, key, val)
|
||||
await Config.set_setting_value(self.settings, jid_bare,
|
||||
db_file, key, val)
|
||||
status_type = 'available'
|
||||
status_message = '📫️ Welcome back!'
|
||||
XmppPresence.send(self, jid_bare, status_message, status_type=status_type)
|
||||
XmppPresence.send(self, jid_bare, status_message,
|
||||
status_type=status_type)
|
||||
await asyncio.sleep(5)
|
||||
key_list = ['check', 'status', 'interval']
|
||||
await task.start_tasks_xmpp(self, jid_bare, key_list)
|
||||
|
@ -1064,14 +1084,16 @@ async def message(self, message):
|
|||
'Input name is identical to the '
|
||||
'existing name.')
|
||||
else:
|
||||
await sqlite.set_feed_title(db_file, feed_id, name)
|
||||
await sqlite.set_feed_title(db_file, feed_id,
|
||||
name)
|
||||
response = ('> {}'
|
||||
'\n'
|
||||
'Subscription #{} has been renamed to "{}".'
|
||||
.format(name_old, feed_id, name))
|
||||
'Subscription #{} has been '
|
||||
'renamed to "{}".'.format(
|
||||
name_old,feed_id, name))
|
||||
else:
|
||||
response = ('Subscription with Id {} does not exist.'
|
||||
.format(feed_id))
|
||||
response = ('Subscription with Id {} does not '
|
||||
'exist.'.format(feed_id))
|
||||
except:
|
||||
response = ('No action has been taken.'
|
||||
'\n'
|
||||
|
@ -1101,7 +1123,8 @@ async def message(self, message):
|
|||
key = 'enabled'
|
||||
val = 0
|
||||
db_file = config.get_pathname_to_database(jid_file)
|
||||
await Config.set_setting_value(self.settings, jid_bare, db_file, key, val)
|
||||
await Config.set_setting_value(
|
||||
self.settings, jid_bare, db_file, key, val)
|
||||
key_list = ['interval', 'status']
|
||||
task.clean_tasks_xmpp(self, jid_bare, key_list)
|
||||
status_type = 'xa'
|
||||
|
|
Loading…
Reference in a new issue