raiwalletbot.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:RaiWalletBot 作者: SergiySW 项目源码 文件源码
def restricted(func):
    @wraps(func)
    def wrapped(bot, update, *args, **kwargs):
        # extract user_id from arbitrary update
        try:
            user_id = update.message.from_user.id
        except (NameError, AttributeError):
            try:
                user_id = update.inline_query.from_user.id
            except (NameError, AttributeError):
                try:
                    user_id = update.chosen_inline_result.from_user.id
                except (NameError, AttributeError):
                    try:
                        user_id = update.callback_query.from_user.id
                    except (NameError, AttributeError):
                        print("No user_id available in update.")
                        return
        if user_id not in admin_list:
            print("Unauthorized access denied for {0}.".format(user_id))
            return
        return func(bot, update, *args, **kwargs)
    return wrapped


# Define a few command handlers. These usually take the two arguments bot and
# update. Error handlers also receive the raised TelegramError object in error.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号