def chatEntry_Activate(self,widget): if widget.get_text() != "": dest = "" serv = self.get_server() #Get the current channel... if len(serv.channels) != 0: #Loop through all of the channels for i in serv.channels: selection = self.TreeView1.get_selection() model, selected = selection.get_selected() sl = self.listTreeStore.get_value(selected, 0).replace(" ","") if sl.startswith("#"): #Select the one that is selected in the treeview if sl == i.cName: dest = i.cName else: if sl == i.cName: dest = i.cName wText = widget.get_text() if wText.startswith(" "): wText = wText[1:] #Add what you said to the TextView import sendMsg if sendMsg.entryBoxCheck(self, wText, serv, self.TreeView1, dest, servers, IRC) == False: IRCHelper.sendMsg(serv,dest,wText) widget.set_text("")
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