Skip to content

Add support for Telegram disable_web_page_preview option#2223

Merged
cvium merged 2 commits intoFlexget:developfrom
Endemoniada:feature/telegram-disable-preview
Oct 15, 2018
Merged

Add support for Telegram disable_web_page_preview option#2223
cvium merged 2 commits intoFlexget:developfrom
Endemoniada:feature/telegram-disable-preview

Conversation

@Endemoniada
Copy link
Copy Markdown
Contributor

@Endemoniada Endemoniada commented Oct 11, 2018

Motivation for changes:

A message or message template can include links, but the user may want to disable the webpage preview feature to minimize message length.

Detailed changes:

  • Adds option to disable webpage preview in config file. Default is still disable = False.

Config usage if relevant (new plugin or updated schema):

            telegram:
              bot_token: token
              use_markdown: yes
              disable_previews: yes
              recipients:
                - username: my-user-name
                - group: my-group-name
                - fullname:
                    first: my-first-name
                    sur: my-sur-name

Log and/or tests output (preferably both):

2018-10-14 11:38 DEBUG    notify        telegram-test   Sending a notification to `telegram`
2018-10-14 11:38 DEBUG    telegram      telegram-test   token=xxxxxxxxxx, parse_mode=markdown, disable_previews=True, usernames=[u'xxxxxxxxxx'], fullnames=[], groups=[]
2018-10-14 11:38 DEBUG    telegram.bot  telegram-test   Entering: get_me
2018-10-14 11:38 DEBUG    telegram.vendor.ptb_urllib3.urllib3.connectionpool telegram-test   Starting new HTTPS connection (1): api.telegram.org
2018-10-14 11:38 DEBUG    telegram.vendor.ptb_urllib3.urllib3.connectionpool telegram-test   https://api.telegram.org:443 "GET /botxxxxxxxxxx/getMe HTTP/1.1" 200 111
2018-10-14 11:38 DEBUG    telegram.bot  telegram-test   {'username': u'xxxxxxxxxx', 'first_name': u"xxxxxxxxxx", 'is_bot': True, 'id': xxxxxxxxxx}
2018-10-14 11:38 DEBUG    telegram.bot  telegram-test   Exiting: get_me
2018-10-14 11:38 DEBUG    telegram      telegram-test   loading cached chat ids
2018-10-14 11:38 DEBUG    telegram      telegram-test   found 1 cached chat_ids: [u'id=xxxxxxxxxx username=xxxxxxxxxx firstname=xxxxxxxxxx surname=xxxxxxxxxx']
2018-10-14 11:38 DEBUG    telegram      telegram-test   all chat ids found in cache
2018-10-14 11:38 DEBUG    telegram      telegram-test   chat_ids=[<flexget.plugins.notifiers.telegram.ChatIdEntry object at 0x10f462610>]
2018-10-14 11:38 DEBUG    telegram      telegram-test   sending msg to telegram servers: _Downloading:_

📽  [Skyscraper](https://www.imdb.com/title/tt5758778/) (2018)
FBI Hostage Rescue Team leader and U.S. war veteran Will Sawyer now assesses security for skyscrapers. On assignment in Hong Kong he finds the tallest, safest building in the world suddenly ablaze and he's been framed for it. A wanted man on the run, Will must find those responsible, clear his name and somehow rescue his family who are trapped inside the building - above the fire line.
(_5.9/10 - 46430 votes_)


2018-10-14 11:38 DEBUG    telegram.bot  telegram-test   Entering: send_message
2018-10-14 11:38 DEBUG    telegram.vendor.ptb_urllib3.urllib3.connectionpool telegram-test   https://api.telegram.org:443 "POST /botxxxxxxxxxx/sendMessage HTTP/1.1" 200 919
2018-10-14 11:38 DEBUG    telegram.bot  telegram-test   {'delete_chat_photo': False, 'new_chat_photo': [], 'from': {'username': u'xxxxxxxxxx', 'first_name': u"xxxxxxxxxx", 'is_bot': True, 'id': xxxxxxxxxx}, 'text': u"Downloading:\n\n\U0001f4fd  Skyscraper (2018)\nFBI Hostage Rescue Team leader and U.S. war veteran Will Sawyer now assesses security for skyscrapers. On assignment in Hong Kong he finds the tallest, safest building in the world suddenly ablaze and he's been framed for it. A wanted man on the run, Will must find those responsible, clear his name and somehow rescue his family who are trapped inside the building - above the fire line.\n(5.9/10 - 46430 votes)", 'caption_entities': [], 'entities': [{'length': 12, 'type': u'italic', 'offset': 0}, {'url': u'https://www.imdb.com/title/tt5758778/', 'length': 10, 'type': u'text_link', 'offset': 18}, {'length': 20, 'type': u'italic', 'offset': 426}], 'channel_chat_created': False, 'new_chat_members': [], 'supergroup_chat_created': False, 'chat': {'username': u'xxxxxxxxxx', 'first_name': u'xxxxxxxxxx', 'last_name': u'xxxxxxxxxx', 'type': u'private', 'id': xxxxxxxxxx}, 'photo': [], 'date': 1539509869, 'group_chat_created': False, 'message_id': xxxxxxxxxx}
2018-10-14 11:38 DEBUG    telegram.bot  telegram-test   Exiting: send_message
2018-10-14 11:38 VERBOSE  notify        telegram-test   Successfully sent a notification to `telegram`

To Do:

  • Test new configuration parameter
  • Test messages

@Endemoniada Endemoniada force-pushed the feature/telegram-disable-preview branch from 3cd7740 to c5bfabb Compare October 13, 2018 18:24
@Endemoniada Endemoniada changed the title [WIP] Add support for Telegram disable_web_page_preview option Add support for Telegram disable_web_page_preview option Oct 14, 2018
@cvium cvium merged commit 9e33ae1 into Flexget:develop Oct 15, 2018
@Endemoniada Endemoniada deleted the feature/telegram-disable-preview branch October 15, 2018 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants