def privmsg(self, source, target, message): source = user_controller.get_or_create_user(*source) self.fire(debugout("{} <{}> {}".format(source.nick, target, message))) regex_action = re.compile('\x01ACTION (?P<action>.*)\x01') regex_cmd = re.compile(r'^\.(?P<command>[^\s]+)(?: (?P<args>.*))?$') regex_direct = re.compile(r'^{nick}[:,] (?P<msg>.+)$'.format(nick=self.nick)) if target.startswith("#"): action_match = regex_action.search(message) cmd_match = regex_cmd.search(message) direct_match = regex_direct.search(message) if action_match: action = action_match.group('action') self.fire(actionmessage(source, target, action)) elif cmd_match: cmd = cmd_match.group('command') args = cmd_match.group('args') self.fire(command(source, target, cmd, args or '')) elif direct_match: msg = direct_match.group('msg') self.fire(directmessage(source, target, msg)) else: self.fire(generalmessage(source, target, message)) else: pass
def process_kwargs(self, **kwargs): if 'original' in kwargs: message = kwargs['original'] message_parse = directed_regex.findall(message) if message_parse: target = message_parse[0] user = user_controller.get_or_create_user(target) arcuser = arcuser_controller.get_or_create_arcuser(user) kwargs['target'] = arcuser return kwargs
def privmsg(self, source, target, message): source = user_controller.get_or_create_user(*source) self.fire(debugout("{} <{}> {}".format(source.nick, target, message))) regex_action = re.compile('\x01ACTION (?P<action>.*)\x01') regex_cmd = re.compile(r'^\.(?P<command>[^\s]+)(?: (?P<args>.*))?$') regex_direct = re.compile(r'^{nick}[:,] (?P<msg>.+)$'.format(nick=self.nick)) action_match = regex_action.search(message) cmd_match = regex_cmd.search(message) if target.startswith("#"): # message in a channel direct_match = regex_direct.search(message) if action_match: action = action_match.group('action') self.fire(actionmessage(source, target, action)) elif cmd_match: cmd = cmd_match.group('command') args = cmd_match.group('args') self.fire(command(source, target, cmd, args or '')) elif direct_match: msg = direct_match.group('msg') self.fire(directmessage(source, target, msg)) else: self.fire(generalmessage(source, target, message)) else: # private message channel = source.nick if action_match: action = action_match.group('command') self.fire(actionmessage(source, channel, action)) elif cmd_match: cmd = cmd_match.group('command') args = cmd_match.group('args') self.fire(command(source, channel, cmd, args or '')) else: self.fire(privatemessage(source, channel, message))
def quit(self, info, channel): nick, realname, address = info user = user_controller.get_or_create_user(nick, name=realname) return user_controller.remove_user_from_channel(user, channel)
def join(self, info, channel): nick, realname, address = info user = user_controller.get_or_create_user(nick, name=realname) return user_controller.add_user_to_channel(user, channel)