コード例 #1
0
ファイル: topiclistener.py プロジェクト: IjonTichy/TichyBot
    def processLine(self, line):
        msg333 = "Topic for {} set by {} on {}"

        msg332 = "Topic for " + SB + "{}" + EB + " is ", '"{}"'
        msg332C = "-", "6"

        msgTopic = "Topic for " + SB + "{}" + EB + " changed to ", '"{}"', " by ", "{}"
        msgTopicC = "-", "6", "-", "G"

        ret = ircresponse.IRCResponse(line)

        if ret.command == "332":
            topic = ret.message
            channel = ret.args[1]

            msg = ansicodes.mapColors(msg332, msg332C)

            self.master.log(msg.format(channel, topic))

        if ret.command == "topic":
            setter = ret.source
            channel = ret.args[0]
            topic = ret.message

            msg = ansicodes.mapColors(msgTopic, msgTopicC)

            self.master.log(msg.format(channel, topic, setter))
コード例 #2
0
ファイル: motdlistener.py プロジェクト: IjonTichy/TichyBot
    def processLine(self, line):

        motdMsg = ("-", "M", "-", " {}")
        motdCol = ("1", "D", "1", "-")

        smotdMsg = ("-", "M", "-", " {}")
        smotdCol = ("1", "C", "1", "-")

        emotdMsg = ("-", "M", "-", " {}")
        emotdCol = ("1", "B", "1", "-")

        isofmotd = False

        ret = ircresponse.IRCResponse(line)

        if ret.command == "372":   # MOTD
            isofmotd = True
            msg = motdMsg
            col = motdCol

        elif ret.command == "375": # start MOTD
            isofmotd = True
            msg = smotdMsg
            col = smotdCol


        elif ret.command == "376": # end MOTD
            isofmotd = True
            msg = emotdMsg
            col = emotdCol

        if isofmotd:
            retmsg = ansicodes.mapColors(msg, col)

            self.master.log(retmsg.format(ret.message))
コード例 #3
0
ファイル: quitlistener.py プロジェクト: IjonTichy/TichyBot
    def processLine(self, line):

        leaveMsg = ("{} ", "[", "{}", "]", " has quit ", "(", "{}", ")")
        leaveCol = ("6", "A", "6", "A", "-", "A", "-", "A")

        ret = ircresponse.IRCResponse(line)

        if ret.command == "quit":

            msg = ansicodes.mapColors(leaveMsg, leaveCol)

            self.master.log(msg.format(ret.source, ret.sourceFull, ret.message) )
コード例 #4
0
ファイル: nicklistener.py プロジェクト: IjonTichy/TichyBot
    def processLine(self, line):

        leaveMsg = ("{}", " is now known as ", "{}")
        leaveCol = ("6", "-", "G")

        ret = ircresponse.IRCResponse(line)

        if ret.command == "nick":
            newNick = ret.args[0]

            msg = ansicodes.mapColors(leaveMsg, leaveCol)

            self.master.log(msg.format(ret.source, newNick))
コード例 #5
0
ファイル: kicklistener.py プロジェクト: IjonTichy/TichyBot
    def processLine(self, line):

        kickMsg = ("{}", " has kicked " + SB + "{}" + EB + " from " + SB + "{}" + EB, " (", "{}", ")")
        kickCol = ("6", "-", "A", "-", "A")
        ret = ircresponse.IRCResponse(line)

        if ret.command == "kick":

            channel, kicked = ret.args[0:2]

            msg = ansicodes.mapColors(kickMsg, kickCol)

            self.master.log(msg.format(ret.source, kicked, channel, ret.message))
コード例 #6
0
ファイル: modelistener.py プロジェクト: IjonTichy/TichyBot
    def processLine(self, line):

        modeMsg = ("mode/", "{} ", "[", "{}", "]", " by " + SB + "{}" + EB)
        modeCol = ("-",     "6",   "A", "-",  "A", "-")

        myModeMsg = ("mode/", "{} ", "[", "{}", "]")
        myModeCol = ("-",     "6",   "A", "-",  "A")

        ret = ircresponse.IRCResponse(line)

        if ret.command == "mode":

            setter = ret.source
            recip  = ret.args[0]
            args   = ret.args[1:]

            if setter == recip:
                msg = ansicodes.mapColors(myModeMsg, myModeCol)
            else:
                msg = ansicodes.mapColors(modeMsg, modeCol)

            self.master.log(msg.format(recip, " ".join(args), setter) )
コード例 #7
0
ファイル: partlistener.py プロジェクト: IjonTichy/TichyBot
    def processLine(self, line):

        leaveMsg = ("{}", " [", "{}", "]", " has left " + SB + "{}" + EB, " (", "{}", ")")
        leaveCol = ("G", "A", "6", "A", "-", "A", "-", "A")

        ret = ircresponse.IRCResponse(line)

        if ret.command == "part":

            target = ret.args[0]

            msg = ansicodes.mapColors(leaveMsg, leaveCol)

            self.master.log(msg.format(ret.source, ret.sourceFull, target, ret.message))
コード例 #8
0
ファイル: noticelistener.py プロジェクト: IjonTichy/TichyBot
    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))