mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-03 01:39:23 +01:00
Added configurables for smileys and frowns.
This commit is contained in:
parent
85e0783cb9
commit
0d25243fb0
@ -63,13 +63,14 @@ except ImportError:
|
|||||||
raise callbacks.Error, 'You need to have PySQLite installed to use this ' \
|
raise callbacks.Error, 'You need to have PySQLite installed to use this ' \
|
||||||
'plugin. Download it at <http://pysqlite.sf.net/>'
|
'plugin. Download it at <http://pysqlite.sf.net/>'
|
||||||
|
|
||||||
|
def SmileyType(s):
|
||||||
smileys = (':)', ';)', ':]', ':-)', ':-D', ':D', ':P', ':p', '(=', '=)')
|
try:
|
||||||
frowns = (':|', ':-/', ':-\\', ':\\', ':/', ':(', ':-(', ':\'(')
|
L = configurable.SpaceSeparatedStrListType(s)
|
||||||
|
return re.compile('|'.join(imap(re.escape, L)))
|
||||||
smileyre = re.compile('|'.join(imap(re.escape, smileys)))
|
except configurable.Error:
|
||||||
frownre = re.compile('|'.join(imap(re.escape, frowns)))
|
raise configurable.Error, 'Value must be a space-separated list of ' \
|
||||||
|
'smileys or frowns.'
|
||||||
|
|
||||||
class ChannelDB(plugins.ChannelDBHandler,
|
class ChannelDB(plugins.ChannelDBHandler,
|
||||||
configurable.Mixin,
|
configurable.Mixin,
|
||||||
callbacks.Privmsg):
|
callbacks.Privmsg):
|
||||||
@ -80,8 +81,16 @@ class ChannelDB(plugins.ChannelDBHandler,
|
|||||||
possibly skewing the channel stats (especially in cases where he's
|
possibly skewing the channel stats (especially in cases where he's
|
||||||
relaying between channels on a network."""),
|
relaying between channels on a network."""),
|
||||||
('wordstats-top-n', configurable.IntType, 3,
|
('wordstats-top-n', configurable.IntType, 3,
|
||||||
"""Determines the maximum number of top users to show for a given
|
"""Determines the maximum number of top users to show for a given
|
||||||
wordstat when you request the wordstats for a particular word.""")]
|
wordstat when you request the wordstats for a particular word."""),
|
||||||
|
('smileys', SmileyType, SmileyType(':) ;) ;] :-) :-D :D :P :p (= =)'),
|
||||||
|
"""Determines what words count as smileys for the purpose of keeping
|
||||||
|
statistics on the number of smileys each user has sent to the
|
||||||
|
channel."""),
|
||||||
|
('frowns', SmileyType, SmileyType(':| :-/ :-\\ :\\ :/ :( :-( :\'('),
|
||||||
|
"""Determines what words count as frowns for the purpose of keeping
|
||||||
|
statistics on the number of frowns each user has sent ot the
|
||||||
|
channel."""),]
|
||||||
)
|
)
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
@ -213,8 +222,8 @@ class ChannelDB(plugins.ChannelDBHandler,
|
|||||||
chars = len(s)
|
chars = len(s)
|
||||||
words = len(s.split())
|
words = len(s.split())
|
||||||
isAction = ircmsgs.isAction(msg)
|
isAction = ircmsgs.isAction(msg)
|
||||||
frowns = len(frownre.findall(s))
|
frowns = len(self.configurables.get('frowns', channel).findall(s))
|
||||||
smileys = len(smileyre.findall(s))
|
smileys = len(self.configurables.get('smileys', channel).findall(s))
|
||||||
s = ircmsgs.prettyPrint(msg)
|
s = ircmsgs.prettyPrint(msg)
|
||||||
cursor.execute("""UPDATE channel_stats
|
cursor.execute("""UPDATE channel_stats
|
||||||
SET smileys=smileys+%s,
|
SET smileys=smileys+%s,
|
||||||
|
Loading…
Reference in New Issue
Block a user