Esempio n. 1
0
    def __init__(self):
        print "Nyx 0.1 Alpha"
        print "Initializing window"

        self.listTreeStore = gtk.TreeStore(str, str, gtk.gdk.Color, str) #Name #Icon #Color #Determines whether it's a channel or a User
        self.UserListTreeStore = gtk.ListStore(str, str)

        self.w = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.w.set_title("Nyx 0.1 Alpha")
        self.w.connect("delete_event",self.delete_event)
        self.w.connect("map-event",self.window_focus)
        self.w.connect("focus-in-event",self.window_focus)
        self.w.connect("focus-out-event",self.window_unfocus)

        self.w.set_default_size(750, 450)

        #Load the settings and the theme
        self.settings = settings.loadSettings()
        self.theme = settings.theme()
        self.theme.loadTheme(self.settings.themePath)

        #Setup the form
        from Form import form_stuff
        form_stuff.setup_form(self)
        
        self.w.show()
        #Setup the form END
        
        for server in self.settings.servers:
            if server.autoconnect == True:
                from Form import form_stuff
                form_stuff.connect_server(self, server, IRC, servers)
Esempio n. 2
0
File: sendMsg.py Progetto: dom96/nyx
def entryBoxCheck(self, text, server, listTreeView, selectedChan, servers, IRC):
    if text.startswith("/j") or text.startswith("/join"):
        IRCHelper.join(server,text.replace("/j ","").replace("/join ",""),server.listTreeStore)
        return True
        
    if text.startswith("/msg"):
        splitText = text.replace("/msg ","").split(" ")
        count = 0     
        msg = ""
        for i in splitText:
            if count > 0:
                msg += i + " "
            count += 1                

        IRCHelper.cmdSendMsg(server,splitText[0],msg)
        return True
        
    if text.startswith("/nick"):
        print "NICK " + text.replace("/nick ","")
        server.cSocket.send("NICK " + text.replace("/nick ","") + "\r\n")
        return True     

    if text.startswith("/raw"):
        splitText = text.replace("/raw ","").split(" ")
        rawMsg = ""
        for i in splitText:
            rawMsg += i + " "
                
        server.cSocket.send(rawMsg + "\r\n")
        return True

    """NEED TO MAKE THIS IN A SEPERATE FILE, ALL THE CTCP STUFF."""
    if text.startswith("/version"):
        IRCHelper.sendMsg(server,text.replace("/version ",""),"\x01VERSION\x01")
        #PRIVMSG dom96 :VERSION
        return True
    if text.startswith("/ctcp"):
        splitText = text.replace("/ctcp ","").split()
        try:
            to=splitText[0]#dom96 for example
            ctcp=splitText[1]#VERSION for example
            IRCHelper.sendMsg(server,to,"\x01" + ctcp + "\x01")
        except:
            pass
        return True

    if text.startswith("/me"):
        from IRCLibrary import ResponseParser
        fakecResp=ResponseParser.privMsg()
        fakecResp.msg="ACTION " + text[4:] + ""
        fakecResp.nick=server.cNick
        #Get the selected channel
        model, selected = listTreeView.get_selection().get_selected()
        cSelected = server.listTreeStore.get_value(selected, 0)            
        fakecResp.channel=cSelected

        IRCHelper.sendMsg(server,cSelected,"ACTION " + text[4:] + "")
        return True
    
    if text.startswith("/exec"):
        from IRCLibrary import ResponseParser
        import commands
        output = commands.getoutput(text[5:])
        #Get the selected channel
        model, selected = listTreeView.get_selection().get_selected()
        cSelected = server.listTreeStore.get_value(selected, 0)
        IRCHelper.sendMsg(server,cSelected,output)
        return True

    if text.startswith("/cycle"):
        server.cSocket.send("PART " + text.split(" ")[1] + "\r\n")
        server.cSocket.send("JOIN " + text.split(" ")[1] + "\r\n")
        return True

    if text.startswith("/quit"):
        pDebug("\033[1;34m" + "QUIT :%s" % (text[5:]) + "\\r\\n\033[1;m")
        server.cSocket.send("QUIT :%s\r\n" % (text[5:]))
        return True
        
    if text.startswith("/eval"):
        try:
            output = eval(' '.join(text.split()[1:]))
            pDebug(output)
            IRCHelper.cmdSendMsg(server, selectedChan, str(' '.join(text.split()[1:])) + " = " + str(output))
        except:
            pDebug("Error occured with /eval")
        return True
        
    if text.startswith("/newserver"):
        address = text.split()[1]
        try:
            port = int(text.split()[2])
        except:
            port = 6667
        from settings import settings
        serv = settings.sServer()
        serv.cName = address
        serv.addresses = []
        addr = settings.sServer()
        addr.cAddress = address
        addr.cPort = port
        addr.cSsl = False
        addr.cPass = ""
        serv.addresses.append(addr)
        from Form import form_stuff
        form_stuff.connect_server(self, serv, IRC, servers)
        return True
        
        

    if text.startswith("//"):
        IRCHelper.cmdSendMsg(server, selectedChan, text[1:])
        return True

    if text.startswith("/") and text.startswith("//") == False:
        pDebug("\033[1;34m" + text[1:] + "\\r\\n\033[1;m")
        server.cSocket.send(text[1:] + "\r\n")
        return True

    return False