def setChannelCommander(self, schid, enabled): ts3lib.setClientSelfVariableAsInt( schid, ts3lib.ClientPropertiesRare.CLIENT_IS_CHANNEL_COMMANDER, enabled) returnCode = ts3lib.createReturnCode() self.retcodes.append(returnCode) ts3lib.flushClientSelfUpdates(schid, returnCode)
def tick(self): self.current = not self.current ts3lib.setClientSelfVariableAsInt( self.schid, ts3lib.ClientPropertiesRare.CLIENT_IS_CHANNEL_COMMANDER, self.current) ts3lib.flushClientSelfUpdates(self.schid)
def onClientChannelGroupChangedEvent(self, schid, channelGroupID, channelID, clientID, invokerClientID, invokerName, invokerUniqueIdentity): (err, ownID) = ts3lib.getClientID(schid) if clientID != ownID: return (err, val) = ts3lib.getClientNeededPermission(schid, "b_client_use_channel_commander") if val: return ts3lib.setClientSelfVariableAsInt(schid, ts3defines.ClientPropertiesRare.CLIENT_IS_CHANNEL_COMMANDER, 1) ts3lib.flushClientSelfUpdates(schid, self.retcode)
def onClientKickFromChannelEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, kickerID, kickerName, kickerUniqueIdentifier, kickMessage): (error, ownid) = ts3lib.getClientID(schid) if self.insupport == clientID and oldChannelID == self.cursupchan and kickerID == ownid: if self.wasmuted: ts3lib.setClientSelfVariableAsInt(schid, ts3defines.ClientProperties.CLIENT_OUTPUT_MUTED, 1);ts3lib.flushClientSelfUpdates(schid) ts3lib.requestClientMove(schid, ownid, self.oldchan, "") ts3lib.printMessageToCurrentTab("Not longer in support with client #{0} in channel #{1}".format(self.insupport, self.cursupchan)) self.insupport = 0;self.cursupchan = 0;self.oldchan = 0 if self.debug: ts3lib.printMessageToCurrentTab("onClientKickFromChannelEvent: insupport: {0} | cursupchan: {1} | oldchan: {2}".format(self.insupport,self.cursupchan, self.oldchan))
def tick(self): (err, commander) = ts3lib.getClientSelfVariable( self.schid, ts3defines.ClientPropertiesRare.CLIENT_IS_CHANNEL_COMMANDER) ts3lib.setClientSelfVariableAsInt( self.schid, ts3lib.ClientPropertiesRare.CLIENT_IS_CHANNEL_COMMANDER, not commander) ts3lib.flushClientSelfUpdates(self.schid, self.retcode)
def stopsup(self, schid=1): (error, ownid) = ts3lib.getClientID(schid) ts3lib.requestClientMove(schid, ownid, self.oldchan, "") if self.wasmuted: ts3lib.setClientSelfVariableAsInt( schid, ts3defines.ClientProperties.CLIENT_OUTPUT_MUTED, 1) if self.debug: ts3lib.printMessageToCurrentTab( "Not longer in support with client #{0} in channel #{1}". format(self.insupport, self.cursupchan)) self.insupport = 0 self.cursupchan = 0 self.oldchan = 0
def onClientChannelGroupChangedEvent(self, schid, channelGroupID, channelID, clientID, invokerClientID, invokerName, invokerUniqueIdentity): if not self.toggle: return (error, cID) = ts3lib.getClientID(schid) if error == ts3defines.ERROR_ok: if cID == clientID: (error, cgID) = ts3lib.getClientVariableAsInt( schid, cID, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) for _group in self.smgroup: if cgID == _group: ts3lib.setClientSelfVariableAsInt( schid, ts3defines.ClientPropertiesRare. CLIENT_IS_CHANNEL_COMMANDER, 1) ts3lib.flushClientSelfUpdates(schid) break
def restoreTab(self, tab=None): try: if not tab: self._timers.pop(0) schid, tab = self._tabs.popitem() args = [ PluginConnectTab.PLUGIN_CONNECT_TAB_NEW_IF_CURRENT_CONNECTED if self.first else PluginConnectTab.PLUGIN_CONNECT_TAB_NEW, # connectTab: int, tab["name"], # serverLabel: Union[str, unicode], tab["address"], # serverAddress: Union[str, unicode], tab["pw"], # serverPassword: Union[str, unicode], tab["nick"], # nickname: Union[str, unicode], tab["cpath"], # channel: Union[str, unicode], tab["cpw"], # channelPassword: Union[str, unicode] "", # captureProfile: Union[str, unicode], "", # playbackProfile: Union[str, unicode] "", # hotkeyProfile: Union[str, unicode], "Default Sound Pack (Female)", # soundPack tab["uid"], # userIdentity: Union[str, unicode], tab["token"], # oneTimeKey: Union[str, unicode], tab["nick_phonetic"] # phoneticName: Union[str, unicode] ] if self.first: self.first = False print("ts3lib.guiConnect({})".format("\", \"".join( str(x) for x in args))) err, schid = ts3lib.guiConnect(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12], args[13]) print("TAB: ", tab) ts3lib.setClientSelfVariableAsInt( schid, ClientProperties.CLIENT_INPUT_MUTED, tab["input_muted"]) ts3lib.setClientSelfVariableAsInt( schid, ClientProperties.CLIENT_OUTPUT_MUTED, int(tab["output_muted"])) ts3lib.requestChannelSubscribeAll(schid) except: ts3lib.logMessage(format_exc(), LogLevel.LogLevel_ERROR, "pyTSon", 0)
def onClientMoveMovedEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moverID, moverName, moverUniqueIdentifier, moveMessage): try: (error, ownid) = ts3lib.getClientID(schid) (error, ownchan) = ts3lib.getChannelOfClient(schid, ownid) (error, afk) = ts3lib.getClientVariableAsInt(schid, ownid, ts3defines.ClientPropertiesRare.CLIENT_AWAY) if self.debug: ts3lib.printMessageToCurrentTab("onClientMoveMovedEvent: 1 | insupport: {0} | cursupchan: {1} | oldchan: {2}".format(self.insupport,self.cursupchan, self.oldchan)) if self.debug: ts3lib.printMessageToCurrentTab("{0} {1} {2}".format(ownchan, self.afkchan, afk)) if self.insupport == 0 and moverUniqueIdentifier == self.supbot and newChannelID == self.supchanmain and not ownchan == self.afkchan and not afk: for c in self.supchans: (error, clients) = ts3lib.getChannelClientList(schid, c) if len(clients) > 0: continue else: # ts3lib.sendPluginCommand(schid, "S3NDuZ3r", ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER, targetIDs, returnCode) for ch in self.supchans: (error, clients) = ts3lib.getChannelClientList(schid, ch) if clientID in clients: return ts3lib.requestClientMove(schid, clientID, c, "") ts3lib.requestClientMove(schid, ownid, c, "") (error, muted) = ts3lib.getClientVariableAsInt(schid, ownid, ts3defines.ClientProperties.CLIENT_OUTPUT_MUTED) self.wasmuted = muted ts3lib.setClientSelfVariableAsInt(schid, ts3defines.ClientProperties.CLIENT_OUTPUT_MUTED, 0);ts3lib.flushClientSelfUpdates(schid) self.insupport = clientID;self.cursupchan = c;self.oldchan = ownchan if self.debug: ts3lib.printMessageToCurrentTab("Now in support with client #{0} in channel #{1}".format(clientID, c)) return ts3lib.printMessageToCurrentTab("No free support channel found for client #{0}! Please try manually.".format(clientID)) elif self.insupport == clientID and oldChannelID == self.cursupchan and moverID == ownid: if self.wasmuted: ts3lib.setClientSelfVariableAsInt(schid, ts3defines.ClientProperties.CLIENT_OUTPUT_MUTED, 1);ts3lib.flushClientSelfUpdates(schid) ts3lib.requestClientMove(schid, ownid, self.oldchan, "") ts3lib.printMessageToCurrentTab("Not longer in support with client #{0} in channel #{1}".format(self.insupport, self.cursupchan)) self.insupport = 0;self.cursupchan = 0;self.oldchan = 0 if self.debug: ts3lib.printMessageToCurrentTab("onClientMoveMovedEvent: 2 | insupport: {0} | cursupchan: {1} | oldchan: {2}".format(self.insupport,self.cursupchan, self.oldchan)) except: try: from traceback import format_exc;ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0);pass except: try: from traceback import format_exc;ts3lib.printMessageToCurrentTab(format_exc()) except: try: from traceback import format_exc;print(format_exc()) except: print("Unknown Error")
def setStatus(self, schid): try: err, ownid = ts3.getClientID(schid) err, schids = ts3.getServerConnectionHandlerList() regex = re.compile(r'.*(<{0}>.*</{0}>).*'.format(self.tag), re.IGNORECASE) 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_message = ts3.getClientSelfVariable( tab, ts3defines.ClientPropertiesRare.CLIENT_AWAY_MESSAGE) 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) host = "" port = 0 name = "" if self.cfg.getboolean('general', 'enabled'): err, host, port, pw = ts3.getServerConnectInfo(schid) # err, ip = ts3.getConnectionVariableAsString(schid, ownid, ts3defines.ConnectionProperties.CONNECTION_SERVER_IP) # err, port = ts3.getConnectionVariableAsString(schid, ownid, ts3defines.ConnectionProperties.CONNECTION_SERVER_PORT) # err, ip = ts3.getServerVariableAsString(schid, ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_IP) # err, port = ts3.getServerVariableAsString(schid, ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_PORT) if host: newmeta = xml.Element(self.tag) c = xml.SubElement(newmeta, "tab") c.set("id", str(schid)) err, name = ts3.getServerVariable( schid, ts3defines.VirtualServerProperties. VIRTUALSERVER_NAME) if name: c.text = escape(name.strip()) c.set("host", escape(host)) if port and port != 9987: c.set("port", "{}".format(port)) if pw and self.cfg.getboolean('general', 'pw'): c.set("pw", pw) 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 "") _away_message = self.cfg.get('general', 'status').replace( '{host}', host if host else "").replace( '{name}', name if name else "").replace( '{port}', str(port) if port else "") 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) except: from traceback import format_exc ts3.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0) 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)