diff --git a/modules/pingtools/index.py b/modules/pingtools/index.py
index 5f28867..f833f53 100644
--- a/modules/pingtools/index.py
+++ b/modules/pingtools/index.py
@@ -1,4 +1,6 @@
-if self.MESSAGE.text == "!ping":
+msg = self.MESSAGE.text.lower()
+
+if msg == "!ping":
current_time = time.time()
delay = current_time - 7200 - float(self.MESSAGE.date.strftime('+%s'))
self.RESPONSE = f"Pong in {delay} seconds"
@@ -17,7 +19,7 @@ if self.MESSAGE.text == "!ping":
append_score(self.path, self.MESSAGE.from_user.id, f"{current_time} {user_id} {chat_id} {first_name} {last_name} {username} {delay}\n")
-elif self.MESSAGE.text == "!pong":
+elif msg == "!pong":
current_time = time.time()
delay = current_time - 7200 - float(self.MESSAGE.date.strftime('+%s'))
self.RESPONSE = f"Ping in {delay} seconds"
@@ -36,7 +38,7 @@ elif self.MESSAGE.text == "!pong":
append_score(self.path, self.MESSAGE.from_user.id, f"{current_time} {user_id} {chat_id} {first_name} {last_name} {username} {delay}\n")
-elif self.MESSAGE.text == "!pingtop":
+elif msg == "!pingtop":
def read_score(path, name):
if os.path.exists(path + f"scoreboard/{name}"):
return open(path + f"scoreboard/{name}").read()
@@ -54,11 +56,11 @@ elif self.MESSAGE.text == "!pingtop":
print(results)
- results.sort(key = lambda x: x[6])
+ results.sort(key = lambda x: float(x[6]))
self.RESPONSE = "Ping top:\n" + "\n".join( [f"{i+1}. {v[3]} {v[4]} ({v[5]}) - {v[6]}" for i, v in enumerate(results[:10])] )
self.FORMAT = "HTML"
-elif self.MESSAGE.text == "!pongtop":
+elif msg == "!pongtop":
def read_score(path, name):
if os.path.exists(path + f"pong-scoreboard/{name}"):
return open(path + f"pong-scoreboard/{name}").read()
@@ -76,11 +78,11 @@ elif self.MESSAGE.text == "!pongtop":
print(results)
- results.sort(key = lambda x: x[6])
+ results.sort(key = lambda x: float(x[6]))
self.RESPONSE = "Pong top:\n" + "\n".join( [f"{i+1}. {v[3]} {v[4]} ({v[5]}) - {v[6]}" for i, v in enumerate(results[:10])] )
self.FORMAT = "HTML"
-elif self.MESSAGE.text == "!pingantitop":
+elif msg == "!pingantitop":
def read_score(path, name):
if os.path.exists(path + f"scoreboard/{name}"):
return open(path + f"scoreboard/{name}").read()
@@ -98,12 +100,12 @@ elif self.MESSAGE.text == "!pingantitop":
print(results)
- results.sort(key = lambda x: x[6])
+ results.sort(key = lambda x: float(x[6]))
results = results[::-1]
self.RESPONSE = "Ping antitop:\n" + "\n".join( [f"{i+1}. {v[3]} {v[4]} ({v[5]}) - {v[6]}" for i, v in enumerate(results[:10])] )
self.FORMAT = "HTML"
-elif self.MESSAGE.text == "!pongantitop":
+elif msg == "!pongantitop":
def read_score(path, name):
if os.path.exists(path + f"pong-scoreboard/{name}"):
return open(path + f"pong-scoreboard/{name}").read()
@@ -121,7 +123,7 @@ elif self.MESSAGE.text == "!pongantitop":
print(results)
- results.sort(key = lambda x: x[6])
+ results.sort(key = lambda x: float(x[6]))
results = results[::-1]
self.RESPONSE = "Pong antitop:\n" + "\n".join( [f"{i+1}. {v[3]} {v[4]} ({v[5]}) - {v[6]}" for i, v in enumerate(results[:10])] )
self.FORMAT = "HTML"