def privmsg(self, user, channel, msg): """This will get called when the bot receives a message.""" user = user.split('!', 1)[0] shushify = re.search('{}: (un)?shush'.format(self.nickname), msg) if shushify: args = msg.split() if shushify.groups()[0]: # Group 0: turn shush off self.quiet = None self.msg(channel, 'universal translation matrix re-enabled') else: m = 5 if len(args) > 2: try: m = int(args[2]) except ValueError: pass self.quiet = datetime.datetime.now() + \ datetime.timedelta(minutes=m) self.msg(channel, 'quiet time') elif channel == self.nickname: self.msg(user, translate_remyspeak(msg)) elif user == 'oddshocks': translated = translate_remyspeak(msg) display = self.karma.sub('', translated) if not msg.lower() == translated.lower(): self.can_talk(channel, 'What {} means is: {}'.format( user, display))
def privmsg(self, user, channel, msg): """This will get called when the bot receives a message.""" user = user.split('!', 1)[0] if user == 'decause': translated = translate_remyspeak(msg) display = re.sub(r'(\+\+)|(--)', '', translated) if not msg.lower() == translated.lower(): self.msg(channel, 'What {} meant to say was: {}'.format( user, display)) if channel == self.nickname: self.msg(user, translate_remyspeak(msg))
def privmsg(self, user, channel, msg): """This will get called when the bot receives a message.""" user = user.split('!', 1)[0] shushify = re.search('{}: (un)?shush'.format(self.nickname), msg) if shushify: args = msg.split() if shushify.groups()[0]: # Group 0: turn shush off self.quiet = None self.msg(channel, 'universal translation matrix re-enabled') else: m = 5 if len(args) > 2: try: m = int(args[2]) except ValueError: pass self.quiet = datetime.datetime.now() + \ datetime.timedelta(minutes=m) self.msg(channel, 'quiet time') elif channel == self.nickname: self.msg(user, translate_remyspeak(msg)) elif user == 'decause': translated = translate_remyspeak(msg) display = self.karma.sub('', translated) if not msg.lower() == translated.lower(): self.can_talk(channel, 'What {} means is: {}'.format( user, display)) tag_list = self.xml.findall(msg.lower()) untag_list = self.xml_close.findall(msg.lower()) for tag in untag_list: if tag in tag_list: tag_list.remove(tag) if tag_list: response = ''.join('</'+tag+'>' for tag in tag_list[::-1]) self.can_talk(channel, response)
def privmsg(self, user, channel, msg): """This will get called when the bot receives a message.""" user = user.split('!', 1)[0] # Regexes to handle non-kettlefish actions shushify = re.match('{}: (un)?shush(.*)'.format(self.nickname), msg) optional = re.match('{}: opt (in|out)$'.format(self.nickname), msg) thanks = re.search('({0}.*thanks)|(thanks.*{0})'.format(self.nickname), msg) tag_list = self.xml.findall(msg.lower()) untag_list = self.xml_close.findall(msg.lower()) # Anything PM-ed to kettlefish will be translated if channel == self.nickname: self.msg(user, translate_remyspeak(msg)) # Handle being told to shush or unshush elif shushify: args = shushify.groups() # This tests the existence of the 'un-' prefix if args[0] == 'un': self.quiet = None self.msg(channel, 'universal translation matrix re-enabled') else: m = 5 if args[1]: try: # Don't shush longer than 90 minutes m = min(int(args[2]), 90) except ValueError: pass self.quiet = datetime.datetime.now() + datetime.timedelta(minutes=m) self.msg(channel, 'quiet time') # I provide a valuable service to the community! elif thanks: self.can_talk(channel, "{}: You're welcome!".format(user)) # But not that valuable... elif optional: if optional.groups()[0] == 'out': self.victims.discard(user) self.describe(channel, 'recognizes that {} hates fun'.format(user)) elif optional.groups()[0] == 'in': self.victims.add(user) self.describe(channel, 'has noted that {} is a cool person'.format(user)) with open('victims.json', 'w') as jfile: json.dump(list(self.victims), jfile) elif tag_list: for tag in untag_list: if tag in tag_list: tag_list.remove(tag) if tag_list: response = ''.join('</' + tag + '>' for tag in tag_list[::-1]) self.can_talk(channel, response) elif user in self.victims: translated = translate_remyspeak(msg) display = self.karma.sub('', translated) if not msg.lower() == translated.lower(): self.can_talk(channel, 'What {} means is: {}'.format(user, display))
def privmsg(self, user, channel, msg): """This will get called when the bot receives a message.""" user = user.split('!', 1)[0] # Regexes to handle non-kettlefish actions shushify = re.match('{}: (un)?shush(.*)'.format(self.nickname), msg) optional = re.match('{}: opt (in|out)$'.format(self.nickname), msg) thanks = re.search('({0}.*thanks)|(thanks.*{0})'.format(self.nickname), msg) tag_list = self.xml.findall(msg.lower()) untag_list = self.xml_close.findall(msg.lower()) # Anything PM-ed to kettlefish will be translated if channel == self.nickname: self.msg(user, translate_remyspeak(msg)) # Handle being told to shush or unshush elif shushify: args = shushify.groups() # This tests the existence of the 'un-' prefix if args[0] == 'un': self.quiet = None self.msg(channel, 'universal translation matrix re-enabled') else: m = 5 if args[1]: try: # Don't shush longer than 90 minutes m = min(int(args[2]), 90) except ValueError: pass self.quiet = datetime.datetime.now() + datetime.timedelta(minutes=m) self.msg(channel, 'quiet time') # I provide a valuable service to the community! elif thanks: self.can_talk(channel, "{}: You're welcome!".format(user)) # But not that valuable... elif optional: if optional.groups()[0] == 'out': try: self.victims.remove(user) except ValueError: pass elif optional.groups()[0] == 'in': self.victims.append(user) with open('victims.json', 'w') as jfile: json.dump(self.victims, jfile) elif tag_list: for tag in untag_list: if tag in tag_list: tag_list.remove(tag) if tag_list: response = ''.join('</' + tag + '>' for tag in tag_list[::-1]) self.can_talk(channel, response) elif user in self.victims: translated = translate_remyspeak(msg) display = self.karma.sub('', translated) if not msg.lower() == translated.lower(): self.can_talk(channel, 'What {} means is: {}'.format(user, display))