update6
This commit is contained in:
parent
2a1f8cfa20
commit
15e40502b0
|
@ -20,6 +20,8 @@ from datetime import datetime, timedelta
|
|||
import timeago
|
||||
from irc3.plugins.cron import cron
|
||||
from time import sleep
|
||||
import sqlite3
|
||||
import json
|
||||
|
||||
###########################################################################################
|
||||
###########################################################################################
|
||||
|
@ -199,6 +201,28 @@ class Plugin:
|
|||
#######################################################################################
|
||||
#######################################################################################
|
||||
|
||||
def db_recurse(self):
|
||||
dbname='databases/maple_db.sqlite'
|
||||
con = sqlite3.connect(dbname)
|
||||
cursor = con.cursor()
|
||||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
|
||||
tables = cursor.fetchall()
|
||||
self.bot.dbio.seen_users=[]
|
||||
for i,_ in enumerate(tables):
|
||||
print(f'{i} - {_[0]}')
|
||||
cursor.execute("SELECT * FROM "+_[0]+";")
|
||||
rows = cursor.fetchall()
|
||||
k=[ x[0] for x in rows ]
|
||||
for y in range(len(k)):
|
||||
try:
|
||||
if rows[y][0].startswith('last_msg_for_'):
|
||||
self.bot.dbio.seen_users.append(rows[y][0].replace("last_msg_for_",""))
|
||||
except:
|
||||
pass
|
||||
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
||||
def dsa_hardchatradar(self, USER, channel):
|
||||
"""radar for hardchatters who join a channel"""
|
||||
|
||||
|
@ -340,15 +364,8 @@ class Plugin:
|
|||
"""dsa_analyze
|
||||
%%dsa_analyze <message>...
|
||||
"""
|
||||
self.db_recurse()
|
||||
data=''.join(args['<message>']).strip()
|
||||
db_info=self.bot.config['storage']
|
||||
base_dir=f"{os.getcwd()}/{db_info.split('/')[-2]}"
|
||||
db_pathname=f"{base_dir}/{db_info.split('/')[-1]}"
|
||||
f=open(db_pathname,'r');l=f.read();f.close()
|
||||
db=l.splitlines()
|
||||
for _ in db:
|
||||
if not _.find('last_msg_for_')==-1:
|
||||
self.bot.dbio.seen_users.append(_.split('last_msg_for_')[1].split('"')[0])
|
||||
|
||||
###################################################################################
|
||||
###################################################################################
|
||||
|
@ -367,10 +384,9 @@ class Plugin:
|
|||
IS_RUNNING=True
|
||||
LOOP=1
|
||||
if SEARCH_FLAG:
|
||||
for _ in db:
|
||||
if not _.find('last_msg_for_')==-1:
|
||||
if not _.find(USER)==-1:
|
||||
self.bot.dbio.search_users.append(_.split('last_msg_for_')[-1].split('":')[0])
|
||||
for _ in self.bot.dbio.seen_users:
|
||||
if not _.find(USER)==-1:
|
||||
self.bot.dbio.search_users.append(_.split('last_msg_for_')[-1].split('":')[0])
|
||||
LOOP=len(self.bot.dbio.search_users)
|
||||
for i in range(0,LOOP):
|
||||
if SEARCH_FLAG:
|
||||
|
@ -532,6 +548,7 @@ class Plugin:
|
|||
records_newnicks=[]
|
||||
activities=0
|
||||
activities_total_words=0
|
||||
activities_total_msgs=0
|
||||
newnicks=0
|
||||
for _key in key:
|
||||
if _key['type']=='privmsg':
|
||||
|
@ -545,16 +562,39 @@ class Plugin:
|
|||
records_privmsgs.append(timestamp)
|
||||
elif _key['type']=='activity':
|
||||
activities+=1
|
||||
|
||||
# MSGSCOUNT
|
||||
try:
|
||||
activities_total_words+=int(_key[-1]['msg'])
|
||||
timestamp=await self.epochdelta(_key[-1]['time']+"T00:00:00.000000")
|
||||
records_timestamps.append(_key[-1]['time']+"T00:00:00.000000")
|
||||
records_privmsgs.append(timestamp)
|
||||
try:
|
||||
activities_total_msgs+=int(_key[-1]['msgs'])
|
||||
timestamp=await self.epochdelta(_key[-1]['time']+"T00:00:00.000000")
|
||||
records_timestamps.append(_key[-1]['time']+"T00:00:00.000000")
|
||||
records_privmsgs.append(timestamp)
|
||||
except:
|
||||
activities_total_msgs+=int(_key['msgs'])
|
||||
timestamp=await self.epochdelta(_key['time']+"T00:00:00.000000")
|
||||
records_timestamps.append(_key['time']+"T00:00:00.000000")
|
||||
records_privmsgs.append(timestamp)
|
||||
except:
|
||||
activities_total_words+=int(_key['msg'])
|
||||
timestamp=await self.epochdelta(_key['time']+"T00:00:00.000000")
|
||||
records_timestamps.append(_key['time']+"T00:00:00.000000")
|
||||
records_privmsgs.append(timestamp)
|
||||
pass
|
||||
|
||||
|
||||
# WORDCOUNT
|
||||
try:
|
||||
try:
|
||||
activities_total_words+=int(_key[-1]['msg'])
|
||||
timestamp=await self.epochdelta(_key[-1]['time']+"T00:00:00.000000")
|
||||
records_timestamps.append(_key[-1]['time']+"T00:00:00.000000")
|
||||
records_privmsgs.append(timestamp)
|
||||
except:
|
||||
activities_total_words+=int(_key['msg'])
|
||||
timestamp=await self.epochdelta(_key['time']+"T00:00:00.000000")
|
||||
records_timestamps.append(_key['time']+"T00:00:00.000000")
|
||||
records_privmsgs.append(timestamp)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
else:
|
||||
newnicks+=1
|
||||
try:
|
||||
|
@ -603,6 +643,7 @@ class Plugin:
|
|||
msg=f'{D}historicals{R}: {G}{records}'; self.bot.privmsg("#PalletTown",msg)
|
||||
msg=f'{D}nickchanges{R}: {G}{newnicks}'; self.bot.privmsg("#PalletTown",msg)
|
||||
msg=f'{D}activity days{R}: {G}{activities}'; self.bot.privmsg("#PalletTown",msg)
|
||||
msg=f'{D}msgscount total{R}: {G}{activities_total_msgs}'; self.bot.privmsg("#PalletTown",msg)
|
||||
msg=f'{D}wordcount total{R}: {G}{activities_total_words}'; self.bot.privmsg("#PalletTown",msg)
|
||||
msg=f'{D}last time spoken{R}: {G}{records_privmsgs[-1]}'; self.bot.privmsg("#PalletTown",msg)
|
||||
msg=f'{D}oldest interaction{R}: {G}{oldest_timestamp}'; self.bot.privmsg("#PalletTown",msg)
|
||||
|
@ -655,6 +696,7 @@ class Plugin:
|
|||
msg=f'{D}historicals{R}: {G}{records}'; self.bot.privmsg("#PalletTown",msg)
|
||||
msg=f'{D}nickchanges{R}: {G}{newnicks}'; self.bot.privmsg("#PalletTown",msg)
|
||||
msg=f'{D}activity days{R}: {G}{activities}'; self.bot.privmsg("#PalletTown",msg)
|
||||
msg=f'{D}msgscount total{R}: {G}{activities_total_msgs}'; self.bot.privmsg("#PalletTown",msg)
|
||||
msg=f'{D}wordcount total{R}: {G}{activities_total_words}'; self.bot.privmsg("#PalletTown",msg)
|
||||
msg=f'{D}last time spoken{R}: {G}{records_privmsgs[-1]}'; self.bot.privmsg("#PalletTown",msg)
|
||||
msg=f'{D}oldest interaction{R}: {G}{oldest_timestamp}'; self.bot.privmsg("#PalletTown",msg)
|
||||
|
|
Loading…
Reference in New Issue