Пример #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)
Пример #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)
Пример #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
Пример #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
Пример #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
Пример #6
0
 def mode(self,frm,usr,msg):
     print notify('i','m',"%s sets mode: %s"%(usr,msg))
Пример #7
0
 def quit(self,frm,msg):
     print notify('i','m',frm+' '+msg)
Пример #8
0
 def part(self,frm,channel):
     print notify('i','m',frm+' left '+channel)
Пример #9
0
 def join(self,frm,channel):
     print notify('i','m',frm+' joined '+channel)
Пример #10
0
 def notice(self,frm,to,msg):
     print notify('i','m',"Notice to %s: %s"%(to,msg))
Пример #11
0
 def mode(self, frm, usr, msg):
     print notify('i', 'm', "%s sets mode: %s" % (usr, msg))
Пример #12
0
 def quit(self, frm, msg):
     print notify('i', 'm', frm + ' ' + msg)
Пример #13
0
 def part(self, frm, channel):
     print notify('i', 'm', frm + ' left ' + channel)
Пример #14
0
 def join(self, frm, channel):
     print notify('i', 'm', frm + ' joined ' + channel)
Пример #15
0
 def notice(self, frm, to, msg):
     print notify('i', 'm', "Notice to %s: %s" % (to, msg))