def command_day(update, context):
    uid_hash = encrypt.blake2b_hash(str(update.message.from_user.id))
    if sql._sql_check_uid(uid_hash) != 1:
        return
    config.expire_date_unit_select_dict[uid_hash] = 'day'
    config.command_expire_list.append(uid_hash)
    text = 'How long does it take to expire (<b>day</b>)?'
    update.message.reply_text(text=text, parse_mode=ParseMode.HTML)
def command_keygen(update, context):
    '''Generate the new key for user.
    '''

    uid = update.message.from_user.id
    uid_hash = encrypt.blake2b_hash(str(uid))
    if sql._sql_check_uid(uid_hash) != 1:
        return

    uid_hash_list = list()
    uid_hash_list.append(uid_hash)

    if config.keygen_confirm_dict.__contains__(uid_hash):
        if config.keygen_confirm_dict[uid_hash] == False:
            config.keygen_confirm_dict[uid_hash] = True
            config.keygen_confirm_dict.pop(uid_hash)
            config.command_expire_list.remove(uid_hash)

            asymmetric_key_dict = encrypt.asymmetric_key_generate()
            private_key_hex = encrypt.convert_bytes_to_str(
                asymmetric_key_dict['private_key'])
            public_key_hex = encrypt.convert_bytes_to_str(
                asymmetric_key_dict['public_key'])

            if sql.sql_update_expired_public_key(uid_hash_list,
                                                 public_key_hex) == -1:
                text = 'Update asymmetric key failed.'
                update.message.reply_text(text=text, parse_mode=ParseMode.HTML)
                return

            text = (
                'Generate success, this is your new <b>Asymmetric Secret Key</b>. %s'
                'The database will be updated automatically. '
                'Similarly, we will not store this key, so please keep it safe.'
            ) % (config.GOOD_EXPRESSION)
            update.message.reply_text(text=text, parse_mode=ParseMode.HTML)
            text = '<b>%s</b>' % private_key_hex
            update.message.reply_text(text=text, parse_mode=ParseMode.HTML)
    else:
        text = (
            'Please confirm if you need to really regenerate <b>Asymmetric Key</b>. '
            'If you regenerate the key, the old chat message no longer supports decryption reading.'
            'But we also <b>recommend</b> that you reset this key periodically to avoid exhaustive attacks.'
            'After all, there are quantum computers now.'
            'If you confirm to regenerate this key, click /keygen button <b>again</b>.'
        )
        # False mean that the program will waiting for the user confirmation.
        config.keygen_confirm_dict[uid_hash] = False
        config.command_expire_list.append(uid_hash)
        update.message.reply_text(text=text, parse_mode=ParseMode.HTML)