Example #1
0
 def endofmotd(self, server, me, msg):
   """Used instead of a connect callback since it invokes too early."""
   self.client.send("MODE %s +B" % me)
   helpers.nick(self.client, "marzipan")
   helpers.join(self.client, "#playground")
   if self.client.logchan:
     helpers.join(self.client, self.client.logchan)
Example #2
0
 def endofmotd(self, server, me, msg):
     """Used instead of a connect callback since it invokes too early."""
     self.client.send("MODE %s +B" % me)
     helpers.nick(self.client, "marzipan")
     helpers.join(self.client, "#playground")
     if self.client.logchan:
         helpers.join(self.client, self.client.logchan)
Example #3
0
 def updateProfile(self):
     me = self.mainwindow.profile()
     handle = me.handle
     try:
         helpers.nick(self.cli, handle)
     except socket.error:
         self.setConnectionBroken()
     self.updateMood()
Example #4
0
 def updateProfile(self):
     me = self.mainwindow.profile()
     handle = me.handle
     try:
         helpers.nick(self.cli, handle)
     except socket.error:
         self.setConnectionBroken()
     self.mainwindow.closeConversations(True)
     self.updateMood()
Example #5
0
    def connect(self):
        """ initiates the connection to the server set in self.host:self.port
        and returns a generator object.

        >>> cli = IRCClient(my_handler, host="irc.freenode.net", port=6667)
        >>> g = cli.connect()
        >>> while 1:
        ...     g.next()

        """
        try:
            logging.info('connecting to %s:%s' % (self.host, self.port))
            self.socket.connect(("%s" % self.host, self.port))
            if self.blocking:
                # this also overrides default timeout
                self.socket.setblocking(1)
            else:
                self.socket.setblocking(0)

            helpers.nick(self, self.nick)
            helpers.user(self, self.nick, self.real_name)

            if self.connect_cb:
                self.connect_cb(self)

            buffer = bytes()
            while not self._end:
                try:
                    buffer += self.socket.recv(1024)
                except socket.error as e:
                    try:  # a little dance of compatibility to get the errno
                        errno = e.errno
                    except AttributeError:
                        errno = e[0]
                    if not self.blocking and errno == 11:
                        pass
                    else:
                        raise e
                else:
                    data = buffer.split(bytes("\n", "ascii"))
                    buffer = data.pop()

                    for el in data:
                        prefix, command, args = parse_raw_irc_command(el)
                        try:
                            self.command_handler.run(command, prefix, *args)
                        except CommandError:
                            # error will of already been loggingged by the handler
                            pass

                yield True
        finally:
            if self.socket:
                logging.info('closing socket')
                self.socket.close()
Example #6
0
 def updateProfile(self):
     me = self.mainwindow.profile()
     handle = me.handle
     try:
         helpers.nick(self.cli, handle)
     except socket.error:
         self.setConnectionBroken()
     self.mainwindow.closeConversations(True)
     self.mainwindow.doAutoIdentify()
     self.mainwindow.autoJoinDone = False
     self.mainwindow.doAutoJoins()
     self.updateMood()
Example #7
0
    def connect(self):
        """ initiates the connection to the server set in self.host:self.port 
        """

        logging.info('connecting to %s:%s' % (self.host, self.port))
        self.socket.connect(("%s" % self.host, self.port))
        if not self.blocking:
            self.socket.setblocking(0)
        if self.timeout:
            self.socket.settimeout(self.timeout)
        helpers.nick(self, self.nick)
        helpers.user(self, self.nick, self.real_name)

        if self.connect_cb:
            self.connect_cb(self)
Example #8
0
    def connect(self):
        """ initiates the connection to the server set in self.host:self.port 
        """

        logging.info('connecting to %s:%s' % (self.host, self.port))
        self.socket.connect(("%s" % self.host, self.port))
        if not self.blocking:
            self.socket.setblocking(0)
        if self.timeout:
            self.socket.settimeout(self.timeout)
        helpers.nick(self, self.nick)
        helpers.user(self, self.nick, self.real_name)

        if self.connect_cb:
            self.connect_cb(self)
Example #9
0
    def connect(self):
        """ initiates the connection to the server set in self.host:self.port 
        and returns a generator object. 

        >>> cli = IRCClient(my_handler, host="irc.freenode.net", port=6667)
        >>> g = cli.connect()
        >>> while 1:
        ...     g.next()

        """
        try:
            log.info("connecting to %s:%s" % (self.host, self.port))
            self.socket.connect(("%s" % self.host, self.port))
            if not self.blocking:
                self.socket.setblocking(0)

            helpers.nick(self, self.nick)
            helpers.user(self, self.nick, self.real_name)

            if self.connect_cb:
                self.connect_cb(self)

            buffer = ""
            while not self._end:
                try:
                    buffer += self.socket.recv(1024)
                except socket.error, e:
                    if not self.blocking and e[0] == 11:
                        pass
                    else:
                        raise e
                else:
                    data = buffer.split("\n")
                    buffer = data.pop()

                    for el in data:
                        prefix, command, args = parse_raw_irc_command(el)
                        try:
                            self.command_handler.run(command, prefix, *args)
                        except CommandError:
                            # error will of already been logged by the handler
                            pass

                yield True
        finally:
            if self.socket:
                log.info("closing socket")
                self.socket.close()
Example #10
0
 def nicknameinuse(self, server, cmd, nick, msg):
     newnick = "pesterClient%d" % (random.randint(100,999))
     helpers.nick(self.client, newnick)
     self.parent.nickCollision.emit(nick, newnick)
Example #11
0
 def nicknameinuse(self, server, something, nick, msg):
     helpers.nick(self.client, nick + str(random.randint(0, 10000)))
Example #12
0
 def nicknameinuse(self, server, cmd, nick, msg):
     newnick = "pesterClient%d" % (random.randint(100,999))
     helpers.nick(self.client, newnick)
     self.parent.nickCollision.emit(nick, newnick)
 def nicknameinuse(self, server, wtf, nick, reason):
     helpers.nick(self.client, nick+'_')
Example #14
0
 def nicknameinuse(self, nick, *message):
     print("Nickname in use", nick, message)
     helpers.nick(self.client, self.client.handler.generate_nick())