diff --git a/tgbot/handlers/utils/info.py b/tgbot/handlers/utils/info.py index 0d13021..8bd156f 100644 --- a/tgbot/handlers/utils/info.py +++ b/tgbot/handlers/utils/info.py @@ -17,18 +17,7 @@ def command_func(update, context, *args, **kwargs): def extract_user_data_from_update(update: Update) -> Dict: """ python-telegram-bot's Update instance --> User info """ - if update.message is not None: - user = update.message.from_user.to_dict() - elif update.inline_query is not None: - user = update.inline_query.from_user.to_dict() - elif update.chosen_inline_result is not None: - user = update.chosen_inline_result.from_user.to_dict() - elif update.callback_query is not None and update.callback_query.from_user is not None: - user = update.callback_query.from_user.to_dict() - elif update.callback_query is not None and update.callback_query.message is not None: - user = update.callback_query.message.chat.to_dict() - else: - raise Exception(f"Can't extract user data from update: {update}") + user = update.effective_user.to_dict() return dict( user_id=user["id"], @@ -38,4 +27,4 @@ def extract_user_data_from_update(update: Update) -> Dict: for k in ["username", "first_name", "last_name", "language_code"] if k in user and user[k] is not None }, - ) \ No newline at end of file + )