mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Fixed lots of stuff.
This commit is contained in:
parent
52393396b2
commit
c290465c80
@ -142,9 +142,8 @@ class ChannelStat(irclib.IrcCommandDispatcher):
|
|||||||
|
|
||||||
|
|
||||||
class UserStat(ChannelStat):
|
class UserStat(ChannelStat):
|
||||||
def __init__(self, id, kicked=0, *args):
|
def __init__(self, kicked=0, *args):
|
||||||
ChannelStat.__init__(self, *args)
|
ChannelStat.__init__(self, *args)
|
||||||
self.id = id
|
|
||||||
self.kicked = kicked
|
self.kicked = kicked
|
||||||
self._values.insert(0, 'kicked')
|
self._values.insert(0, 'kicked')
|
||||||
|
|
||||||
@ -154,7 +153,6 @@ class UserStat(ChannelStat):
|
|||||||
|
|
||||||
class StatsDB(plugins.ChannelUserDB):
|
class StatsDB(plugins.ChannelUserDB):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
self.channelStats = ircutils.IrcDict()
|
|
||||||
plugins.ChannelUserDB.__init__(self, *args, **kwargs)
|
plugins.ChannelUserDB.__init__(self, *args, **kwargs)
|
||||||
|
|
||||||
def serialize(self, v):
|
def serialize(self, v):
|
||||||
@ -163,29 +161,27 @@ class StatsDB(plugins.ChannelUserDB):
|
|||||||
def deserialize(self, channel, id, L):
|
def deserialize(self, channel, id, L):
|
||||||
L = map(int, L)
|
L = map(int, L)
|
||||||
if id == 'channelStats':
|
if id == 'channelStats':
|
||||||
return ChannelStat(L)
|
return ChannelStat(*L)
|
||||||
else:
|
else:
|
||||||
return UserStat(L)
|
return UserStat(*L)
|
||||||
|
|
||||||
def addMsg(self, msg, id=None):
|
def addMsg(self, msg, id=None):
|
||||||
channel = msg.args[0]
|
channel = msg.args[0]
|
||||||
if ircutils.isChannel(channel):
|
if ircutils.isChannel(channel):
|
||||||
if channel not in self.channelStats:
|
if (channel, 'channelStats') not in self:
|
||||||
self.channelStats[channel] = ChannelStat()
|
self[channel, 'channelStats'] = ChannelStat()
|
||||||
self.channelStats[channel].addMsg(msg)
|
self[channel, 'channelStats'].addMsg(msg)
|
||||||
try:
|
try:
|
||||||
if id is None:
|
if id is None:
|
||||||
id = ircdb.users.getUserId(msg.prefix)
|
id = ircdb.users.getUserId(msg.prefix)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return
|
return
|
||||||
if channel not in self.channels:
|
if (channel, id) not in self:
|
||||||
self.channels[channel] = {}
|
self[channel, id] = UserStat()
|
||||||
if id not in self.channels[channel]:
|
self[channel, id].addMsg(msg)
|
||||||
self.channels[channel][id] = UserStat(id)
|
|
||||||
self.channels[channel][id].addMsg(msg)
|
|
||||||
|
|
||||||
def getChannelStats(self, channel):
|
def getChannelStats(self, channel):
|
||||||
return self[channel, -1]
|
return self[channel, 'channelStats']
|
||||||
|
|
||||||
def getUserStats(self, channel, id):
|
def getUserStats(self, channel, id):
|
||||||
return self[channel, id]
|
return self[channel, id]
|
||||||
@ -238,15 +234,13 @@ class ChannelStats(callbacks.Privmsg):
|
|||||||
id = None
|
id = None
|
||||||
for (channel, c) in self.laststate.channels.iteritems():
|
for (channel, c) in self.laststate.channels.iteritems():
|
||||||
if msg.nick in c.users:
|
if msg.nick in c.users:
|
||||||
if channel not in self.db.channelStats:
|
if (channel, 'channelStats') not in self.db:
|
||||||
self.db.channelStats[channel] = ChannelStat()
|
self.db[channel, 'channelStats'] = ChannelStat()
|
||||||
self.db.channelStats[channel].quits += 1
|
self.db[channel, 'channelStats'].quits += 1
|
||||||
if id is not None:
|
if id is not None:
|
||||||
if channel not in self.db.channels:
|
if (channel, id) not in self.db:
|
||||||
self.db.channels[channel] = {}
|
self.db[channel, id] = UserStat()
|
||||||
if id not in self.db.channels[channel]:
|
self.db[channel, id].quits += 1
|
||||||
self.db.channels[channel][id] = UserStat(id)
|
|
||||||
self.db.channels[channel][id].quits += 1
|
|
||||||
|
|
||||||
def doKick(self, irc, msg):
|
def doKick(self, irc, msg):
|
||||||
(channel, nick, _) = msg.args
|
(channel, nick, _) = msg.args
|
||||||
@ -258,7 +252,7 @@ class ChannelStats(callbacks.Privmsg):
|
|||||||
if channel not in self.db.channels:
|
if channel not in self.db.channels:
|
||||||
self.db.channels[channel] = {}
|
self.db.channels[channel] = {}
|
||||||
if id not in self.db.channels[channel]:
|
if id not in self.db.channels[channel]:
|
||||||
self.db.channels[channel][id] = UserStat(id)
|
self.db.channels[channel][id] = UserStat()
|
||||||
self.db.channels[channel][id].kicked += 1
|
self.db.channels[channel][id].kicked += 1
|
||||||
|
|
||||||
def stats(self, irc, msg, args):
|
def stats(self, irc, msg, args):
|
||||||
|
Loading…
Reference in New Issue
Block a user