mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-03 01:39:23 +01:00
Added configure and proper length coverups for bad words.
This commit is contained in:
parent
51f80c265a
commit
fa3e65d7b1
@ -49,6 +49,17 @@ import ircmsgs
|
|||||||
import privmsgs
|
import privmsgs
|
||||||
import callbacks
|
import callbacks
|
||||||
|
|
||||||
|
def configure(onStart, afterConnect, advanced):
|
||||||
|
from questions import expect, anything, something, yn
|
||||||
|
onStart.append('load BadWords')
|
||||||
|
while yn('Would you like to add some bad words?') == 'y':
|
||||||
|
words = anything('What words? (separate individual words by spaces)')
|
||||||
|
onStart.append('addbadwords %s' % words)
|
||||||
|
|
||||||
|
nastyChars = '!@#$' * 256
|
||||||
|
def subber(m):
|
||||||
|
return nastyChars[:len(m.group(1))]
|
||||||
|
|
||||||
class BadWords(callbacks.Privmsg):
|
class BadWords(callbacks.Privmsg):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
@ -57,13 +68,13 @@ class BadWords(callbacks.Privmsg):
|
|||||||
def outFilter(self, irc, msg):
|
def outFilter(self, irc, msg):
|
||||||
if hasattr(self, 'regexp') and msg.command == 'PRIVMSG':
|
if hasattr(self, 'regexp') and msg.command == 'PRIVMSG':
|
||||||
s = msg.args[1]
|
s = msg.args[1]
|
||||||
s = self.regexp.sub('!@#$', s)
|
s = self.regexp.sub(subber, s)
|
||||||
return ircmsgs.privmsg(msg.args[0], s)
|
return ircmsgs.privmsg(msg.args[0], s)
|
||||||
else:
|
else:
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
def makeRegexp(self):
|
def makeRegexp(self):
|
||||||
self.regexp = re.compile(r'\b(?:'+'|'.join(self.badwords)+r')\b', re.I)
|
self.regexp = re.compile(r'\b('+'|'.join(self.badwords)+r')\b', re.I)
|
||||||
|
|
||||||
def addbadword(self, irc, msg, args):
|
def addbadword(self, irc, msg, args):
|
||||||
"<word>"
|
"<word>"
|
||||||
|
Loading…
Reference in New Issue
Block a user