Beispiel #1
0
    def lineReceived(self, line):
        if not line:
            return

        result = commands.handle_input(self, line.decode())
        if result is not None:
            print(result)
Beispiel #2
0
 def lineReceived(self, line):
     if line.startswith('/'):
         line = line[1:]
         result = commands.handle_input(self, line)
         if result is not None:
             print(result)
     else:
         self.protocol.send_chat(line)
Beispiel #3
0
    def lineReceived(self, line):
        if not line:
            return

        try:
            result = commands.handle_input(self, line.decode())
        # pylint: disable=broad-except
        except Exception:
            traceback.print_exc()
        else:
            if result is not None:
                print(result)
Beispiel #4
0
 def privmsg(self, user, irc_channel, msg):
     if user in self.ops or user in self.voices:
         prefix = '@' if user in self.ops else '+'
         alias = self.factory.aliases.get(user, user)
         if msg.startswith(self.factory.commandprefix) and user in self.ops:
             self.unaliased_name = user
             self.name = prefix + alias
             user_input = msg[len(self.factory.commandprefix):]
             result = commands.handle_input(self, user_input)
             if result is not None:
                 self.send("%s: %s" % (user, result))
         elif msg.startswith(self.factory.chatprefix):
             max_len = MAX_IRC_CHAT_SIZE - \
                 len(self.protocol.server_prefix) - 1
             msg = msg[len(self.factory.chatprefix):].strip()
             message = ("<%s> %s" % (prefix + alias, msg))[:max_len]
             message = message.decode('cp1252')
             print(message.encode('ascii', 'replace'))
             self.factory.server.send_chat(encode(message))
Beispiel #5
0
    def privmsg(self, user, irc_channel, msg):
        if user not in self.ops and user not in self.voices:
            return  # This user is unpriviledged

        prefix = '@' if user in self.ops else '+'
        alias = self.factory.aliases.get(user, user)

        if msg.startswith(self.factory.chatprefix):
            max_len = MAX_IRC_CHAT_SIZE - \
                len(self.protocol.server_prefix) - 1
            msg = msg[len(self.factory.chatprefix):].strip()
            message = ("[irc] <{}> {}".format(prefix + alias, msg))[:max_len]
            log.info(escape_control_codes(message))
            self.factory.server.broadcast_chat(message)
        elif msg.startswith(self.factory.commandprefix) and user in self.ops:
            self.unaliased_name = user
            self.name = prefix + alias
            user_input = msg[len(self.factory.commandprefix):]
            result = commands.handle_input(self, user_input)
            if result is not None:
                self.send("{}: {}".format(user, result))