Skip to content

Instantly share code, notes, and snippets.

@sh4dowb sh4dowb/multipleevent.py

Last active Jun 18, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.