home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.65k stars 29.94k forks source link

Parsing telegram_command payload does not work for channels #31363

Closed Tooa closed 4 years ago

Tooa commented 4 years ago

The problem

When posting commands such as /command1 to a Telegram channel containing a chat bot, the payload of the telegram_command causes a parsing error.

Environment

Problem-relevant configuration.yaml

# configuration.yml
telegram_bot:
  - platform: polling
    api_key: !secret telegram_bot
    allowed_chat_ids: 
      - <channel_id>

notify:
  - name: telegram
    platform: telegram
    chat_id: <channel_id>

# automation

- alias: 'Telegram sample automation'
  hide_entity: true
  trigger:
    - platform: event
      event_type: telegram_command
      event_data:
        command: '/command1'
  action:
    - service: notify.telegram
      data:
        message: 'a message'

Traceback/Error logs

Message with unknown data received: {'update_id': 1234, 'channel_post': {'message_id': 4, 'date': 1580510620, 'chat': {'id': <channel_id>, 'type': 'channel', 'title': 'ChannelName'}, 'text': '/command1', 'entities': [{'type': 'bot_command', 'offset': 0, 'length': 8}], 'caption_entities': [], 'photo': [], 'new_chat_members': [], 'new_chat_photo': [], 'delete_chat_photo': False, 'group_chat_created': False, 'supergroup_chat_created': False, 'channel_chat_created': False, 'author_signature': 'User User'}}

Additional information

pattyland commented 4 years ago

I would like to increase the priority here, my bot was apparently added in several foreign channels.

According to the API documentation, I can't block people etc. from the bot, and my homeassistant log is now full of the Message with unknown data received error messages

stale[bot] commented 4 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

leibnizman commented 3 years ago

This issue is still present in core-2021.5.1.

Having channels supported could be really useful, because this allows bot to bot communication. I want to use this as a workaround for the lacking iOS shortcuts telegram integration.

Message with unknown data received: {'update_id': xxx, 'channel_post': {'message_id': 19, 'sender_chat': {'id': -xxx, 'type': 'channel', 'title': 'xxx'}, 'date': 1620446845, 'chat': {'id': -xxx, 'type': 'channel', 'title': 'channel'}, 'text': 'test', 'entities': [], 'caption_entities': [], 'photo': [], 'new_chat_members': [], 'new_chat_photo': [], 'delete_chat_photo': False, 'group_chat_created': False, 'supergroup_chat_created': False, 'channel_chat_created': False}}