import pubg_lablab from uuid import uuid4 from telegram.ext import MessageHandler, Filters, Updater, InlineQueryHandler from telegram import InlineQueryResultArticle, InputTextMessageContent, ParseMode bg = pubg_lablab.Battlegrounds('Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI1NzdjYzFlMC1jM2UwLTAxMzYtOWJiZS02YjYxOGIyZjU5NzQiLCJpc3MiOiJnYW1lbG9ja2VyIiwiaWF0IjoxNTQxNTAxNzA1LCJwdWIiOiJibHVlaG9sZSIsInRpdGxlIjoicHViZyIsImFwcCI6InB1YmdfdGVsZWdyYW0ifQ.yANNOqbPTDA0aBxMvriJ35c6Fg2b2g7JC9esndsXKOg', 'pc_eu') def bot_query(bot, update): query = update.inline_query.query print(query) allowed_users = ['Vogelstrauss', 'tsi_tsi', 'Ceelbee', 'Konfusio'] if query in allowed_users: squad_lifetime_stats = bg.lifetime(bg.player(query).id).squad out = query + " (Rounds: " + str(squad_lifetime_stats.roundsPlayed) + ")" \ + "\nKills: " + str(squad_lifetime_stats.kills) \ + "\nHeadshot Kills: " + str(squad_lifetime_stats.headshotKills) \ + "\nAssists: " + str(squad_lifetime_stats.assists) \ + "\nRoad Kills: " + str(squad_lifetime_stats.roadKills) \ + "\nLongest Shot: " + str(squad_lifetime_stats.longestKill) options = [ InlineQueryResultArticle( id=uuid4(), title="Total Kills", input_message_content=InputTextMessageContent(out , parse_mode = "HTML")) ] print(options) if query == 'rank': toplist = {} for i in allowed_users: stats = bg.lifetime(bg.player(i).id).squad toplist[i] = stats.kills toplist = sorted(toplist.items(), key=lambda kv: kv[1], reverse=True) out = "Ranking\n" n = 1 for i in toplist: out += str(n) + ". " + str(i[0]) + " - " + str(i[1]) + '\n' n = n + 1 options = [ InlineQueryResultArticle( id=uuid4(), title="Ranking", input_message_content=InputTextMessageContent(out , parse_mode = "HTML")) ] update.inline_query.answer(options, cache_time=0) updater = Updater(token='627697353:AAEuYCZSPfMg9ll0D0Gf3QhA9G21wJh97Wk') dispatcher = updater.dispatcher dispatcher.add_handler(InlineQueryHandler(bot_query)) updater.start_polling(clean=True) print ("Running") updater.idle()