2023-02-03 20:33:10 +00:00
|
|
|
from mctools import PINGClient
|
|
|
|
import telebot
|
2024-03-02 13:14:43 +00:00
|
|
|
from threading import Thread
|
|
|
|
from time import time, sleep
|
2024-03-02 12:05:24 +00:00
|
|
|
|
|
|
|
from db import *
|
|
|
|
|
|
|
|
API_TOKEN = read()['token']
|
2023-02-03 20:33:10 +00:00
|
|
|
bot = telebot.TeleBot(API_TOKEN)
|
|
|
|
|
2024-03-02 13:14:43 +00:00
|
|
|
# 764 - 1.20.2
|
|
|
|
host = 'CoolFunZone.aternos.me'
|
|
|
|
port = 36413
|
|
|
|
prot = 764
|
|
|
|
global c
|
|
|
|
c = PINGClient(host, port, proto_num = prot)
|
2023-02-03 20:33:10 +00:00
|
|
|
|
|
|
|
@bot.message_handler(commands=['online'])
|
2024-03-02 12:05:24 +00:00
|
|
|
def check_online(message):
|
2024-03-02 13:14:43 +00:00
|
|
|
global c
|
|
|
|
|
2024-03-02 12:05:24 +00:00
|
|
|
try:
|
2024-03-02 13:14:43 +00:00
|
|
|
stats = c.get_stats()
|
|
|
|
ms = c.ping()
|
2024-03-02 12:05:24 +00:00
|
|
|
except:
|
|
|
|
bot.reply_to(message, "🔴 Сервер оффлайн")
|
2024-03-02 13:14:43 +00:00
|
|
|
c.stop()
|
|
|
|
c = PINGClient(host, port, proto_num = prot)
|
2024-03-02 12:05:24 +00:00
|
|
|
return 0
|
|
|
|
|
2023-02-03 20:33:10 +00:00
|
|
|
maxp = stats['players']['max']
|
2024-03-02 12:05:24 +00:00
|
|
|
onp = stats['players']['online']
|
|
|
|
|
2023-02-03 20:33:10 +00:00
|
|
|
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 = ''
|
2024-03-02 12:05:24 +00:00
|
|
|
|
2023-02-03 20:33:10 +00:00
|
|
|
bot.reply_to(message, f"""🟢 Игроки онлайн >> {onp}/{maxp}
|
2024-03-02 12:05:24 +00:00
|
|
|
|
2024-03-02 13:14:43 +00:00
|
|
|
{pp}
|
|
|
|
|
|
|
|
📡 {round(ms)} ms""")
|
2023-02-03 20:33:10 +00:00
|
|
|
|
|
|
|
|
2024-03-02 12:11:18 +00:00
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
bot.infinity_polling()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
exit()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
2023-02-03 20:33:10 +00:00
|
|
|
|