Skip to content

Instantly share code, notes, and snippets.

@sh4dowb
Last active June 18, 2020 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sh4dowb/9a2d53c9ca78627f7e176bddf0088584 to your computer and use it in GitHub Desktop.
Save sh4dowb/9a2d53c9ca78627f7e176bddf0088584 to your computer and use it in GitHub Desktop.
telethon capture multiple events - capture button and/or text event
def press_or_text(user_id):
return events.Raw(func=lambda e: (type(e) == UpdateNewMessage and e.message.from_id == user_id) or (type(e) == UpdateBotCallbackQuery and e.user_id == user_id and e.data != b'cancel'))
whatever = await conv.wait_event(press_or_text(sender))
if type(whatever) == UpdateBotCallbackQuery and whatever.data in [b'create', b'list']:
# button clicked
# not actual event like "CallbackQuery", you can't use .edit() etc. directly
print(whatever.data)
else:
# message sent
print(whatever.message.message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment