Skip to content

Commit ab2d6eb

Browse files
committed
Fix "key not found" exception if the very first message handler in a ConversationHandler returns the state ConversationHandler.END.
1 parent 00bba73 commit ab2d6eb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

telegram/ext/conversationhandler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ def handle_update(self, update, dispatcher):
213213

214214
def update_state(self, new_state, key):
215215
if new_state == self.END:
216-
del self.conversations[key]
216+
if key in self.conversations:
217+
del self.conversations[key]
217218

218219
elif isinstance(new_state, Promise):
219220
self.conversations[key] = (self.conversations[key], new_state)

0 commit comments

Comments
 (0)