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)
|
# Maximum length of summary (Value 0 to disable)
|
||||||
length = 300
|
length = 300
|
||||||
|
|
||||||
|
# Display media (audio, image, video) when available
|
||||||
|
media = 0
|
||||||
|
|
||||||
# Mark entries of newly added entries as unread
|
# Mark entries of newly added entries as unread
|
||||||
old = 0
|
old = 0
|
||||||
|
|
||||||
|
|
|
@ -198,6 +198,7 @@ async def xmpp_send_update(self, jid, num=None):
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_file)
|
||||||
enabled = await config.get_setting_value(db_file, 'enabled')
|
enabled = await config.get_setting_value(db_file, 'enabled')
|
||||||
if enabled:
|
if enabled:
|
||||||
|
show_media = await config.get_setting_value(db_file, 'media')
|
||||||
if not num:
|
if not num:
|
||||||
num = await config.get_setting_value(db_file, 'quantum')
|
num = await config.get_setting_value(db_file, 'quantum')
|
||||||
else:
|
else:
|
||||||
|
@ -227,10 +228,11 @@ async def xmpp_send_update(self, jid, num=None):
|
||||||
# elif enclosure.startswith("magnet:"):
|
# elif enclosure.startswith("magnet:"):
|
||||||
# media = action.get_magnet(enclosure)
|
# media = action.get_magnet(enclosure)
|
||||||
# elif enclosure:
|
# elif enclosure:
|
||||||
if enclosure:
|
if show_media:
|
||||||
media = enclosure
|
if enclosure:
|
||||||
else:
|
media = enclosure
|
||||||
media = await action.extract_image_from_html(url)
|
else:
|
||||||
|
media = await action.extract_image_from_html(url)
|
||||||
|
|
||||||
if media and news_digest:
|
if media and news_digest:
|
||||||
# Send textual message
|
# Send textual message
|
||||||
|
|
|
@ -615,6 +615,26 @@ async def message(self, message):
|
||||||
# else:
|
# else:
|
||||||
# response = 'Missing value.'
|
# response = 'Missing value.'
|
||||||
XmppMessage.send_reply(self, message, response)
|
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':
|
case 'new':
|
||||||
db_file = config.get_pathname_to_database(jid_file)
|
db_file = config.get_pathname_to_database(jid_file)
|
||||||
key = 'old'
|
key = 'old'
|
||||||
|
|
|
@ -57,7 +57,7 @@ async def get_chat_type(self, jid):
|
||||||
'Jabber ID: {}'
|
'Jabber ID: {}'
|
||||||
.format(e, jid))
|
.format(e, jid))
|
||||||
logging.error(message)
|
logging.error(message)
|
||||||
except BaseException as e:
|
# except BaseException as e:
|
||||||
logging.error('BaseException', str(e))
|
# logging.error('BaseException', str(e))
|
||||||
finally:
|
# finally:
|
||||||
logging.info('Chat type is:', chat_type)
|
# logging.info('Chat type is:', chat_type)
|
||||||
|
|
Loading…
Reference in a new issue