def train(bot, update):
user = update.message.from_user
logger.info('show_song_to_clasify %s' % user)
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='{}/train/{}/'.format(API_SERVER, user.id)
)
song = resp.json()['song'] if 'song' in resp.json() else None
if song:
bot.song_cache = song
update.message.reply_text(
u"""
Choose one activity for this song:\n\n
Title: {}\n
Artist: {}\n
Album: {}\n
""".format(song[1], song[4], song[2]),
reply_markup=ReplyKeyboardMarkup(ACTIVITY_KEYBOARD, one_time_keyboard=True, resize_keyboard=True)
)
else:
update.message.reply_text("Server error. %s" % resp.json())
return SAVE_SONG
评论列表
文章目录