Ejemplo n.º 1
0
 def connect(self):
     print notify('i','m',"Connecting to %s on port %d..."%(SERVER,PORT))
     sock = self.sock
     sock.connect((SERVER,PORT))
     if self.password:
         sock.send("PASS %s\r\n"%self.password)
     sock.send("NICK %s\r\n"%self.nick)
     sock.send("USER %s %s * :%s\r\n"%(self.nick,SERVER,self.nick))
     sock.send("JOIN %s\r\n"%ROOM)
Ejemplo n.º 2
0
 def connect(self):
     print notify('i', 'm',
                  "Connecting to %s on port %d..." % (SERVER, PORT))
     sock = self.sock
     sock.connect((SERVER, PORT))
     if self.password:
         sock.send("PASS %s\r\n" % self.password)
     sock.send("NICK %s\r\n" % self.nick)
     sock.send("USER %s %s * :%s\r\n" % (self.nick, SERVER, self.nick))
     sock.send("JOIN %s\r\n" % ROOM)
Ejemplo n.º 3
0
def main(client_maker):
    ''' pass a function that constructs a client (subclass of ChatClient)'''
    c = client_maker()
    c.connect()
    try:
        c.loop(1)
    except SASLAuthenticationFailed:
        print notify('!','r',"Authentication failed. Try again.")
        return True
    except KeyboardInterrupt:
        print "Disconnecting..."
        c.disconnect()
    return False
Ejemplo n.º 4
0
    def message_received(self,frm,body):
        print colorize('k',frm+':'),body
        if self.log:
            self.write_log(frm,body)

        msg = None
        cmd_match = re.match("(?:%s\s*[:,;:->]+\s*|!)(\w+)"%self.name,body)
        if cmd_match:
            cmd_name = cmd_match.group(1).lower()
            if cmd_name in self.commands:
                cmd = self.commands[cmd_name]
                try:
                    msg = cmd(self,frm,body)
                except Exception, e:
                    print notify('!','r',"Error processing command: "+cmd_name)
                    print e
Ejemplo n.º 5
0
    def message_received(self, frm, body):
        print colorize('k', frm + ':'), body
        if self.log:
            self.write_log(frm, body)

        msg = None
        cmd_match = re.match("(?:%s\s*[:,;:->]+\s*|!)(\w+)" % self.name, body)
        if cmd_match:
            cmd_name = cmd_match.group(1).lower()
            if cmd_name in self.commands:
                cmd = self.commands[cmd_name]
                try:
                    msg = cmd(self, frm, body)
                except Exception, e:
                    print notify('!', 'r',
                                 "Error processing command: " + cmd_name)
                    print e
Ejemplo n.º 6
0
 def mode(self,frm,usr,msg):
     print notify('i','m',"%s sets mode: %s"%(usr,msg))
Ejemplo n.º 7
0
 def quit(self,frm,msg):
     print notify('i','m',frm+' '+msg)
Ejemplo n.º 8
0
 def part(self,frm,channel):
     print notify('i','m',frm+' left '+channel)
Ejemplo n.º 9
0
 def join(self,frm,channel):
     print notify('i','m',frm+' joined '+channel)
Ejemplo n.º 10
0
 def notice(self,frm,to,msg):
     print notify('i','m',"Notice to %s: %s"%(to,msg))
Ejemplo n.º 11
0
 def mode(self, frm, usr, msg):
     print notify('i', 'm', "%s sets mode: %s" % (usr, msg))
Ejemplo n.º 12
0
 def quit(self, frm, msg):
     print notify('i', 'm', frm + ' ' + msg)
Ejemplo n.º 13
0
 def part(self, frm, channel):
     print notify('i', 'm', frm + ' left ' + channel)
Ejemplo n.º 14
0
 def join(self, frm, channel):
     print notify('i', 'm', frm + ' joined ' + channel)
Ejemplo n.º 15
0
 def notice(self, frm, to, msg):
     print notify('i', 'm', "Notice to %s: %s" % (to, msg))