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