bot.py 文件源码

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

项目:heydjbot 作者: mongonauta 项目源码 文件源码
def save_classification(bot, update):
    user = update.message.from_user
    logger.info('save_classification(%s) %s - %s' % (user, bot.song_cache, update.message.text))

    resp = requests.get(
        url='{}/user_info/{}/'.format(API_SERVER, user.id)
    )

    if not resp.json():
        update.message.reply_text(
            'Sorry {}, but I can\'t do that. Please, use "connect" command'.format(user['first_name'])
        )

    else:
        resp = requests.get(
            url='{}/classify/{}/{}'.format(
                API_SERVER,
                bot.song_cache[0],
                ACTIVITY_KEYBOARD[0].index(update.message.text)
            )
        )

        result = resp.json()
        resp = requests.get(
            url='{}/stats/{}/'.format(
                API_SERVER,
                user.id
            )
        )
        result['total'] = resp.json()['total']
        result['classified'] = resp.json()['classified']

        update.message.reply_text(
            'Result: %s \n\n Statistics:\n %s' % (result, resp.json()),
            reply_markup=ReplyKeyboardMarkup([[NAVIGATION_KEYBOARD[1]]], one_time_keyboard=True, resize_keyboard=True)
        )
    return SAVE_SONG
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号