def matches(bot,message): try: dota_id = df.get_dota_id_from_telegram(message.from_user.id) except: return bot.sendMessage(chat_id=message.chat_id,text='You do not appear to be in the database. Please register with /register') matches = df.findMatches(dota_id) if not matches: logging.error('No results from match requests. WebAPI servers down?') return sendText(bot,message.chat_id,'Request failed. Steam webAPI servers may be down') match_ids = ['#m_' + str(d['match_id']) for d in matches] keyboard = [match_ids[:3],match_ids[4:7]] reply_markup = telegram.ReplyKeyboardMarkup(keyboard,one_time_keyboard=True) bot.sendMessage(chat_id=message.chat_id, text="Choose match:", reply_markup=reply_markup)
def last_match(bot, message, match_id=None): reply_markup = telegram.ReplyKeyboardHide() bot.sendMessage(chat_id=message.chat_id,text=msgs['getmatch'],reply_markup=reply_markup) # sendText(bot,message.chat_id,msgs['getmatch']) if not match_id: try: dota_id = df.get_dota_id_from_telegram(message.from_user.id) except: logging.info('last match info requested by non-registered user,',message.user) return bot.sendMessage(chat_id=message.chat_id,text='You don\'t appear to be in the database. Please register using the /register command') match_id = df.getLastMatch(dota_id) logging.info('Last match request:',dota_id,message.from_user.first_name,dota_id,message.from_user.id) bot.sendMessage(chat_id=message.chat_id, text="[Requested DotaBuff page for match " +str(match_id)+"](http://dotabuff.com/matches/"+str(match_id)+").", parse_mode=telegram.ParseMode.MARKDOWN)