Принудительная установка протокола и добавление пинга в ms

main
none 8 months ago
parent c33cc36a96
commit d22cbad4e4

@ -1,22 +1,31 @@
from mctools import PINGClient from mctools import PINGClient
import telebot import telebot
from threading import Thread
from time import time, sleep
from db import * from db import *
API_TOKEN = read()['token'] API_TOKEN = read()['token']
bot = telebot.TeleBot(API_TOKEN) bot = telebot.TeleBot(API_TOKEN)
ping = PINGClient('CoolFunZone.aternos.me', 36413) # 764 - 1.20.2
host = 'CoolFunZone.aternos.me'
stats = ping.get_stats() port = 36413
print(stats) prot = 764
global c
c = PINGClient(host, port, proto_num = prot)
@bot.message_handler(commands=['online']) @bot.message_handler(commands=['online'])
def check_online(message): def check_online(message):
global c
try: try:
stats = ping.get_stats() stats = c.get_stats()
ms = c.ping()
except: except:
bot.reply_to(message, "🔴 Сервер оффлайн") bot.reply_to(message, "🔴 Сервер оффлайн")
c.stop()
c = PINGClient(host, port, proto_num = prot)
return 0 return 0
maxp = stats['players']['max'] maxp = stats['players']['max']
@ -35,7 +44,9 @@ def check_online(message):
bot.reply_to(message, f"""🟢 Игроки онлайн >> {onp}/{maxp} bot.reply_to(message, f"""🟢 Игроки онлайн >> {onp}/{maxp}
{pp}""") {pp}
📡 {round(ms)} ms""")
while True: while True:

Loading…
Cancel
Save