def get_irc_socket_object(self):
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        sock.settimeout(10)

        self.sock = sock

        try:
            sock.connect((self.server['host'], self.server['port']))
        except:
            pp('Cannot connect to server (%s:%s).' % (self.server['host'], self.server['port']), 'error')
            sys.exit()

        sock.settimeout(None)

        sock.send('USER %s\r\n' % self.server['user'])
        sock.send('PASS %s\r\n' % self.server['oauthpass'])
        sock.send('NICK %s\r\n' % self.server['user'])

        if self.check_login_status(sock.recv(1024)):
            pp('Login successful.')
        else:
            pp('Login unsuccessful. (hint: make sure your oauth token is set in self.config/self.config.py).', 'error')
            thread.exit()
        
        self.join_channel()
        
        return sock
 def leave_channel(self):
     pp('Leaving channel "%s".' % self.channel.name)
     self.sock.send('PART %s\r\n' % self.channel.name)
     pp('Leaving channel "%s".' % self.channel.name)
     return True
 def join_channel(self):
     pp('Joining channel "%s".' % self.channel.name)
     self.sock.send('JOIN %s\r\n' % self.channel.name)
     pp('Joined channel "%s".' % self.channel.name)
     return True