Add switch for media
This commit is contained in:
parent
b748170e25
commit
065311d0d8
4 changed files with 33 additions and 8 deletions
|
@ -24,6 +24,9 @@ interval = 300
|
|||
# Maximum length of summary (Value 0 to disable)
|
||||
length = 300
|
||||
|
||||
# Display media (audio, image, video) when available
|
||||
media = 0
|
||||
|
||||
# Mark entries of newly added entries as unread
|
||||
old = 0
|
||||
|
||||
|
|
|
@ -198,6 +198,7 @@ async def xmpp_send_update(self, jid, num=None):
|
|||
db_file = config.get_pathname_to_database(jid_file)
|
||||
enabled = await config.get_setting_value(db_file, 'enabled')
|
||||
if enabled:
|
||||
show_media = await config.get_setting_value(db_file, 'media')
|
||||
if not num:
|
||||
num = await config.get_setting_value(db_file, 'quantum')
|
||||
else:
|
||||
|
@ -227,6 +228,7 @@ async def xmpp_send_update(self, jid, num=None):
|
|||
# elif enclosure.startswith("magnet:"):
|
||||
# media = action.get_magnet(enclosure)
|
||||
# elif enclosure:
|
||||
if show_media:
|
||||
if enclosure:
|
||||
media = enclosure
|
||||
else:
|
||||
|
|
|
@ -615,6 +615,26 @@ async def message(self, message):
|
|||
# else:
|
||||
# response = 'Missing value.'
|
||||
XmppMessage.send_reply(self, message, response)
|
||||
case 'media off':
|
||||
db_file = config.get_pathname_to_database(jid_file)
|
||||
key = 'media'
|
||||
val = 0
|
||||
if await sqlite.get_settings_value(db_file, key):
|
||||
await sqlite.update_settings_value(db_file, [key, val])
|
||||
else:
|
||||
await sqlite.set_settings_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 await sqlite.get_settings_value(db_file, key):
|
||||
await sqlite.update_settings_value(db_file, [key, val])
|
||||
else:
|
||||
await sqlite.set_settings_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'
|
||||
|
|
|
@ -57,7 +57,7 @@ async def get_chat_type(self, jid):
|
|||
'Jabber ID: {}'
|
||||
.format(e, jid))
|
||||
logging.error(message)
|
||||
except BaseException as e:
|
||||
logging.error('BaseException', str(e))
|
||||
finally:
|
||||
logging.info('Chat type is:', chat_type)
|
||||
# except BaseException as e:
|
||||
# logging.error('BaseException', str(e))
|
||||
# finally:
|
||||
# logging.info('Chat type is:', chat_type)
|
||||
|
|
Loading…
Reference in a new issue