Skip to content

[QUESTION]: PollAnswerHandler in ConversationHandler with per_chat = True #2338

@lucasfldmn

Description

@lucasfldmn

Issue I am facing

The callback for a PollAnswerHandler that in integration within a ConversationHandler is never executed. Thus, it is impossible to check poll results within an active Conversation and make changes to the conversation state based in the poll results.

Traceback to the issue

The sourcecode for the check_update function in the ConversationHandler (link) revealed the following:

if self.per_chat and not update.effective_chat:
   return None

An update for a poll answer looks like this

telegram.ext.dispatcher - DEBUG - Processing Update: {'update_id': 77252507, 'poll_answer': {'poll_id': '5224265113522929685', 'user': {'id': 1297725373, 'first_name': 'All3', 'is_bot': False, 'last_name': 'Uos', 'username': 'alluos3', 'language_code': 'de'}, 'option_ids': [0]}}

As you can see, this update contains no effective_chat and therefore the PollAnswerHandler can not be used within a ConversationHandler. This seems very counterintuitive as the ConversationHandler kind of promises to work with every other type of handler.

Related part of your code

room_manager_conv_handler = ConversationHandler(
    entry_points=[
        CommandHandler('start', room.start_escape, filters=Filters.chat_type.groups)
    ],
    states={
        state.WAIT_FOR_USERS_TO_BE_READY: [
            MessageHandler(filter_ready, room.evaluate_readiness),             
        ],
        state.WAIT_FOR_PATH_SEL: [
            MessageHandler(filter_paths, room.save_path)
        ],
        state.WAIT_FOR_TASK_SELECTION: [
            sentence_corr_conv_handler,
            vocab_desc_conv_handler,
            discussion_conv_handler      
        ],       
        state.WAIT_FOR_PASSCODE: [
            MessageHandler(None, room.check_passcode)
        ],
        state.WAIT_FOR_RESTART_POLL: [            
            PollAnswerHandler(room.handle_poll_updates),
        ]
    },
    fallbacks=[
        CommandHandler('stop', room.stop_group, filters=Filters.chat_type.groups)
    ],
    per_user=False
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions