예제 #1
0
파일: writer.py 프로젝트: halilb/irc-client
 def run(self):
     while True:
         if self.threadQueue.qsize() > 0:
             queue_message = self.threadQueue.get()
             outgoing = self.outgoing_parser(queue_message)
             if outgoing:
                 outgoing += "\n"
                 print("OUTGOING: " + outgoing)
                 try:
                     self.csoc.send(outgoing)
                 except socket.error:
                     self.csoc.close()
                     break
             else:
                 incoming_message = IncomingMessage(Types.originTypes.LOCAL)
                 incoming_message.type = Types.responseTypes.SYSTEM
                 incoming_message.text = "Command Error"
                 self.screenQueue.put(incoming_message)
예제 #2
0
파일: reader.py 프로젝트: halilb/irc-client
    def incoming_parser(self, data):
        incoming_message = IncomingMessage(Types.originTypes.SERVER)

        if len(data) == 0:
            return

        print("INCOMING: " + data)

        cmd = data[0:3]
        rest = data[4:]

        if cmd == "TIC":
            self.threadQueue.put("/tic")
            return
        if cmd == "TOC":
            return

        if cmd == "SAY":
            tempArr = rest.split(":")
            incoming_message.type = Types.responseTypes.PUBLIC_MESSAGE
            incoming_message.nickname = tempArr[0]
            incoming_message.text = tempArr[1]
        if cmd == "MSG":
            tempArr = rest.split(":")
            incoming_message.type = Types.responseTypes.PRIVATE_MESSAGE
            incoming_message.nickname = tempArr[0]
            incoming_message.text = tempArr[1]
        elif cmd == "HEL":
            incoming_message.type = Types.responseTypes.NEW_LOGIN
            incoming_message.nickname = rest
        elif cmd == "SYS":
            incoming_message.type = Types.responseTypes.SYSTEM
            incoming_message.text = rest
        elif cmd == "REJ":
            incoming_message.type = Types.responseTypes.REJECTED
            incoming_message.nickname = rest
        elif cmd == "MNO":
            incoming_message.type = Types.responseTypes.PRIVATE_MES_FAILED
            incoming_message.nickname = rest
        elif cmd == "LSA":
            incoming_message.type = Types.responseTypes.LIST
            incoming_message.nickname = rest
        elif cmd == "ERL":
            incoming_message.type = Types.responseTypes.NOT_SIGNED_IN
        elif cmd == "ERR":
            incoming_message.type = Types.responseTypes.ERROR

        return incoming_message