bstat: add eaten/not eaten in db counts
This commit is contained in:
parent
2e4eaa499c
commit
e762f1e7f6
2 changed files with 7 additions and 3 deletions
|
@ -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" \
|
||||
|
|
2
ubot.py
2
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):
|
||||
|
|
Loading…
Reference in a new issue