You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello dear telebot team and thank you for your client library
I was just fiddling with middlewares when I found out that I had problems setting up middlewares
wsgi: fastapi (without async and with bot set to threaded=False)
tunnelling: ngrok
The error is:
Traceback (most recent call last):
File "/Users/user/tgbots/aws_rebooter/api/src/main.py", line 50, in <module>
@bot.middleware_handler(update_types=['message'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/user/tgbots/aws_rebooter/api/venv/lib/python3.11/site-packages/telebot/__init__.py", line 6389, in decorator
self.add_middleware_handler(handler, update_types)
File "/Users/user/tgbots/aws_rebooter/api/venv/lib/python3.11/site-packages/telebot/__init__.py", line 6413, in add_middleware_handler
if update_types and self.typed_middleware_handlers:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TeleBot' object has no attribute 'typed_middleware_handlers'. Did you mean: 'add_middleware_handler'?
make: *** [all] Error 1
The ports match, bot token is valid, ngrok tunnel is secure, the curl request for setWebhook returns 200 OK.
Without middlewares, bot commands work perfectly fine
Function middlewares work ok only if I use infinite_polling on my bot
I also tried using class middlewares, but using them with webhooks yielded some nasty event loop errors (even though the wsgi app and the bot appeared to work synchronously)
I've also tried switching wsgi to Flask, thinking it was something wrong with async operations, but I only encountered different errors regarding the setWebhook method. For illustrative purposes, I decided to use session.py example from the repo, adding the Flask code to it to check the functioning of the middlewares
It gave 'Too many requests to Telegram API' error, although a simple curl request to the setWebhook endpoint with same parameters was working fine (supposedly some unsanctioned retry loop working behind the scenes of apihelper). Also, with Flask I encountered lots of 422 Unprocessable Entity errors
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello dear telebot team and thank you for your client library
I was just fiddling with middlewares when I found out that I had problems setting up middlewares
wsgi: fastapi (without async and with bot set to threaded=False)
tunnelling: ngrok
The error is:
The ports match, bot token is valid, ngrok tunnel is secure, the curl request for setWebhook returns 200 OK.
Without middlewares, bot commands work perfectly fine
Function middlewares work ok only if I use infinite_polling on my bot
I also tried using class middlewares, but using them with webhooks yielded some nasty event loop errors (even though the wsgi app and the bot appeared to work synchronously)
I've also tried switching wsgi to Flask, thinking it was something wrong with async operations, but I only encountered different errors regarding the setWebhook method. For illustrative purposes, I decided to use session.py example from the repo, adding the Flask code to it to check the functioning of the middlewares
It gave 'Too many requests to Telegram API' error, although a simple curl request to the setWebhook endpoint with same parameters was working fine (supposedly some unsanctioned retry loop working behind the scenes of apihelper). Also, with Flask I encountered lots of 422 Unprocessable Entity errors
Has somebody encountered this?
Beta Was this translation helpful? Give feedback.
All reactions