bare stats by chats
This commit is contained in:
parent
f041a5ae58
commit
b218ab13b5
1 changed files with 7 additions and 1 deletions
8
ubot.py
8
ubot.py
|
@ -19,6 +19,7 @@ import pymysql.cursors
|
||||||
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
from collections import Counter
|
||||||
logger.remove()
|
logger.remove()
|
||||||
logger.level("DEBUG", color='<magenta>')
|
logger.level("DEBUG", color='<magenta>')
|
||||||
logger.add(sys.stderr, level="DEBUG")
|
logger.add(sys.stderr, level="DEBUG")
|
||||||
|
@ -53,6 +54,7 @@ class states:
|
||||||
last_reply_bioeb_avocado = 0 # same as above
|
last_reply_bioeb_avocado = 0 # same as above
|
||||||
avocado_reply_timeout = 3 # increase interval if lag more than this timeout in secs
|
avocado_reply_timeout = 3 # increase interval if lag more than this timeout in secs
|
||||||
stats_medkit = 0
|
stats_medkit = 0
|
||||||
|
stats_most_infect_spam_chats = Counter()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
|
@ -199,6 +201,7 @@ async def main():
|
||||||
cinfo = await m.get_chat()
|
cinfo = await m.get_chat()
|
||||||
chat_name = cinfo.title
|
chat_name = cinfo.title
|
||||||
logger.debug(f"in chat '{chat_name}'")
|
logger.debug(f"in chat '{chat_name}'")
|
||||||
|
states.stats_most_infect_spam_chats[chat_name] += 1
|
||||||
t = m.raw_text
|
t = m.raw_text
|
||||||
# NOTE: theme hell... any ideas for improvment required
|
# NOTE: theme hell... any ideas for improvment required
|
||||||
# but not use huge regular expression like|that|fuckin|way|a|aaaa|aaaaaaaa
|
# but not use huge regular expression like|that|fuckin|way|a|aaaa|aaaaaaaa
|
||||||
|
@ -472,8 +475,11 @@ async def main():
|
||||||
####################################################################
|
####################################################################
|
||||||
@client.on(events.NewMessage(outgoing=True, pattern=r'\.bstat$'))
|
@client.on(events.NewMessage(outgoing=True, pattern=r'\.bstat$'))
|
||||||
async def bio_stat(event):
|
async def bio_stat(event):
|
||||||
|
stats_most_chats = states.stats_most_infect_spam_chats.most_common()
|
||||||
msg = "Session stats:\n" \
|
msg = "Session stats:\n" \
|
||||||
f"Medkit usage: {states.stats_medkit}"
|
f"Medkit usage: {states.stats_medkit}\n" \
|
||||||
|
f"Most common chats:\n" \
|
||||||
|
f"{stats_most_chats}".replace(',', '\n')
|
||||||
await event.edit(msg)
|
await event.edit(msg)
|
||||||
|
|
||||||
@client.on(events.NewMessage(outgoing=True, pattern='.ping'))
|
@client.on(events.NewMessage(outgoing=True, pattern='.ping'))
|
||||||
|
|
Loading…
Reference in a new issue