Skip to content

Commit

Permalink
Fix #1366: _trigger_timeout() missing 1 required positional argument:…
Browse files Browse the repository at this point in the history
… 'job' (#1367)

* Fix #1366: _trigger_timeout() missing 1 required positional argument: 'job'

* Add comments
  • Loading branch information
loozhengyuan authored and jsmnbom committed Apr 5, 2019
1 parent 7944805 commit 2ed4cbd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ The following wonderful people contributed directly or indirectly to this projec
- `Kirill Vasin <https://github.com/vasinkd>`_
- `Kjwon15 <https://github.com/kjwon15>`_
- `Li-aung Yip <https://github.com/LiaungYip>`_
- `Loo Zheng Yuan <https://github.com/loozhengyuan>`_
- `macrojames <https://github.com/macrojames>`_
- `Michael Elovskikh <https://github.com/wronglink>`_
- `Mischa Krüger <https://github.com/Makman2>`_
Expand Down
19 changes: 13 additions & 6 deletions telegram/ext/conversationhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from telegram import Update
from telegram.ext import (Handler, CallbackQueryHandler, InlineQueryHandler,
ChosenInlineResultHandler)
ChosenInlineResultHandler, CallbackContext)
from telegram.utils.promise import Promise


Expand Down Expand Up @@ -354,12 +354,19 @@ def update_state(self, new_state, key):
if self.persistent:
self.persistence.update_conversation(self.name, key, new_state)

def _trigger_timeout(self, bot, job):
def _trigger_timeout(self, context, job=None):
self.logger.debug('conversation timeout was triggered!')
del self.timeout_jobs[job.context.conversation_key]

# Backward compatibility with bots that do not use CallbackContext
if isinstance(context, CallbackContext):
context = context.job.context
else:
context = job.context

del self.timeout_jobs[context.conversation_key]
handlers = self.states.get(self.TIMEOUT, [])
for handler in handlers:
check = handler.check_update(job.context.update)
check = handler.check_update(context.update)
if check is not None and check is not False:
handler.handle_update(job.context.update, job.context.dispatcher, check)
self.update_state(self.END, job.context.conversation_key)
handler.handle_update(context.update, context.dispatcher, check)
self.update_state(self.END, context.conversation_key)

0 comments on commit 2ed4cbd

Please sign in to comment.