From d22cbad4e40f6c73eb765300ef39e60b3075d406 Mon Sep 17 00:00:00 2001 From: none Date: Sat, 2 Mar 2024 16:14:43 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=BD=D1=83=D0=B4=D0=B8?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=B0=D1=8F=20=D1=83=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BF=D1=80=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=BA=D0=BE=D0=BB=D0=B0=20=D0=B8=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=B8=D0=BD?= =?UTF-8?q?=D0=B3=D0=B0=20=D0=B2=20ms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- online.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/online.py b/online.py index 8874207..f1c51f5 100644 --- a/online.py +++ b/online.py @@ -1,22 +1,31 @@ from mctools import PINGClient import telebot +from threading import Thread +from time import time, sleep from db import * API_TOKEN = read()['token'] bot = telebot.TeleBot(API_TOKEN) -ping = PINGClient('CoolFunZone.aternos.me', 36413) - -stats = ping.get_stats() -print(stats) +# 764 - 1.20.2 +host = 'CoolFunZone.aternos.me' +port = 36413 +prot = 764 +global c +c = PINGClient(host, port, proto_num = prot) @bot.message_handler(commands=['online']) def check_online(message): + global c + try: - stats = ping.get_stats() + stats = c.get_stats() + ms = c.ping() except: bot.reply_to(message, "🔴 Сервер оффлайн") + c.stop() + c = PINGClient(host, port, proto_num = prot) return 0 maxp = stats['players']['max'] @@ -35,7 +44,9 @@ def check_online(message): bot.reply_to(message, f"""🟢 Игроки онлайн >> {onp}/{maxp} -{pp}""") +{pp} + +📡 {round(ms)} ms""") while True: