Ejemplo n.º 1
0
    def run(self):
        while True:
            ircmsg = self.ircsock.recv(8192)
            ircmsg = ircmsg.decode(errors='ignore').strip('\n\r')
            if DEBUG:
                print(ircmsg)
            message = IRCMessage(ircmsg)
            if message.isValid():
                if message.msgType == 'PING':
                    self.ping()
                elif message.msgType == 'INVITE':
                    if message.target == self.botnick:
                        self.joinchan(message.channel)
                elif message.msgType == 'PRIVMSG':
                    if 'KeyJoin' == message.msg[:7]:
                        msg_split = message.msg.split()
                        if len(msg_split) == 3:
                            self.joinchan(msg_split[1], msg_split[2])

                    if '옵뿌려!' in message.msg:
                        members = self.listmember(message.channel).split(' ')
                        for mem in members:
                            if mem[0] != '@':
                                self.ircsock.send(
                                    ('MODE ' + message.channel + ' +o ' + mem +
                                     '\n').encode())

                else:
                    if LOG_ENABLE:
                        print(message)
                    if self.msgQueue is not None:
                        self.msgQueue.put({'type': 'irc', 'content': message})
Ejemplo n.º 2
0
 def run(self):
     while True:
         ircmsg = self.ircsock.recv(8192)
         try:
             ircmsg = ircmsg.decode().strip("\n\r")
         except e:
             print(e)
         else:
             print(ircmsg)
             message = IRCMessage(ircmsg)
             if message.isValid():
                 print(message)
                 if message.msgType == "PING":
                     self.ping()
                 else:
                     self.msgQueue.put({"type": "irc", "content": message})
Ejemplo n.º 3
0
 def run(self):
     while True:
         ircmsg = self.ircsock.recv(8192)
         try:
             ircmsg = ircmsg.decode().strip('\n\r')
         except:
             ircmsg = ''
             print("error?!")
             pass
         finally:
             #print(ircmsg)
             message = IRCMessage(ircmsg)
             if message.isValid():
                 #print(message)
                 if message.msgType == 'PING':
                     self.ping()
                 else:
                     self.msgQueue.put({'type': 'irc', 'content': message})