raiwalletbot.py 文件源码

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

项目:RaiWalletBot 作者: SergiySW 项目源码 文件源码
def password_callback(bot, update, args):
    user_id = update.message.from_user.id
    chat_id = update.message.chat_id
    if (len(args) > 0):
        check = mysql_check_password(user_id)
        if (check is False):
            if (len(args[0]) >= 8):
                password = args[0]
                if ((len(set(string.digits).intersection(password)) > 0) and (len(set(string.ascii_uppercase).intersection(password))> 0) and (len(set(string.ascii_lowercase).intersection(password)) > 0)):
                    try:
                        dk = hashlib.pbkdf2_hmac('sha256', password, salt, 112000)
                        hex = binascii.hexlify(dk)
                        mysql_set_password(user_id, hex)
                        message_markdown(bot, chat_id, lang(user_id, 'password_success'))
                        logging.info('Password added for user {0}'.format(user_id))
                    except UnicodeEncodeError:
                        text_reply(update, lang(user_id, 'password_uppercase'))
                        logging.info('Password set failed for user {0}. Reason: Unicode symbol'.format(user_id))
                else:
                    text_reply(update, lang(user_id, 'password_uppercase'))
                    logging.info('Password set failed for user {0}. Reason: uppercase-lowercase-digits'.format(user_id))
            else:
                text_reply(update, lang(user_id, 'password_short'))
                logging.info('Password set failed for user {0}. Reason: Too short'.format(user_id))
        else:
            text_reply(update, lang(user_id, 'password_not_empty'))
            logging.info('Password set failed for user {0}. Reason: Already protected'.format(user_id))
    else:
        text_reply(update, lang(user_id, 'password_command'))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号