mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 10:34:19 +01:00
Final cleanups for BadWords kicking.
This commit is contained in:
parent
e292c5d0c9
commit
f1948a2245
@ -94,8 +94,10 @@ conf.registerChannelValue(BadWords, 'kick',
|
||||
registry.Boolean(False, """Determines whether the bot will kick people with
|
||||
a warning when they use bad words."""))
|
||||
conf.registerChannelValue(BadWords.kick, 'message',
|
||||
registry.String("""You have been kicked for using a word prohibited on this
|
||||
channel. Please use more appropriate language in the future."""))
|
||||
registry.NormalizedString("""You have been kicked for using a word
|
||||
prohibited in the presence of this bot. Please use more appropriate
|
||||
language in the future.""", """Determines the kick message used by the bot
|
||||
when kicking users for saying bad words."""))
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
@ -66,11 +66,14 @@ class BadWords(callbacks.Privmsg):
|
||||
self.filtering = True
|
||||
return msg
|
||||
|
||||
def outFilter(self, irc, msg):
|
||||
if self.filtering and msg.command == 'PRIVMSG':
|
||||
def updateRegexp(self):
|
||||
if self.lastModified < self.words.lastModified:
|
||||
self.makeRegexp(self.words())
|
||||
self.lastModified = time.time()
|
||||
|
||||
def outFilter(self, irc, msg):
|
||||
if self.filtering and msg.command == 'PRIVMSG':
|
||||
self.updateRegexp()
|
||||
s = msg.args[1]
|
||||
if self.registryValue('stripFormatting'):
|
||||
s = ircutils.stripFormatting(s)
|
||||
@ -79,17 +82,17 @@ class BadWords(callbacks.Privmsg):
|
||||
return msg
|
||||
|
||||
def doPrivmsg(self, irc, msg):
|
||||
self.updateRegexp()
|
||||
s = ircutils.stripFormatting(msg.args[1])
|
||||
channel = msg.args[0]
|
||||
if ircutils.isChannel(channel) and self.registryValue('kick', channel):
|
||||
if self.regexp.match(s):
|
||||
if self.regexp.search(s):
|
||||
if irc.nick in irc.state.channels[channel].ops:
|
||||
message = self.registryValue('kick.message', channel)
|
||||
irc.queueMsg(ircmsgs.kick(channel, msg.nick, message))
|
||||
else:
|
||||
self.log('Should kick %s from %s, but am not opped.',
|
||||
self.log.warning('Should kick %s from %s, but not opped.',
|
||||
msg.nick, channel)
|
||||
callbacks.Privmsg.doPrivmsg(self, irc, msg)
|
||||
|
||||
def makeRegexp(self, iterable):
|
||||
s = '(%s)' % '|'.join(map(re.escape, iterable))
|
||||
|
Loading…
Reference in New Issue
Block a user