diff --git a/src/stat.py b/src/stat.py index 76f868e..43f033d 100644 --- a/src/stat.py +++ b/src/stat.py @@ -1,7 +1,7 @@ from collections import Counter from telethon import events - +from datetime import datetime class bio: medkit_usage = 0 @@ -11,13 +11,17 @@ class bio: victims_failed_parse = 0 -async def biomod(client): +async def biomod(client, c): @client.on(events.NewMessage(outgoing=True, pattern=r'\.bstat$')) async def bio_stat(event): stats_most_chats = bio.most_infect_spam_chats.most_common() stats_most_chats = str(stats_most_chats).replace(',', '\n') + when = datetime.timestamp(event.date) + count_eaten = int(c.execute(f"SELECT COUNT(*) FROM `avocado` WHERE expr_int <= {when} LIMIT 1").fetchone()[0]) + count_not_eaten = int(c.execute(f"SELECT COUNT(*) FROM `avocado` WHERE expr_int = 0 LIMIT 1").fetchone()[0]) msg = "Session stats:\n" \ f"Medkit usage: {bio.medkit_usage}\n" \ + f"Victims in db (eaten/not eaten): {count_eaten}/{count_not_eaten}\n" \ f"Most common chats:\n" \ f"{stats_most_chats}" \ f"\nUpdated victims: {bio.victims_updated}\n" \ diff --git a/ubot.py b/ubot.py index 0a0cb09..4822785 100644 --- a/ubot.py +++ b/ubot.py @@ -188,7 +188,7 @@ async def main(): asyncio.ensure_future(avocmine.automine_avocado_task(client)) - await stat.biomod(client) + await stat.biomod(client, c) @client.on(events.NewMessage(outgoing=True, pattern='.ping')) async def cmd_ping(event):