-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Description
Steps to reproduce
Use a handler like:
@deco.global_message_handler(Filters.poll)
def poll_send(u,c):
print("poll sender")
bot:telegram.Bot=c.bot
message:telegram.Message=u.channel_post
pl : telegram.poll = message.poll
print("Right option before", pl.correct_option_id)
poll_dict=pl.to_dict()
poll_dict.pop("options")
options=[op.text for op in pl.options]
print("Right option ", pl.correct_option_id)
callback=lambda chat_id, reply_to_message_id: bot.send_poll(chat_id, options=options ,**poll_dict)
Where @deco.global_message_handler is just:
def global_message_handler(filters, **kwargs):
def wrap_global_message_handler(func):
@wraps(func)
def wrapped (*a, **bb):
log(func)
return func(*a, **bb)
global_dispatchers.append(MessageHandler(filters, wrapped, **kwargs))
return wrapped
return wrap_global_message_handler
And the global_dispatchers are added to a Conversation_handler like this:
conversation_handler = ConversationHandler(
entry_points=deco.entry_points,
states=deco.entry_states,
fallbacks=deco.entry_fallbacks,
name="order",
persistent=True,
allow_reentry=True,
per_user=True,
per_chat=True,
)
The point is I am filtering just polls and pl.correct_option_id is always None for whatever option I set when sending a quiz to this bot, if it is a quiz or poll. I know it is expected for polls to have None there but not quizzes.
Expected behaviour
pl.correct_option_id should return an int when the bot receives a QUIZ type poll.
Actual behaviour
pl.correct_option_id is None for quizzes
Configuration
Operating System: Ubuntu, Arch linux
Version of Python, python-telegram-bot & dependencies:
python-telegram-bot 12.Z8
certifi 2020.06.20
future 0.18.2
Python 3.8.5 (default, Jul 27 2020, 08:42:51) [GCC 10.1.0]
Logs
I am trying to resend the quiz to another channel without forwarding it so I get:
File "/home/bot/channel_mirror_bot/bot.py", line 262, in <lambda>
callback=lambda chat_id, reply_to_message_id: bot.send_poll(chat_id, options=options ,**poll_dict)
File "<decorator-gen-65>", line 2, in send_poll
File "/home/bot/.local/lib/python3.8/site-packages/telegram/bot.py", line 67, in decorator
result = func(*args, **kwargs)
File "/home/bot/.local/lib/python3.8/site-packages/telegram/bot.py", line 3727, in send_poll
return self._message(url, data, timeout=timeout, disable_notification=disable_notification,
File "/home/bot/.local/lib/python3.8/site-packages/telegram/bot.py", line 175, in _message
result = self._request.post(url, data, timeout=timeout)
File "/home/bot/.local/lib/python3.8/site-packages/telegram/utils/request.py", line 330, in post
result = self._request_wrapper('POST', url,
File "/home/bot/.local/lib/python3.8/site-packages/telegram/utils/request.py", line 244, in _request_wrapper
raise BadRequest(message)
telegram.error.BadRequest: Wrong correct option id specified
Because it is None.