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
Comments
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 Thanks. |
Hi Mike,
Sure! Here’s the output:
% webchanges --verbose --test-reporter telegram
2021-08-12 18:29:34,291 cli DEBUG: webchanges: 3.8.1 Copyright 2020- Mike Borsetti
2021-08-12 18:29:34,291 cli DEBUG: Python: ('default', 'Jun 19 2021 00:24:55')
2021-08-12 18:29:34,300 cli DEBUG: System: macOS-11.4-arm64-arm-64bit
2021-08-12 18:29:34,307 storage DEBUG: sqlite3.version=2.6.0, sqlite3.sqlite_version=3.36.0
2021-08-12 18:29:34,307 storage INFO: Opening permanent sqlite3 database file /Users/sean/Library/Caches/webchanges/cache.db
2021-08-12 18:29:34,307 storage DEBUG: Executing (perm) 'SELECT name FROM sqlite_master WHERE type='table';'
2021-08-12 18:29:34,307 storage DEBUG: Creating temp sqlite3 database file in memory
2021-08-12 18:29:34,307 storage DEBUG: Executing (temp) 'CREATE TABLE webchanges (uuid TEXT, timestamp REAL, msgpack_data BLOB)'
2021-08-12 18:29:34,307 main INFO: Config file is /Users/sean/Library/Preferences/webchanges/config.yaml
2021-08-12 18:29:34,307 main INFO: Jobs file is /Users/sean/Library/Preferences/webchanges/jobs.yaml
2021-08-12 18:29:34,307 main INFO: Hooks file is /Users/sean/Library/Preferences/webchanges/hooks.py
2021-08-12 18:29:34,307 main INFO: Database file is /Users/sean/Library/Caches/webchanges/cache.db
2021-08-12 18:29:34,339 main INFO: Found 37 jobs
2021-08-12 18:29:34,339 handler DEBUG: Job 0: Got exception while processing job <url url='http://example.com/error'; index_number=0 name='Error Reporting'
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/webchanges/command.py", line 369, in set_error
raise ValueError(message)
ValueError: Oh Noes!
2021-08-12 18:29:34,339 reporters INFO: Sending telegram message to chat id: '-##########'
2021-08-12 18:29:34,345 connectionpool DEBUG: Starting new HTTPS connection (1): api.telegram.org:443
2021-08-12 18:29:34,932 connectionpool DEBUG: https://api.telegram.org:443 "POST /botxxxxxxxx:Xxxxxxxxxxxxxxx/sendMessage HTTP/1.1" 400 73
Traceback (most recent call last):
File "/opt/homebrew/Caskroom/miniforge/base/bin/webchanges", line 8, in <module>
sys.exit(main())
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/webchanges/cli.py", line 231, in main
urlwatch_command.run()
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/webchanges/command.py", line 538, in run
self.check_test_reporter()
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/webchanges/command.py", line 390, in check_test_reporter
report.finish_one(name)
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/webchanges/handler.py", line 384, in finish_one
ReporterBase.submit_one(name, self, self.job_states, duration, check_enabled)
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/webchanges/reporters.py", line 139, in submit_one
subclass(report, cfg, job_states, duration).submit()
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/webchanges/reporters.py", line 1019, in submit
self.submit_to_telegram(bot_token, chat_id, chunk)
File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.9/site-packages/webchanges/reporters.py", line 1040, in submit_to_telegram
raise RuntimeError(f"Telegram error: {json_res['description']}")
RuntimeError: Telegram error: Bad Request: chat not found
…On Aug 12, 2021, 6:20 PM -0700, Mike Borsetti ***@***.***>, wrote:
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_it from the error message)?
Thanks.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
|
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 |
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. |
That did it!! Brilliant! Thanks :) In
|
Happy it worked out. Will update the documentation based on your input; thanks! |
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! 🎉 |
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.
The text was updated successfully, but these errors were encountered: