mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Finished fixing the switch to registry.
This commit is contained in:
parent
6362a02cd1
commit
ec288430df
@ -67,32 +67,31 @@ except ImportError:
|
||||
class Smileys(registry.Value):
|
||||
def set(self, s):
|
||||
L = s.split()
|
||||
self.s = s
|
||||
self.setValue(L)
|
||||
|
||||
def setValue(self, v):
|
||||
self.s = ' '.join(v)
|
||||
self.value = re.compile('|'.join(imap(re.escape, v)))
|
||||
|
||||
def __str__(self):
|
||||
return self.s
|
||||
|
||||
conf.registerPlugin('ChannelDB')
|
||||
conf.registerChannelValue(conf.supybot.plugins.ChannelDB, 'selfStats',
|
||||
conf.registerPlugin('ChannelStats')
|
||||
conf.registerChannelValue(conf.supybot.plugins.ChannelStats, 'selfStats',
|
||||
registry.Boolean(True, """Determines whether the bot will keep channel
|
||||
statistics on itself, possibly skewing the channel stats (especially in
|
||||
cases where the bot is relaying between channels on a network)."""))
|
||||
conf.registerChannelValue(conf.supybot.plugins.ChannelDB, 'smileys',
|
||||
conf.registerChannelValue(conf.supybot.plugins.ChannelStats, 'smileys',
|
||||
Smileys(':) ;) ;] :-) :-D :D :P :p (= =)'.split(), """Determines what
|
||||
words (i.e., pieces of text with no spaces in them) are considered
|
||||
'smileys' for the purposes of stats-keeping."""))
|
||||
conf.registerChannelValue(conf.supybot.plugins.ChannelDB, 'frowns',
|
||||
conf.registerChannelValue(conf.supybot.plugins.ChannelStats, 'frowns',
|
||||
Smileys(':| :-/ :-\\ :\\ :/ :( :-( :\'('.split(), """Determines what words
|
||||
(i.e., pieces of text with no spaces in them ) are considered 'frowns' for
|
||||
the purposes of stats-keeping."""))
|
||||
|
||||
|
||||
class ChannelDB(plugins.ChannelDBHandler,
|
||||
callbacks.Privmsg):
|
||||
class ChannelStats(plugins.ChannelDBHandler, callbacks.Privmsg):
|
||||
noIgnore = True
|
||||
def __init__(self):
|
||||
callbacks.Privmsg.__init__(self)
|
||||
@ -167,11 +166,15 @@ class ChannelDB(plugins.ChannelDBHandler,
|
||||
self.laststate = irc.state.copy()
|
||||
finally:
|
||||
self.lastmsg = msg
|
||||
super(ChannelDB, self).__call__(irc, msg)
|
||||
super(ChannelStats, self).__call__(irc, msg)
|
||||
|
||||
def doPrivmsg(self, irc, msg):
|
||||
if not ircutils.isChannel(msg.args[0]):
|
||||
return
|
||||
else:
|
||||
self._updatePrivmsgStats(msg)
|
||||
|
||||
def _updatePrivmsgStats(self, msg):
|
||||
(channel, s) = msg.args
|
||||
db = self.getDb(channel)
|
||||
cursor = db.cursor()
|
||||
@ -433,6 +436,6 @@ class ChannelDB(plugins.ChannelDBHandler,
|
||||
irc.reply(s)
|
||||
|
||||
|
||||
Class = ChannelDB
|
||||
Class = ChannelStats
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||
|
@ -33,12 +33,18 @@
|
||||
Keeps statistics on who says what words in a channel.
|
||||
"""
|
||||
|
||||
import plugins
|
||||
import os
|
||||
import string
|
||||
|
||||
import sqlite
|
||||
|
||||
import conf
|
||||
import utils
|
||||
import ircdb
|
||||
import plugins
|
||||
import ircutils
|
||||
import privmsgs
|
||||
import registry
|
||||
import callbacks
|
||||
|
||||
|
||||
@ -51,6 +57,10 @@ conf.registerChannelValue(conf.supybot.plugins.WordStats,
|
||||
|
||||
class WordStats(callbacks.Privmsg, plugins.ChannelDBHandler):
|
||||
noIgnore = True
|
||||
def __init__(self):
|
||||
callbacks.Privmsg.__init__(self)
|
||||
plugins.ChannelDBHandler.__init__(self)
|
||||
|
||||
def die(self):
|
||||
callbacks.Privmsg.die(self)
|
||||
plugins.ChannelDBHandler.die(self)
|
||||
@ -84,7 +94,6 @@ class WordStats(callbacks.Privmsg, plugins.ChannelDBHandler):
|
||||
def doPrivmsg(self, irc, msg):
|
||||
if not ircutils.isChannel(msg.args[0]):
|
||||
return
|
||||
callbacks.Privmsg.doPrivmsg(self, irc, msg)
|
||||
try:
|
||||
id = ircdb.users.getUserId(msg.prefix)
|
||||
except KeyError:
|
||||
@ -127,7 +136,7 @@ class WordStats(callbacks.Privmsg, plugins.ChannelDBHandler):
|
||||
db.commit()
|
||||
irc.replySuccess()
|
||||
|
||||
def stats(self, irc, msg, args):
|
||||
def wordstats(self, irc, msg, args):
|
||||
"""[<channel>] [<user>] [<word>]
|
||||
|
||||
With no arguments, returns the list of words that are being monitored
|
||||
|
Loading…
Reference in New Issue
Block a user