Пример #1
0
    def processLine(self, line):
        super().processLine(line)

        ret = highestresponse.highestResponse(line)

        if ret.command == "join" and ret.source == self.master.name:
            self.channels |= {ret.message}
Пример #2
0
    def processLine(self, line):

        ret = highestresponse.highestResponse(line)

        if not ret.isMessage:
            return

        msg = ret.message
        src = ret.source
        rec = ret.target

        if rec.startswith("#"):
            toChan = True
        else:
            toChan = False

        trigger = self.__class__.TRIGGER
        toMe = False

        if isinstance(trigger, str):
            if msg.startswith(self.__class__.TRIGGER):
                toMe = True

        elif isinstance(trigger, (list, tuple)):

            for i in trigger:
                if msg.startswith(i):
                    toMe = True
                    break        # we're done here

        if toMe:
            response = self.respond(ret)

            if not response:
                return

            cmd = irccommand.IRCCommand("PRIVMSG", [], "")

            if toChan:
                cmd.args = [rec]
            else:
                cmd.args = [src]

            for line in response.split("\n"):
                line = line.rstrip()

                if line:
                    cmd.message = line
                    print(cmd)
                    self.master.sendCommand(cmd)
Пример #3
0
    def processLine(self, line):

        isCTCP   = False
        isAction = False

        channelMsgs =    (
        ("-",  SB + "{0}" + EB + ":" + SB + "{1}" + EB,  "-", " {2}"),
        ("-",  SB + "{0}" + EB + ":" + SB + "{1}" + EB,  "-", SB + "NOTICE:" + EB + " {2}"),
        ("-",  SB + "{0}" + EB,  "-",   " * " + SB + "{1}" + EB + " {2}"),
        )

        channelColors = (
        ("1", "-", "1", "-"),
        ("1", "-", "1", "-"),
        ("1", "-", "1", "-"),
        )

        serverChannelMsgs = (
        ("-", "N", "-", " {2}"),
        ("-", "N", "-", " {2}"),
        ("-", "N", "-", " *",  SB + " {1}" + EB + " {2}"),
        )

        serverChannelColors = (
        ("1", "E", "1", "-"),
        ("1", "B", "1", "-"),
        ("1", "B", "1", "D", "-"),
        )

        ret = highestresponse.highestResponse(line)

        if ret.isNotice:

            # Find message type
            if ret.isCTCPNotice:
                isCTCP = True

                if ret.ctcpCommand == "action":
                    isAction = True
                    endMsg   = ret.message
                else:
                    endMsg   = ret.fullMessage

            else:
                endMsg = ret.message

            srcSplit = ret.source.split(".")

            if len(srcSplit) > 1:
                src = srcSplit[-2]
            else:
                src = ret.source

            src2Split = self.master.server.split(".")

            if len(src2Split) > 1:
                src2 = src2Split[-2]
            else:
                src2 = self.master.server

            if src == src2:
                pMsg = serverChannelMsgs[isCTCP + isAction]
                pCol = serverChannelColors[isCTCP + isAction]
            else:
                pMsg = channelMsgs[isCTCP + isAction]
                pCol = channelColors[isCTCP + isAction]

            pMsg = ansicodes.mapColors(pMsg, pCol)

            self.master.log(pMsg.format(ret.target, ret.source, endMsg))