Esempio n. 1
0
 def loseConnection(self, reason="No reason"):
     self.sendLine(Line('QUIT', [reason]))
     self.logLine(Line('ERROR', ['Closing Link: %s[%s] (%s)'
                                 % (self.nick,
                                    self.user, reason)]))
     # XXX wait some time?
     Irc.loseConnection(self)
Esempio n. 2
0
 def sendLine(self, line):
     """send line to server, and add outbound requests to lists."""
     if line.cmd == 'PING':
         self.pingreq[line.args[0]] = True
     if line.cmd == 'WHO':
         self.addRequest(self.whoreq, line)
     if line.cmd == 'TOPIC' and len(line.args) == 1:
         self.addRequest(self.topicreq, line)
     if line.cmd == 'MODE' and len(line.args) == 1:
         self.addRequest(self.modereq, line)
     if line.cmd == 'NAMES':
         self.addRequest(self.namesreq, line)
     if line.cmd == 'AWAY':
         if len(line.args) > 0 and line.args[0] != '': # if setting away:
             self.awaymsg = line.args[0]
     if line.cmd in ["PRIVMSG", "NOTICE"]:
         # need to log self. simulate server info:
         fakeargs = line.args
         fakeargs[1] = "+" + fakeargs[1] # we are "identified"
         fakeline = Line(cmd=line.cmd, args=fakeargs,
                           prefix=self.clientprefix, time=w3c_timestamp())
         # log the line *after* the line currently being processed
         reactor.callLater(0, self.logLine, fakeline)
     if dbg: info("Sent to server: %s" % line)
     Irc.sendLine(self, line)
Esempio n. 3
0
    def sendLine(self, line):
        """send line to server, and add outbound requests to lists."""
        if line.cmd == 'PING':
            self.pingreq[line.args[0]] = True
        if line.cmd == 'WHO':
            self.addRequest(self.whoreq, line)
        if line.cmd == 'TOPIC' and len(line.args) == 1:
            self.addRequest(self.topicreq, line)
        if line.cmd == 'MODE' and len(line.args) == 1:
            self.addRequest(self.modereq, line)
        if line.cmd == 'NAMES':
            self.addRequest(self.namesreq, line)
        if line.cmd == 'AWAY':
            if len(line.args) > 0 and line.args[0] != '': # if setting away:
                self.awaymsg = line.args[0]

        if dbg: info("Sent to server: %s" % line)
        Irc.sendLine(self, line)
Esempio n. 4
0
    def handleReceived(self, line):
        if line.prefix:
            nick,_ = parseprefix(line.prefix)
        else:
            nick = None
        relatedbefore = self.nick2channels.get(nick, [])
        Irc.handleReceived(self, line)
# FIXME: Many commands missing here!
        if line.cmd in ('NICK', 'QUIT'):
            if self.interestingchannel in relatedbefore:
                self.sink.handleReceived(line)
        elif line.cmd in ('JOIN','PART','KICK','PRIVMSG','NOTICE','TOPIC'):
            if line.args[0].lower() == self.interestingchannel:
                self.sink.handleReceived(line)
        elif line.cmd in ('366','332','333','329'):
            if line.args[1].lower() == self.interestingchannel:
                self.sink.handleReceived(line)
        elif line.cmd in ('353',):
            if line.args[2].lower() == self.interestingchannel:
                self.sink.handleReceived(line)