From bc89a4d6442770582233d67e6f196962e57fe77e Mon Sep 17 00:00:00 2001
From: Dennis Kaarsemaker (?P (?P (?P (?P
(?P
(?P
', True), + 'vmjg59': ('http://www.rjek.com/vmjg59.cgi', r'
(?P', True),
+ 'bofh': ('/home/dennis/ubugtu/plugins/Mess/bofh.txt', 'BOFH Excuse #%d: ', False),
+ '42': ('/home/dennis/ubugtu/plugins/Mess/42.txt', '', False),
+ 'magic8ball': ('/home/dennis/ubugtu/plugins/Mess/ball.txt', '', False),
+ 'ferengi': ('/home/dennis/ubugtu/plugins/Mess/ferengi.txt', 'Ferengi rule of acquisition ', False)
+}
+data = {}
+for m in mess.keys():
+ if mess[m][0].startswith('http'):
+ mess[m] = (mess[m][0],re.compile(mess[m][1], re.I|re.DOTALL), mess[m][2])
+ else:
+ fd = open(mess[m][0])
+ data[mess[m][0]] = [x.strip() for x in fd.readlines()]
+ fd.close()
+
+badwords = ['sex','masturbate','fuck','rape','dick','pussy','prostitute','hooker',
+ 'orgasm','sperm','cunt','penis','shit','piss','urin','bitch','semen','cock']
+tagre = re.compile(r'<.*?>')
+def filter(txt,off):
+ _txt = txt.lower()
+ if not off:
+ for b in badwords:
+ if b in _txt:
+ return None
+ txt = txt.replace('
','').replace('\n','').replace('\r','')
+ txt = txt.replace('','/').replace('','/').replace('','*').replace('','*')
+ txt = txt.replace('"','"').replace('<','<').replace('>','>')
+ txt = tagre.sub('',txt)
+ return txt
+
+times = {}
+
+def ok(func):
+ func.offensive = False
+ def newfunc(*args, **kwargs):
+ global time
+ plugin = args[0]
+ channel = args[2].args[0]
+ if not channel.startswith('#'):
+ delay = 5
+ else:
+ if not plugin.registryValue('enabled', channel):
+ return
+ delay = plugin.registryValue('delay', channel)
+ if channel not in times.keys():
+ times[channel] = time.time()
+ elif times[channel] < time.time() - delay:
+ times[channel] = time.time()
+ else:
+ return
+ i=0
+ func(*args, **kwargs)
+ newfunc.__doc__ = func.__doc__
+ return newfunc
class Mess(callbacks.PluginRegexp):
"""Random Mess plugin"""
threaded = True
- regexps = ['hugme','r42','ball']
+ regexps = ['hugme']
hugs = ["hugs %s","gives %s a big hug","gives %s a sloppy wet kiss",
"huggles %s","squeezes %s","humps %s"]
- regex = re.compile('.*?
(.*?)
', re.DOTALL) - entre = re.compile('&(\S*?);') - jre1 = ('http://www.jackbauerfacts.com/index.php?rate_twenty_four', - re.compile('current-rating.*?width.*?(.*?)
', re.DOTALL)) - mgurl = ('http://www.macgyver.co.za/', - re.compile(r'wishtable">(.*?)')+3:data.find('
')].strip()) - yourmom = wrap(yourmom) - - def bush(self, irc,msg,args): - """Yes, bush needs help....""" - if not self.ok(msg.args[0], True): return - data = utils.web.getUrl('http://www.dubyaspeak.com/random.phtml') - data = data[data.find('')+1:] - irc.reply(data.replace("\r\n",' ').replace("\r",' ').replace("\n",' ')) - bush = wrap(bush) - - def southpark(self, irc, msg, args): - """TIMMEHH!!""" - if not self.ok(msg.args[0], True): return - data = utils.web.getUrl('http://www.southparkquotes.com/random.php?num=1') - data = data[data.find('')+3:data.find('
')] - while '<' in data: - data = data[:data.find('<')] + data[data.find('>')+1:] - irc.reply(data.replace("\r\n",' ').replace("\r",' ').replace("\n",' ')) - southpark = wrap(southpark) - + @ok def pony(self, irc, msg, args, text): """ NO! """ - if not self.ok(msg.args[0]): return if not text: text = 'you' irc.reply("No %s can't have a pony, %s!" % (text, msg.nick)) pony = wrap(pony, [additional('text')]) - def _bauer(self,count=0): -# if self.i % 2 == 0: -# (url, re) = self.jre1 -# else: -# (url, re) = self.jre2 -# self.i += 1 - (url, re) = self.jre2 - if count > 5: - return - try: - fact = utils.web.getUrl(url) - reo = re.search(fact) - val = reo.group(1) - while self.entre.search(val): - entity = self.entre.search(val).group(1) - if entity in entities: - val = self.entre.sub(entities[entity], val) - else: - val = self.entre.sub('?', val) - _val = val.lower() - for word in self.badwords: - if word in _val: - raise RuntimeError - return val - except: - time.sleep(1) - return self._bauer(count+1) - - def _macgyver(self,count=0): - (url, rx) = self.mgurl - if count > 5: - return - try: - fact = utils.web.getUrl(url) - reo = rx.search(fact) - val = reo.group(1).replace('','').replace('
','').replace('"','"').replace(' ',' ') - val = re.sub(r'\s+', ' ', val).strip() - while self.entre.search(val): - entity = self.entre.search(val).group(1) - if entity in entities: - val = self.entre.sub(entities[entity], val) - else: - val = self.entre.sub('?', val) - _val = val.lower() - for word in self.badwords: - if word in _val: - raise RuntimeError - return val - except: - time.sleep(1) - return self._macgyver(count+1) - - def _bruce(self,count=0): - (url, rx) = self.bsurl - if count > 5: - return - try: - fact = utils.web.getUrl(url) - reo = rx.search(fact) - val = reo.group(1).replace('','').replace('
','').replace('"','"').replace(' ',' ') - val = re.sub(r'\s+', ' ', val).strip() - while self.entre.search(val): - entity = self.entre.search(val).group(1) - if entity in entities: - val = self.entre.sub(entities[entity], val) - else: - val = self.entre.sub('?', val) - _val = val.lower() - for word in self.badwords: - if word in _val: - raise RuntimeError - return val - except: - time.sleep(1) - return self._bruce(count+1) - Class = Mess