def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL: if menuItemID == 0: self.dlg = ServersDialog(self) self.dlg.show() #ts3.printMessageToCurrentTab(str(self.filters)) elif menuItemID == 1: _schid = ts3.getCurrentServerConnectionHandlerID() (error, _clid) = ts3.getClientID(_schid) (error, _ip) = ts3.getConnectionVariableAsString( _schid, _clid, ts3defines.ConnectionProperties.CONNECTION_SERVER_IP) (error, _port) = ts3.getConnectionVariableAsString( _schid, _clid, ts3defines.ConnectionProperties.CONNECTION_SERVER_PORT) url = "" if _port != "": _url = self.config['GENERAL'][ 'api'] + "serverlist/result/server/ip/" + _ip + ":" + _port + "/" else: _url = self.config['GENERAL'][ 'api'] + "serverlist/result/server/ip/" + _ip + "/" ts3.printMessageToCurrentTab( str("Navigating to \"" + _url + "\"")) webbrowser.open(_url)
def onConnectionInfoEvent(self, serverConnectionHandlerID, clientID): try: if not self.requested == clientID: return (error, ip) = ts3.getConnectionVariableAsString( serverConnectionHandlerID, clientID, ts3defines.ConnectionProperties.CONNECTION_CLIENT_IP) if error == ts3defines.ERROR_ok: self.ip = ip self.nwm = QNetworkAccessManager() self.nwm.connect("finished(QNetworkReply*)", self.onMainReply) self.nwm.get( QNetworkRequest( QUrl(self.cfg['api']['main'].replace("{ip}", ip)))) if PluginHost.cfg.getboolean("general", "verbose"): ts3.printMessageToCurrentTab( self.cfg['api']['main'].replace("{ip}", ip)) else: (e, msg) = ts3.getErrorMessage(error) ts3.printMessageToCurrentTab( "[[color=orange]WARNING[/color]] [color=red]ISPValidator could not resolve the IP for '%s' (Reason: %s)" % (self.clientURL(serverConnectionHandlerID, clientID), msg)) except: ts3.printMessageToCurrentTab( "[[color=orange]WARNING[/color]] [color=red]ISPValidator could not resolve the IP for '%s' (Reason: %s)" % (self.clientURL(serverConnectionHandlerID, clientID), format_exc()))
def backup(self, serverConnectionHandlerID): ownID = ts3lib.getClientID(serverConnectionHandlerID)[1] ip = ts3lib.getConnectionVariableAsString( serverConnectionHandlerID, ownID, ts3defines.ConnectionProperties.CONNECTION_SERVER_IP)[1] self.cfg['data']['ip'] = ip port = ts3lib.getConnectionVariableAsUInt64( serverConnectionHandlerID, ownID, ts3defines.ConnectionProperties.CONNECTION_SERVER_PORT)[1] self.cfg['data']['port'] = str(port) serverPassword = ts3lib.getServerConnectInfo(serverConnectionHandlerID, 256)[3] self.currentServerPW = serverPassword nickname = ts3lib.getClientSelfVariableAsString( serverConnectionHandlerID, ts3defines.ClientProperties.CLIENT_NICKNAME)[1] self.cfg.set('data', 'nickname', nickname) tabID = ts3defines.PluginConnectTab.PLUGIN_CONNECT_TAB_CURRENT self.cfg['data']['tabID'] = str(tabID) channelID = ts3lib.getChannelOfClient(serverConnectionHandlerID, ownID)[1] channelPassword = ts3lib.getChannelConnectInfo( serverConnectionHandlerID, channelID, 256)[2] self.currentChannelPW = channelPassword return
def onConnectStatusChangeEvent(self, schid, newStatus, errorNumber): if newStatus == ts3defines.ConnectStatus.STATUS_CONNECTED: (error, ownID) = ts3lib.getClientID(schid) (error, ip) = ts3lib.getConnectionVariableAsString( schid, ownID, ts3defines.ConnectionProperties.CONNECTION_SERVER_IP) self.cfg.set('data', 'ip', ip) (error, port) = ts3lib.getConnectionVariableAsInt( schid, ownID, ts3defines.ChannelProperties.CONNECTION_SERVER_PORT) self.cfg.set('data', 'ip', port) (error, nickname) = ts3lib.getClientSelfVariableAsString( schid, ts3defines.ClientProperties.CLIENT_NICKNAME) self.cfg.set('data', 'nickname', nickname) elif newStatus == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: pass
def setStatus(self, schid): err, ownid = ts3.getClientID(schid) err, schids = ts3.getServerConnectionHandlerList() regex = re.compile(r'.*(<{0}>.*</{0}>).*'.format(self.tag), re.IGNORECASE) host = "" port = 9987 pw = "" name = "" nick = "" err, host, port, pw = ts3.getServerConnectInfo(schid) err, name = ts3.getServerVariable( schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_NAME) err, nick = ts3.getServerVariable( schid, 83 ) # ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_NICKNAME if err == ts3defines.ERROR_ok and nick.strip(): nick = nick.split(":") err, ip = ts3.getConnectionVariableAsString( schid, ownid, ts3defines.ConnectionProperties.CONNECTION_SERVER_IP) if err != ts3defines.ERROR_ok or not ip.strip(): err, ip = ts3.getServerVariableAsString( schid, ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_IP) err, port = ts3.getConnectionVariableAsString( schid, ownid, ts3defines.ConnectionProperties.CONNECTION_SERVER_PORT) if err != ts3defines.ERROR_ok or not port or port < 1: err, port = ts3.getServerVariableAsString( schid, ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_PORT) for tab in schids: err, meta_data = ts3.getClientSelfVariable( tab, ts3defines.ClientProperties.CLIENT_META_DATA) meta_data = regex.sub("", meta_data) if tab == schid: ts3.setClientSelfVariableAsInt( tab, ts3defines.ClientPropertiesRare.CLIENT_AWAY, ts3defines.AwayStatus.AWAY_NONE) else: err, away = ts3.getClientSelfVariable( tab, ts3defines.ClientPropertiesRare.CLIENT_AWAY) if away != ts3defines.AwayStatus.AWAY_ZZZ: ts3.setClientSelfVariableAsInt( tab, ts3defines.ClientPropertiesRare.CLIENT_AWAY, ts3defines.AwayStatus.AWAY_ZZZ) if self.cfg.getboolean('general', 'enabled'): if host: newmeta = xml.Element(self.tag) c = xml.SubElement(newmeta, "tab") c.set("i", str(schid)) if name: c.text = escape(name.strip()) c.set("h", escape(host)) if port and port != 9987: c.set("port", "{}".format(port)) if pw and self.cfg.getboolean('general', 'pw'): c.set("p", pw) # if ip and ip.strip(): c.set("ip", ip) # if nick: c.set("nick", ":".join(nick)) meta_data = "{old}{new}".format( old=meta_data, new=xml.tostring(newmeta).decode("utf-8")) # meta_data = "{}<server>{}{}</server>".format(meta_data, ip, ":" + port if port else "") try: name = name[:78] + (name[78:] and '..') except: pass _away_message = self.cfg.get('general', 'status') if "{" in _away_message: _away_message = _away_message\ .replace('{host}', host if host else "")\ .replace('{nick}', nick[0] if nick and len(nick) > 0 else "")\ .replace('{name}', name if name else "")\ .replace('{nickname}', nick[0] if nick else name)\ .replace('{ip}', ip if ip else "")\ .replace('{port}', str(port) if port else "") err, away_message = ts3.getClientSelfVariable( tab, ts3defines.ClientPropertiesRare.CLIENT_AWAY_MESSAGE) if away_message != _away_message: ts3.setClientSelfVariableAsString( tab, ts3defines.ClientPropertiesRare.CLIENT_AWAY_MESSAGE, _away_message) ts3.setClientSelfVariableAsString( tab, ts3defines.ClientProperties.CLIENT_META_DATA, meta_data) ts3.flushClientSelfUpdates(tab)
def processCommand(self, schid, keyword): args = keyword.split() cmd = args.pop(0).lower() if cmd == "com": command = " ".join(args) self.retcode = ts3lib.createReturnCode(); self.schid = schid err = ts3lib.requestSendClientQueryCommand(schid, command, self.retcode) if err != ts3defines.ERROR_ok: (_err, msg) = ts3lib.getErrorMessage(err) ts3lib.printMessageToCurrentTab("(%s) %s: %s"%(schid, command, msg)) elif cmd == "req": clid = int(args.pop(0)) self.req = clid ts3lib.requestClientVariables(schid, clid) elif cmd == "reqcon": clid = int(args.pop(0)) self.req = clid ts3lib.requestConnectionInfo(schid, clid) elif cmd == "self": err, clid = ts3lib.getClientID(schid) ts3lib.printMessageToCurrentTab("[b]{}'s Self Variables:".format(clientURL(schid, clid))) open(self.filepath, 'w').close() min=0;max=64 if len(args): min = int(args.pop(0)) if len(args): max = int(args.pop(0)) for i in range(min, max): msg = "%s"%i values = set(item.value for item in ts3enums.ClientProperties) if i in values: msg += " ({})".format(ts3enums.ClientProperties(i)) msg += ": " (err, var) = ts3lib.getClientSelfVariableAsString(schid, i) if err != ts3defines.ERROR_ok: (_err, var) = ts3lib.getErrorMessage(err) msg += var with open(self.filepath, "a", encoding="utf-8") as myfile: myfile.write(msg+"\n") ts3lib.printMessageToCurrentTab(msg) elif cmd == "client": clid = int(args.pop(0)) ts3lib.printMessageToCurrentTab("[b]{}'s Client Variables:".format(clientURL(schid, clid))) open(self.filepath, 'w').close() min=0;max=64 if len(args): min = int(args.pop(0)) if len(args): max = int(args.pop(0)) for i in range(min, max): msg = "%s"%i values = set(item.value for item in ts3enums.ClientProperties) if i in values: msg += " ({})".format(ts3enums.ClientProperties(i)) msg += ": " (err, var) = ts3lib.getClientVariableAsString(schid, clid, i) if err != ts3defines.ERROR_ok: (_err, var) = ts3lib.getErrorMessage(err) msg += var with open(self.filepath, "a", encoding="utf-8") as myfile: myfile.write(msg+"\n") ts3lib.printMessageToCurrentTab(msg) elif cmd == "con": clid = int(args.pop(0)) ts3lib.printMessageToCurrentTab("[b]{}'s Connection Variables:".format(clientURL(schid, clid))) open(self.filepath, 'w').close() min=0;max=65 if len(args): min = int(args.pop(0)) if len(args): max = int(args.pop(0)) for i in range(min, max): msg = "%s"%i values = set(item.value for item in ts3enums.ConnectionProperties) if i in values: msg += " ({})".format(ts3enums.ConnectionProperties(i)) msg += ": " (err, var) = ts3lib.getConnectionVariableAsString(schid, clid, i) if err != ts3defines.ERROR_ok: (_err, var) = ts3lib.getErrorMessage(err) msg += var with open(self.filepath, "a", encoding="utf-8") as myfile: myfile.write(msg+"\n") ts3lib.printMessageToCurrentTab(msg) else: return False return True