def process_directed_line(self, line_parts): ''' Processes a line directed at the bot ''' user, target_channel, message = (part.strip() for part in line_parts.groups()) if self.channels[target_channel]['silenced'] and 'speak' not in message: return if '~' in message: message = crop_string(message, '~') elif ':' in message and self.nick.lower() in message.lower(): message = crop_string(message, ':') else: return if target_channel == self.nick: target_channel = user self.process_command(user, target_channel, message)
def process_command(self, user, target_channel, message): ''' Processes a command ''' command, action = self.get_action(message) if command is not None: self._add_command_to_history(command, action) message = crop_string(message, command) message = message.strip() response = action(message, user=user,target_channel=target_channel) self._send_messages(target_channel, '{message}'.format(message=response)) else: self._send_message(target_channel, '{user}: Piss off.'.format(user=user))
def is_directed_at_me(self, line): ''' Checks if command is directed at bot ''' line = crop_string(line, '@') return self.nick.lower() in line.lower() or '~' in line
def is_directed_at_me(self, line): ''' Checks if command is directed at bot ''' line = crop_string(line, '@') return '!' in line or IrcBot.is_directed_at_me(self, line)