Fix check for filters and settings keys

This commit is contained in:
Schimon Jehudah 2024-02-16 12:12:06 +00:00
parent 288e5157fa
commit 10762a69e4
9 changed files with 218 additions and 163 deletions

View file

@ -242,7 +242,7 @@ async def xmpp_send_update(self, jid, num=None):
# interval = await initdb(
# jid,
# sqlite.get_settings_value,
# sqlite.is_setting_key,
# "interval"
# )
# self.task_manager[jid]["interval"] = loop.call_at(
@ -296,10 +296,10 @@ async def xmpp_change_interval(self, key, val, jid, jid_file, message=None):
# 'Updates will be sent every {} minutes.'
# ).format(response)
db_file = config.get_pathname_to_database(jid_file)
if sqlite.get_settings_value(db_file, key):
await sqlite.update_settings_value(db_file, [key, val])
if sqlite.is_setting_key(db_file, key):
await sqlite.update_setting_value(db_file, [key, val])
else:
await sqlite.set_settings_value(db_file, [key, val])
await sqlite.set_setting_value(db_file, [key, val])
# NOTE Perhaps this should be replaced
# by functions clean and start
await task.refresh_task(self, jid, task.task_send, key, val)
@ -311,20 +311,14 @@ async def xmpp_change_interval(self, key, val, jid, jid_file, message=None):
XmppMessage.send_reply(self, message, response)
async def reset_settings(jid_file):
db_file = config.get_pathname_to_database(jid_file)
await sqlite.delete_settings(db_file)
response = 'Default settings have been restored.'
return response
async def xmpp_start_updates(self, message, jid, jid_file):
key = 'enabled'
val = 1
db_file = config.get_pathname_to_database(jid_file)
if sqlite.get_settings_value(db_file, key):
await sqlite.update_settings_value(db_file, [key, val])
if sqlite.is_setting_key(db_file, key):
await sqlite.update_setting_value(db_file, [key, val])
else:
await sqlite.set_settings_value(db_file, [key, val])
await sqlite.set_setting_value(db_file, [key, val])
status_type = 'available'
status_message = '📫️ Welcome back!'
XmppPresence.send(self, jid, status_message, status_type=status_type)
@ -338,10 +332,10 @@ async def xmpp_stop_updates(self, message, jid, jid_file):
key = 'enabled'
val = 0
db_file = config.get_pathname_to_database(jid_file)
if sqlite.get_settings_value(db_file, key):
await sqlite.update_settings_value(db_file, [key, val])
if sqlite.is_setting_key(db_file, key):
await sqlite.update_setting_value(db_file, [key, val])
else:
await sqlite.set_settings_value(db_file, [key, val])
await sqlite.set_setting_value(db_file, [key, val])
task.clean_tasks_xmpp(self, jid, ['interval', 'status'])
message_body = 'Updates are disabled.'
XmppMessage.send_reply(self, message, message_body)
@ -468,10 +462,10 @@ def list_unread_entries(result, feed_title):
# TODO Do this when entry is added to list and mark it as read
# DONE!
# results = []
# if get_settings_value(db_file, "filter-deny"):
# if sqlite.is_setting_key(db_file, "deny"):
# while len(results) < num:
# result = cur.execute(sql).fetchone()
# blacklist = await get_settings_value(db_file, "filter-deny").split(",")
# blacklist = sqlite.get_setting_value(db_file, "deny").split(",")
# for i in blacklist:
# if i in result[1]:
# continue
@ -496,7 +490,7 @@ def list_unread_entries(result, feed_title):
# breakpoint()
# # TODO Limit text length
# summary = summary.replace("\n\n\n", "\n\n")
# length = await get_settings_value(db_file, "length")
# length = sqlite.get_setting_value(db_file, "length")
# summary = summary[:length] + " […]"
# summary = summary.strip().split('\n')
# summary = ["> " + line for line in summary]

View file

@ -63,7 +63,7 @@ Send an article as file. Specify <id> or <url> and <type>.
Supported types are ePUB, HTML, MD and PDF (default).
"""
[filter]
[filters]
allow = """
allow [+|-] <keyword>
Keywords to allow
@ -77,11 +77,11 @@ comma-separated keywords
'+' appends to, '-' removes from.
"""
clear_allow = """
filter clear allow
clear allow
Reset allow list.
"""
clear_deny = """
filter clear deny
clear deny
Reset deny list.
"""

View file

@ -35,10 +35,8 @@ import tomli_w
import tomllib
def get_setting_value(db_file, key):
value = (
sqlite.get_settings_value(db_file, key) or
get_value("settings", "Settings", key)
)
value = (sqlite.get_setting_value(db_file, key)[0] or
get_value("settings", "Settings", key))
try:
value = int(value)
except ValueError as e:
@ -470,7 +468,7 @@ async def is_include_keyword(db_file, key, string):
"""
# async def reject(db_file, string):
# async def is_blacklisted(db_file, string):
keywords = (await sqlite.get_filters_value(db_file, key)) or ''
keywords = sqlite.get_filters_value(db_file, key) or ''
keywords = keywords.split(",")
keywords = keywords + (open_config_file("lists.toml")[key])
for keyword in keywords:
@ -486,9 +484,9 @@ async def is_include_keyword(db_file, key, string):
This code was tested at module datahandler
reject = 0
blacklist = await get_settings_value(
blacklist = sqlite.get_setting_value(
db_file,
"filter-deny"
"deny"
)
# print(">>> blacklist:")
# print(blacklist)

View file

@ -1752,9 +1752,9 @@ async def check_entry_exist(
return exist
async def set_settings_value(db_file, key_value):
async def set_setting_value(db_file, key_value):
"""
Set settings value.
Set setting value.
Parameters
----------
@ -1795,9 +1795,9 @@ async def set_settings_value(db_file, key_value):
cur.execute(sql, par)
async def update_settings_value(db_file, key_value):
async def update_setting_value(db_file, key_value):
"""
Update settings value.
Update setting value.
Parameters
----------
@ -1841,6 +1841,36 @@ async def update_settings_value(db_file, key_value):
# )
async def delete_filter(db_file, key):
async with DBLOCK:
with create_connection(db_file) as conn:
cur = conn.cursor()
sql = (
"""
DELETE
FROM filters
WHERE key = ?
"""
)
par = (key,)
cur.execute(sql, par)
async def delete_setting(db_file, key):
async with DBLOCK:
with create_connection(db_file) as conn:
cur = conn.cursor()
sql = (
"""
DELETE
FROM settings
WHERE key = ?
"""
)
par = (key,)
cur.execute(sql, par)
async def delete_settings(db_file):
async with DBLOCK:
with create_connection(db_file) as conn:
@ -1853,7 +1883,8 @@ async def delete_settings(db_file):
)
cur.execute(sql)
def get_settings_value(db_file, key):
def get_setting_value(db_file, key):
"""
Get settings value.
@ -1872,26 +1903,49 @@ def get_settings_value(db_file, key):
"""
with create_connection(db_file) as conn:
cur = conn.cursor()
try:
sql = (
"""
SELECT value
FROM settings
WHERE key = ?
"""
)
par = (key,)
value = cur.execute(sql, par).fetchone()[0]
value = str(value)
except:
value = None
logging.debug(
"No specific value set for key {}.".format(key)
)
return value
sql = (
"""
SELECT value
FROM settings
WHERE key = ?
"""
)
par = (key,)
value = cur.execute(sql, par).fetchone()
return value
async def set_filters_value(db_file, key_value):
def is_setting_key(db_file, key):
"""
Check whether setting key exist.
Parameters
----------
db_file : str
Path to database file.
key : str
Key: allow, deny.
Returns
-------
key : str
Key.
"""
with create_connection(db_file) as conn:
cur = conn.cursor()
sql = (
"""
SELECT key
FROM settings
WHERE key = ?
"""
)
par = (key,)
key = cur.execute(sql, par).fetchone()
return key
async def set_filter_value(db_file, key_value):
"""
Set settings value.
@ -1901,7 +1955,7 @@ async def set_filters_value(db_file, key_value):
Path to database file.
key_value : list
key : str
filter-allow, filter-deny, filter-replace.
allow, deny, replace.
value : int
Numeric value.
"""
@ -1926,7 +1980,7 @@ async def set_filters_value(db_file, key_value):
cur.execute(sql, par)
async def update_filters_value(db_file, key_value):
async def update_filter_value(db_file, key_value):
"""
Update settings value.
@ -1936,7 +1990,7 @@ async def update_filters_value(db_file, key_value):
Path to database file.
key_value : list
key : str
filter-allow, filter-deny, filter-replace.
allow, deny, replace.
value : int
Numeric value.
"""
@ -1968,9 +2022,9 @@ async def update_filters_value(db_file, key_value):
cur.execute(sql, par)
async def is_filter_key(db_file, key):
def is_filter_key(db_file, key):
"""
Get filters key.
Check whether filter key exist.
Parameters
----------
@ -1986,26 +2040,21 @@ async def is_filter_key(db_file, key):
"""
with create_connection(db_file) as conn:
cur = conn.cursor()
try:
sql = (
"""
SELECT key
FROM filters
WHERE key = ?
"""
)
par = (key,)
key = cur.execute(sql, par)
key = True
except:
key = False
logging.debug("No key {}.".format(key))
return key
sql = (
"""
SELECT key
FROM filters
WHERE key = ?
"""
)
par = (key,)
key = cur.execute(sql, par).fetchone()
return key
async def get_filters_value(db_file, key):
def get_filter_value(db_file, key):
"""
Get filters value.
Get filter value.
Parameters
----------
@ -2021,20 +2070,16 @@ async def get_filters_value(db_file, key):
"""
with create_connection(db_file) as conn:
cur = conn.cursor()
try:
sql = (
"""
SELECT value
FROM filters
WHERE key = ?
"""
)
par = (key,)
value = cur.execute(sql, par).fetchone()[0]
value = str(value)
except:
value = None
logging.debug("No specific value set for key {}.".format(key))
sql = (
"""
SELECT value
FROM filters
WHERE key = ?
"""
)
par = (key,)
value = cur.execute(sql, par).fetchone()[0]
value = str(value)
return value

View file

@ -1,2 +1,2 @@
__version__ = '0.1.7'
__version_info__ = (0, 1, 7)
__version__ = '0.1.8'
__version_info__ = (0, 1, 8)

View file

@ -50,6 +50,7 @@ import slixfeed.action as action
import slixfeed.config as config
from slixfeed.dt import timestamp
import slixfeed.sqlite as sqlite
from slixfeed.version import __version__
from slixfeed.xmpp.bookmark import XmppBookmark
from slixfeed.xmpp.connect import XmppConnect
from slixfeed.xmpp.muc import XmppGroupchat
@ -213,10 +214,10 @@ class Slixfeed(slixmpp.ClientXMPP):
task.task_ping(self)
bookmarks = await self.plugin['xep_0048'].get_bookmarks()
XmppGroupchat.autojoin(self, bookmarks)
# Service.commands(self)
# Service.reactions(self)
if config.get_value('accounts', 'XMPP', 'operator'):
jid_op = config.get_value('accounts', 'XMPP', 'operator')
message_body = 'Slixfeed version {}'.format(__version__)
XmppMessage.send(self, jid_op, message_body, 'chat')
def on_session_resumed(self, event):
@ -549,13 +550,13 @@ class Slixfeed(slixmpp.ClientXMPP):
db_file = config.get_pathname_to_database(jid_file)
form = self['xep_0004'].make_form('form', 'Filters')
form['instructions'] = '🛡️ Manage filters' # 🪄️
value = await sqlite.get_filters_value(db_file, 'allow')
value = sqlite.get_filter_value(db_file, 'allow')
form.add_field(var='allow',
ftype='text-single',
label='Allow list',
value=value,
desc=('Keywords to allow (comma-separated keywords).'))
value = await sqlite.get_filters_value(db_file, 'deny')
value = sqlite.get_filter_value(db_file, 'deny')
form.add_field(var='deny',
ftype='text-single',
label='Deny list',
@ -596,13 +597,13 @@ class Slixfeed(slixmpp.ClientXMPP):
val = values[value]
# NOTE We might want to add new keywords from
# an empty form instead of editing a form.
# keywords = await sqlite.get_filters_value(db_file, key)
# keywords = sqlite.get_filter_value(db_file, key)
keywords = ''
val = await config.add_to_list(val, keywords)
if await sqlite.is_filter_key(db_file, key):
await sqlite.update_filters_value(db_file, [key, val])
if sqlite.is_filter_key(db_file, key):
await sqlite.update_filter_value(db_file, [key, val])
elif val:
await sqlite.set_filters_value(db_file, [key, val])
await sqlite.set_filter_value(db_file, [key, val])
form.add_field(var=key.capitalize() + ' list',
ftype='text-single',
value=val)
@ -664,7 +665,7 @@ class Slixfeed(slixmpp.ClientXMPP):
# 'in the subscription list at index '
# '{}.\n{}'.format(result['name'], result['index'],
# result['url']))
# session['notes'] = [['warning', response]] # Not supported by Gajim
# session['notes'] = [['warn', response]] # Not supported by Gajim
# session['notes'] = [['info', response]]
form = self['xep_0004'].make_form('result', 'Subscriptions')
form['instructions'] = ('⚠️ Feed "{}" already exist as index {}'
@ -964,7 +965,7 @@ class Slixfeed(slixmpp.ClientXMPP):
# text = '💡️ About Slixfeed, slixmpp and XMPP\n\n'
# text += '\n\n'
# form = self['xep_0004'].make_form('result', 'About')
text = 'Slixfeed\n\n'
text = 'Slixfeed {}\n\n'.format(__version__)
text += ''.join(action.manual('information.toml', 'about'))
text += '\n\n'
text += 'Slixmpp\n\n'
@ -1109,7 +1110,11 @@ class Slixfeed(slixmpp.ClientXMPP):
form = self['xep_0004'].make_form('result', 'Credits')
form['instructions'] = "We are XMPP"
form.add_field(ftype="text-multi", value=action.manual('information.toml', 'thanks'))
form['instructions'] = 'YOU!\n🫵️\n- Join us -'
# Gajim displays all form['instructions'] on top
# Psi ignore the latter form['instructions']
# form['instructions'] = 'YOU!\n🫵\n- Join us -'
session['payload'] = form
return session
@ -1174,7 +1179,7 @@ class Slixfeed(slixmpp.ClientXMPP):
' Jabber ID: {}\n'
' Timestamp: {}\n'
.format(jid, timestamp()))
session['notes'] = [['error', 'You are not allowed to access this resource.']]
session['notes'] = [['warn', 'You are not allowed to access this resource.']]
return session
@ -1410,12 +1415,13 @@ class Slixfeed(slixmpp.ClientXMPP):
if val < 1: val = 1
val = val * 60
if sqlite.get_settings_value(db_file, key):
await sqlite.update_settings_value(db_file, [key, val])
if sqlite.is_setting_key(db_file, key):
await sqlite.update_setting_value(db_file, [key, val])
else:
await sqlite.set_settings_value(db_file, [key, val])
await sqlite.set_setting_value(db_file, [key, val])
val = sqlite.get_settings_value(db_file, key)
val = sqlite.get_setting_value(db_file, key)
val = val[0]
if key in ('enabled', 'media', 'old'):
if val == '1':
val = 'Yes'

View file

@ -625,10 +625,10 @@ class SlixfeedComponent(slixmpp.ComponentXMPP):
for value in values:
key = value
val = values[value]
if sqlite.get_settings_value(db_file, key):
await sqlite.update_settings_value(db_file, [key, val])
if sqlite.is_setting_key(db_file, key):
await sqlite.update_setting_value(db_file, [key, val])
else:
await sqlite.set_settings_value(db_file, [key, val])
await sqlite.set_setting_value(db_file, [key, val])
match value:
case 'enabled':
pass

View file

@ -62,14 +62,14 @@ class XmppGroupchat:
def join(self, inviter, jid):
# token = await initdb(
# muc_jid,
# get_settings_value,
# sqlite.get_setting_value,
# "token"
# )
# if token != "accepted":
# token = randrange(10000, 99999)
# await initdb(
# muc_jid,
# update_settings_value,
# sqlite.update_setting_value,
# ["token", token]
# )
# self.send_message(

View file

@ -116,13 +116,13 @@ async def message(self, message):
return
# token = await initdb(
# jid,
# get_settings_value,
# sqlite.get_setting_value,
# 'token'
# )
# if token == 'accepted':
# operator = await initdb(
# jid,
# get_settings_value,
# sqlite.get_setting_value,
# 'masters'
# )
# if operator:
@ -144,7 +144,7 @@ async def message(self, message):
# if not approved:
# operator = await initdb(
# jid,
# get_settings_value,
# sqlite.get_setting_value,
# 'masters'
# )
# if operator:
@ -266,18 +266,18 @@ async def message(self, message):
# acode = message[9:]
# token = await initdb(
# jid,
# get_settings_value,
# sqlite.get_setting_value,
# 'token'
# )
# if int(acode) == token:
# await initdb(
# jid,
# update_settings_value,
# sqlite.update_setting_value,
# ['masters', nick]
# )
# await initdb(
# jid,
# update_settings_value,
# sqlite.update_setting_value,
# ['token', 'accepted']
# )
# response = '{}, your are in command.'.format(nick)
@ -327,13 +327,13 @@ async def message(self, message):
val = message_text[7:]
if val:
db_file = config.get_pathname_to_database(jid_file)
keywords = await sqlite.get_filters_value(db_file, key)
keywords = sqlite.get_filter_value(db_file, key)
val = await config.add_to_list(val, keywords)
if await sqlite.get_filters_value(db_file, key):
await sqlite.update_filters_value(db_file,
if sqlite.is_filter_key(db_file, key):
await sqlite.update_filter_value(db_file,
[key, val])
else:
await sqlite.set_filters_value(db_file, [key, val])
await sqlite.set_filter_value(db_file, [key, val])
response = ('Approved keywords\n'
'```\n{}\n```'
.format(val))
@ -345,13 +345,13 @@ async def message(self, message):
val = message_text[7:]
if val:
db_file = config.get_pathname_to_database(jid_file)
keywords = await sqlite.get_filters_value(db_file, key)
keywords = sqlite.get_filter_value(db_file, key)
val = await config.remove_from_list(val, keywords)
if await sqlite.get_filters_value(db_file, key):
await sqlite.update_filters_value(db_file,
if sqlite.is_filter_key(db_file, key):
await sqlite.update_filter_value(db_file,
[key, val])
else:
await sqlite.set_filters_value(db_file, [key, val])
await sqlite.set_filter_value(db_file, [key, val])
response = ('Approved keywords\n'
'```\n{}\n```'
.format(val))
@ -367,13 +367,13 @@ async def message(self, message):
response = 'Value may not be greater than 500.'
else:
db_file = config.get_pathname_to_database(jid_file)
if sqlite.get_settings_value(db_file, key):
if sqlite.is_setting_key(db_file, key):
print('update archive')
await sqlite.update_settings_value(db_file,
await sqlite.update_setting_value(db_file,
[key, val])
else:
print('set archive')
await sqlite.set_settings_value(db_file,
await sqlite.set_setting_value(db_file,
[key, val])
response = ('Maximum archived items has '
'been set to {}.'
@ -403,11 +403,23 @@ async def message(self, message):
response = ('This action is restricted. '
'Type: removing bookmarks.')
XmppMessage.send_reply(self, message, response)
case 'default': # TODO Set default per key
response = action.reset_settings(jid_file)
case _ if message_lowercase.startswith('default '):
key = message_text[8:]
db_file = config.get_pathname_to_database(jid_file)
await sqlite.delete_setting(db_file, key)
response = ('Setting {} has been restored to default value.'
.format(key))
XmppMessage.send_reply(self, message, response)
case 'defaults':
response = action.reset_settings(jid_file)
db_file = config.get_pathname_to_database(jid_file)
await sqlite.delete_settings(db_file)
response = 'Default settings have been restored.'
XmppMessage.send_reply(self, message, response)
case _ if message_lowercase.startswith('clear '):
key = message_text[6:]
db_file = config.get_pathname_to_database(jid_file)
await sqlite.delete_filter(db_file, key)
response = 'Filter {} has been purged.'.format(key)
XmppMessage.send_reply(self, message, response)
case 'bookmarks':
if jid == config.get_value('accounts', 'XMPP', 'operator'):
@ -417,17 +429,17 @@ async def message(self, message):
'Type: viewing bookmarks.')
XmppMessage.send_reply(self, message, response)
case _ if message_lowercase.startswith('deny +'):
key = 'filter-' + message_text[:4]
key = message_text[:4]
val = message_text[6:]
if val:
db_file = config.get_pathname_to_database(jid_file)
keywords = await sqlite.get_filters_value(db_file, key)
keywords = sqlite.get_filter_value(db_file, key)
val = await config.add_to_list(val, keywords)
if await sqlite.get_filters_value(db_file, key):
await sqlite.update_filters_value(db_file,
if sqlite.is_filter_key(db_file, key):
await sqlite.update_filter_value(db_file,
[key, val])
else:
await sqlite.set_filters_value(db_file, [key, val])
await sqlite.set_filter_value(db_file, [key, val])
response = ('Rejected keywords\n'
'```\n{}\n```'
.format(val))
@ -435,17 +447,17 @@ async def message(self, message):
response = 'Missing keywords.'
XmppMessage.send_reply(self, message, response)
case _ if message_lowercase.startswith('deny -'):
key = 'filter-' + message_text[:4]
key = message_text[:4]
val = message_text[6:]
if val:
db_file = config.get_pathname_to_database(jid_file)
keywords = await sqlite.get_filters_value(db_file, key)
keywords = sqlite.get_filter_value(db_file, key)
val = await config.remove_from_list(val, keywords)
if await sqlite.get_filters_value(db_file, key):
await sqlite.update_filters_value(db_file,
if sqlite.is_filter_key(db_file, key):
await sqlite.update_filter_value(db_file,
[key, val])
else:
await sqlite.set_filters_value(db_file, [key, val])
await sqlite.set_filter_value(db_file, [key, val])
response = ('Rejected keywords\n'
'```\n{}\n```'
.format(val))
@ -606,11 +618,11 @@ async def message(self, message):
try:
val = int(val)
db_file = config.get_pathname_to_database(jid_file)
if sqlite.get_settings_value(db_file, key):
await sqlite.update_settings_value(db_file,
if sqlite.is_setting_key(db_file, key):
await sqlite.update_setting_value(db_file,
[key, val])
else:
await sqlite.set_settings_value(db_file,
await sqlite.set_setting_value(db_file,
[key, val])
if val == 0: # if not val:
response = 'Summary length limit is disabled.'
@ -628,7 +640,7 @@ async def message(self, message):
# if val:
# names = await initdb(
# jid,
# get_settings_value,
# sqlite.get_setting_value,
# key
# )
# val = await config.add_to_list(
@ -637,7 +649,7 @@ async def message(self, message):
# )
# await initdb(
# jid,
# update_settings_valuevv,
# sqlite.update_setting_valuevv,
# [key, val]
# )
# response = (
@ -651,30 +663,30 @@ async def message(self, message):
db_file = config.get_pathname_to_database(jid_file)
key = 'media'
val = 0
if sqlite.get_settings_value(db_file, key):
await sqlite.update_settings_value(db_file, [key, val])
if sqlite.is_setting_key(db_file, key):
await sqlite.update_setting_value(db_file, [key, val])
else:
await sqlite.set_settings_value(db_file, [key, val])
await sqlite.set_setting_value(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
if sqlite.get_settings_value(db_file, key):
await sqlite.update_settings_value(db_file, [key, val])
if sqlite.is_setting_key(db_file, key):
await sqlite.update_setting_value(db_file, [key, val])
else:
await sqlite.set_settings_value(db_file, [key, val])
await sqlite.set_setting_value(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
if sqlite.get_settings_value(db_file, key):
await sqlite.update_settings_value(db_file, [key, val])
if sqlite.is_setting_key(db_file, key):
await sqlite.update_setting_value(db_file, [key, val])
else:
await sqlite.set_settings_value(db_file, [key, val])
await sqlite.set_setting_value(db_file, [key, val])
response = 'Only new items of newly added feeds will be sent.'
XmppMessage.send_reply(self, message, response)
# TODO Will you add support for number of messages?
@ -694,10 +706,10 @@ async def message(self, message):
db_file = config.get_pathname_to_database(jid_file)
key = 'old'
val = 1
if sqlite.get_settings_value(db_file, key):
await sqlite.update_settings_value(db_file, [key, val])
if sqlite.is_setting_key(db_file, key):
await sqlite.update_setting_value(db_file, [key, val])
else:
await sqlite.set_settings_value(db_file, [key, val])
await sqlite.set_setting_value(db_file, [key, val])
response = 'All items of newly added feeds will be sent.'
XmppMessage.send_reply(self, message, response)
case _ if message_lowercase.startswith('quantum'):
@ -710,11 +722,11 @@ async def message(self, message):
# 'Every update will contain {} news items.'
# ).format(response)
db_file = config.get_pathname_to_database(jid_file)
if sqlite.get_settings_value(db_file, key):
await sqlite.update_settings_value(db_file,
if sqlite.is_setting_key(db_file, key):
await sqlite.update_setting_value(db_file,
[key, val])
else:
await sqlite.set_settings_value(db_file,
await sqlite.set_setting_value(db_file,
[key, val])
response = ('Next update will contain {} news items.'
.format(val))