Last active
June 18, 2020 07:21
-
-
Save sh4dowb/9a2d53c9ca78627f7e176bddf0088584 to your computer and use it in GitHub Desktop.
telethon capture multiple events - capture button and/or text event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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