You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
852 B

2 years ago
from mctools import PINGClient
import telebot
from db import *
API_TOKEN = read()['token']
2 years ago
bot = telebot.TeleBot(API_TOKEN)
ping = PINGClient('CoolFunZone.aternos.me', 36413)
2 years ago
stats = ping.get_stats()
print(stats)
@bot.message_handler(commands=['online'])
def check_online(message):
try:
stats = ping.get_stats()
except:
bot.reply_to(message, "🔴 Сервер оффлайн")
return 0
2 years ago
maxp = stats['players']['max']
onp = stats['players']['online']
2 years ago
try:
first = True
for i in stats['players']['sample']:
if first == True:
pp = i[0][:i[0].find('[')]
first = False
else:
pp = pp+ ' ; ' +i[0][:i[0].find('[')]
except:
pp = ''
2 years ago
bot.reply_to(message, f"""🟢 Игроки онлайн >> {onp}/{maxp}
2 years ago
{pp}""")
8 months ago
while True:
try:
bot.infinity_polling()
except KeyboardInterrupt:
exit()
except:
pass
2 years ago