Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--telegram-chat can't handle negative sender_chat id values #16

Closed
buzzeddesign opened this issue Aug 13, 2021 · 7 comments
Closed

--telegram-chat can't handle negative sender_chat id values #16

buzzeddesign opened this issue Aug 13, 2021 · 7 comments
Labels
documentation Improvements or additions to documentation

Comments

@buzzeddesign
Copy link

Same issue as described here in urlwatch: thp/urlwatch#622 (comment)

Listing chats when the Telegram Bot is a participant in a channel results in web changes and urlwatch bombing out due tot eh channel chat id being a negative number.

Likewise, when trying the telegram reporter, the telegram report to the channel identified by a negative chat ID fails.

@mborsetti
Copy link
Owner

mborsetti commented Aug 13, 2021

Hi Sean,

Thanks for the report!

I am trying to track down where the issue lies, but am getting confused. Would you be so kind to run webchanges --verbose --test-reporters telegram and post the results (please manually obfuscate the values of bot_token and chat_id from the error message)?

Thanks.

@buzzeddesign
Copy link
Author

buzzeddesign commented Aug 13, 2021 via email

@mborsetti
Copy link
Owner

Hi Steve,

The error comes back from Telegram as a response to calling its API 'https://api.telegram.org/bot{bot_token}/sendMessage' to send the message. This API is documented at https://core.telegram.org/bots/api#sendmessage, and while there's nothing in there specific to negative chat_ids, it does say that such ID is the "Unique identifier for the target chat or username of the target channel (in the format @channelusername). So you may want to try using the @channelusername (if available, I don't use Telegram so wouldn't know) to see if that works, otherwise I really wouldn't know as it's a Telegram issue.

@mborsetti
Copy link
Owner

mborsetti commented Aug 13, 2021

BTW, it appears that you also need to "initialize" the group otherwise the API does not recognize it; send a message to the group so that the group has at least 1 message.

@buzzeddesign
Copy link
Author

buzzeddesign commented Aug 13, 2021

while there's nothing in there specific to negative chat_ids, it does say that such ID is the "Unique identifier for the target chat or username of the target channel (in the format @channelusername). So you may want to try using the @channelusername (if available, I don't use Telegram so wouldn't know) to see if that works

That did it!! Brilliant! Thanks :)

In webchanges --edit-config, if the intended target is a channel and the bot is admin of the channel, then the chat id should be @channelusername, like this:

  telegram:
    bot_token: '1234567890:iuasdhoaihofgojsdfoifasofsoiabsfoi'
    chat_id:
      - '0987654321'
      - '@channelusername'

@mborsetti
Copy link
Owner

Happy it worked out. Will update the documentation based on your input; thanks!

@mborsetti mborsetti added the documentation Improvements or additions to documentation label Aug 13, 2021
@mborsetti mborsetti reopened this Aug 13, 2021
@mborsetti
Copy link
Owner

I just released v3.8.2, whose documentation addresses this very user case here (yes, just noticed a typo in the link there...damn gremlins!)

Thanks so much for opening an issue; very much appreciated! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants