mirror of
https://github.com/ncoevoet/ChanTracker.git
synced 2025-04-27 05:21:10 -05:00
added summary method, which returns some statistics
This commit is contained in:
parent
81cc08ddf7
commit
1181f114cf
48
plugin.py
48
plugin.py
@ -867,6 +867,43 @@ class Chan (object):
|
|||||||
self._lists[mode] = ircutils.IrcDict()
|
self._lists[mode] = ircutils.IrcDict()
|
||||||
return self._lists[mode]
|
return self._lists[mode]
|
||||||
|
|
||||||
|
def summary (self,db):
|
||||||
|
r = []
|
||||||
|
c = db.cursor()
|
||||||
|
c.execute("""SELECT id,oper,kind,removed_at FROM bans WHERE channel=?""",(self.name,))
|
||||||
|
L = c.fetchall()
|
||||||
|
total = {}
|
||||||
|
opers = {}
|
||||||
|
if len(L):
|
||||||
|
for item in L:
|
||||||
|
(id,oper,kind,removed_at) = item
|
||||||
|
if not kind in total:
|
||||||
|
total[kind] = {}
|
||||||
|
total[kind]['active'] = 0
|
||||||
|
total[kind]['removed'] = 0
|
||||||
|
if not removed_at:
|
||||||
|
total[kind]['active'] = total[kind]['active'] + 1
|
||||||
|
else:
|
||||||
|
total[kind]['removed'] = total[kind]['removed'] + 1
|
||||||
|
if not oper in opers:
|
||||||
|
opers[oper] = {}
|
||||||
|
if not kind in opers[oper]:
|
||||||
|
opers[oper][kind] = {}
|
||||||
|
opers[oper][kind]['active'] = 0
|
||||||
|
opers[oper][kind]['removed'] = 0
|
||||||
|
if not removed_at:
|
||||||
|
opers[oper][kind]['active'] = opers[oper][kind]['active'] + 1
|
||||||
|
else:
|
||||||
|
opers[oper][kind]['removed'] = opers[oper][kind]['removed'] + 1
|
||||||
|
for kind in total:
|
||||||
|
r.append('+%s: %s/%s (active/total)' % (kind,total[kind]['active'],total[kind]['active']+total[kind]['removed']))
|
||||||
|
for oper in opers:
|
||||||
|
r.append('%s:' % oper)
|
||||||
|
for kind in opers[oper]:
|
||||||
|
r.append('+%s: %s/%s (active/total)' % (kind,opers[oper][kind]['active'],opers[oper][kind]['active']+opers[oper][kind]['removed']))
|
||||||
|
c.close()
|
||||||
|
return r
|
||||||
|
|
||||||
def addItem (self,mode,value,by,when,db,checkUser=True):
|
def addItem (self,mode,value,by,when,db,checkUser=True):
|
||||||
# eqIb(+*) (-ov) pattern prefix when
|
# eqIb(+*) (-ov) pattern prefix when
|
||||||
# mode : eqIb -ov + ?
|
# mode : eqIb -ov + ?
|
||||||
@ -1148,6 +1185,17 @@ class ChanTracker(callbacks.Plugin,plugins.ChannelDBHandler):
|
|||||||
self._logChan(irc,channel,message)
|
self._logChan(irc,channel,message)
|
||||||
schedule.addEvent(self.checkNag,time.time()+self.registryValue('announceNagInterval'))
|
schedule.addEvent(self.checkNag,time.time()+self.registryValue('announceNagInterval'))
|
||||||
|
|
||||||
|
def summary (self,irc,msg,args,channel):
|
||||||
|
"""[<channel>]
|
||||||
|
|
||||||
|
returns various statistics about channel activity"""
|
||||||
|
c = self.getChan(irc,channel)
|
||||||
|
messages = c.summary(self.getDb(irc.network))
|
||||||
|
for message in messages:
|
||||||
|
irc.queueMsg(ircmsgs.privmsg(msg.nick,message))
|
||||||
|
irc.replySuccess()
|
||||||
|
summary = wrap(summary,['op','channel'])
|
||||||
|
|
||||||
def extract (self,irc,msg,args,channel,newChannel=None):
|
def extract (self,irc,msg,args,channel,newChannel=None):
|
||||||
"""[<channel>] [<newChannel>]
|
"""[<channel>] [<newChannel>]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user