def onUpdateChannelEditedEvent(self, schid, channelID, invokerID, invokerName, invokerUniqueIdentifier): (err, suid) = ts3lib.getServerVariable(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER) if suid != self.suid: return (err, ownID) = ts3lib.getClientID(schid) if invokerID == ownID: (err, self.settings["maxclients"]) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) (err, self.settings["tp"]) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER) (err, ownChannel) = ts3lib.getChannelOfClient(schid, ownID) if channelID != ownChannel: return (err, invokerChannel) = ts3lib.getChannelOfClient(schid, invokerID) if invokerChannel == channelID: return _needed = False (err, ntp) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER) if ntp != self.settings["tp"]: _needed = True ts3lib.setChannelVariableAsInt(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER, self.settings["tp"]) (err, cmc) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) ts3lib.setChannelVariableAsInt(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_FLAG_MAXCLIENTS_UNLIMITED, 0) if cmc != self.settings["maxclients"]: _needed = True ts3lib.setChannelVariableAsInt(schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS, self.settings["maxclients"]) if _needed: ts3lib.flushChannelUpdates(schid, channelID) self.violations[invokerUniqueIdentifier] += 1 if self.violations[invokerUniqueIdentifier] > 2: (err, dbid) = ts3lib.getClientVariable(schid, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) ts3lib.requestSetClientChannelGroup(schid, [9], [channelID], [dbid]) del self.violations[invokerUniqueIdentifier]
def checkChannel(self, schid): (err, clients) = ts3lib.getChannelClientList(schid, self.supchan); clients = len(clients) (err, maxclients) = ts3lib.getChannelVariable(schid, self.supchan, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) if clients < maxclients: ts3lib.setChannelVariableAsString(schid, self.supchan, ts3defines.ChannelProperties.CHANNEL_NAME,self.chan.get("props", "name open")) elif clients >= maxclients: ts3lib.setChannelVariableAsString(schid, self.supchan, ts3defines.ChannelProperties.CHANNEL_NAME, self.chan.get("props", "name in use")) else: return ts3lib.flushChannelUpdates(schid, self.supchan)
def onMenuItemEvent(self, schid, atype, menuItemID, channel): if atype != ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL: return try: (error, ownID) = ts3lib.getClientID(schid) (error, maxclients) = ts3lib.getChannelVariable( schid, channel, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) if self.debug: ts3lib.printMessageToCurrentTab( "error: {0} | maxclients: {1}".format(error, maxclients)) if menuItemID == 0: pw = inputBox("Enter Channel Password", "Password:"******"clients: {0}".format(clients)) (error, maxfamilyclients) = ts3lib.getChannelVariable( schid, channel, ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS) if self.debug: ts3lib.printMessageToCurrentTab( "error: {0} | maxfamilyclients: {1}".format( error, maxfamilyclients)) if clients < maxclients and clients < maxfamilyclients: ts3lib.requestClientMove(schid, ownID, channel, pw) return True (error, name) = ts3lib.getChannelVariableAsString( schid, channel, ts3defines.ChannelProperties.CHANNEL_NAME) self.schid = schid self.channel = channel self.password = pw self.cname = name if not pw: ts3lib.printMessageToCurrentTab( "Queued for channel [url=channelid://{0}]{1}[/url]. [color=red]{2}[/color] client(s) remaining." .format(channel, name, maxclients - clients + 1)) else: ts3lib.printMessageToCurrentTab( "Queued for channel [url=channelid://{0}]{1}[/url] with password \"{2}\". [color=red]{3}[/color] client(s) remaining." .format(channel, name, pw, maxclients - clients + 1)) elif menuItemID == 1: pw = inputBox("Enter Channel Password", "Password:"******"pyTSon", 0)
def onClientSelfVariableUpdateEvent(self, schid, flag, oldValue, newValue) : if not self.schids or len(self.schids) < 1 or schid != self.schids[0]: return if flag != ts3defines.ClientPropertiesRare.CLIENT_AWAY: return newValue = int(newValue) if newValue == ts3defines.AwayStatus.AWAY_ZZZ: ts3lib.setChannelVariableAsInt(schid, self.supchan, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS, 0) ts3lib.setChannelVariableAsString(schid, self.supchan, ts3defines.ChannelProperties.CHANNEL_NAME, self.chan.get("props", "name closed")) ts3lib.flushChannelUpdates(schid, self.supchan) elif newValue == ts3defines.AwayStatus.AWAY_NONE: ts3lib.setChannelVariableAsInt(schid, self.supchan, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS, self.chan.getint("props", "maxclients")) ts3lib.setChannelVariableAsString(schid, self.supchan, ts3defines.ChannelProperties.CHANNEL_NAME, self.chan.get("props", "name open")) ts3lib.flushChannelUpdates(schid, self.supchan)
def onClientChannelGroupChangedEvent(self, schid, channelGroupID, channelID, clientID, invokerClientID, invokerName, invokerUniqueIdentity): (err, suid) = ts3lib.getServerVariable( schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER) # if self.debug: ts3lib.printMessageToCurrentTab('suid != self.suid: {}'.format(suid != self.suid)) if suid != self.suid: return (err, ownID) = ts3lib.getClientID(schid) # if self.debug: ts3lib.printMessageToCurrentTab('clientID != ownID: {}'.format(clientID != ownID)) if clientID != ownID: return # if self.debug: ts3lib.printMessageToCurrentTab('channelGroupID != self.channelAdminGroupID: {}'.format(channelGroupID != self.channelAdminGroupID)) if channelGroupID != self.channelAdminGroupID: return # if self.debug: ts3lib.printMessageToCurrentTab('invokerClientID != 0: {}'.format(invokerClientID != 0)) if invokerClientID == 0: (err, ntp) = ts3lib.getChannelVariable( schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER) if not ntp or ntp == 0: ts3lib.setChannelVariableAsInt( schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER, self.settings["tp"]) # (err, cmc) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) ts3lib.setChannelVariableAsInt( schid, channelID, ts3defines.ChannelPropertiesRare. CHANNEL_FLAG_MAXCLIENTS_UNLIMITED, 0) ts3lib.setChannelVariableAsInt( schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS, self.settings["maxclients"]) (err, cnp) = ts3lib.getChannelVariable( schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NAME_PHONETIC) if not cnp or cnp == "": ts3lib.setChannelVariableAsString( schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NAME_PHONETIC, "Team | Lounge 1") ts3lib.flushChannelUpdates(schid, channelID) return # clid = ts3lib.getClientIDbyNickname(schid, self.gommeBotNick) # if not clid: ts3lib.printMessage(schid, 'Gomme-Bot not found.', ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) # (err, uid) = ts3lib.getClientVariable(schid, self.gommeBotID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) # if uid != "serveradmin": return # if self.debug: ts3lib.printMessageToCurrentTab('self.gommeBotID == 0: {}'.format(self.gommeBotID == 0)) if self.gommeBotID == 0: return ts3lib.requestSendPrivateTextMsg(schid, "registriert", self.gommeBotID)
def onClientChannelGroupChangedEvent(self, schid, channelGroupID, channelID, clientID, invokerClientID, invokerName, invokerUniqueIdentity): (err, suid) = ts3lib.getServerVariable(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER) if suid != self.suid: return (err, ownID) = ts3lib.getClientID(schid) if clientID != ownID: return if channelGroupID != self.channelAdminGroupID: return if invokerClientID == 0: (err, ntp) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER) if not ntp or ntp == 0: ts3lib.setChannelVariableAsInt(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER, self.settings["tp"]) ts3lib.setChannelVariableAsInt(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_FLAG_MAXCLIENTS_UNLIMITED, 0) ts3lib.setChannelVariableAsInt(schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS, self.settings["maxclients"]) (err, cnp) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NAME_PHONETIC) if not cnp or cnp == "": ts3lib.setChannelVariableAsString(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NAME_PHONETIC, "Team | Lounge 1") ts3lib.flushChannelUpdates(schid, channelID) if self.gommeBotID < 1: return ts3lib.requestSendPrivateTextMsg(schid, "registriert", self.gommeBotID)
def onNewChannelCreatedEvent(self, schid, cid, channelParentID, clid, invokerName, invokerUniqueIdentifier): (err, suid) = ts3lib.getServerVariable( schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER) if not suid in self.servers: return (err, sgids) = ts3lib.getClientVariable( schid, clid, ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS) if not set(sgids).isdisjoint(self.servers[suid]): return (err, perm) = ts3lib.getChannelVariable( schid, cid, ts3defines.ChannelProperties.CHANNEL_FLAG_PERMANENT) # (err, semi) = ts3lib.getChannelVariable(schid, cid, ts3defines.ChannelProperties.CHANNEL_FLAG_SEMI_PERMANENT) if not perm: return ts3lib.setChannelVariableAsInt( schid, cid, ts3defines.ChannelProperties.CHANNEL_FLAG_PERMANENT, 0) ts3lib.flushChannelUpdates(schid, cid)
def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moveMessage): if self.schid != schid: return if self.channel == oldChannelID: clients = self.channelClientCount(schid, oldChannelID) if self.debug: ts3lib.printMessageToCurrentTab("clients: {0}".format(clients)) (error, maxclients) = ts3lib.getChannelVariable( schid, oldChannelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) if self.debug: ts3lib.printMessageToCurrentTab( "error: {0} | maxclients: {1}".format(error, maxclients)) (error, maxfamilyclients) = ts3lib.getChannelVariable( schid, oldChannelID, ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS) if self.debug: ts3lib.printMessageToCurrentTab( "error: {0} | maxfamilyclients: {1}".format( error, maxfamilyclients)) if clients < maxclients and clients < maxfamilyclients: (error, ownID) = ts3lib.getClientID(schid) ts3lib.requestClientMove(schid, ownID, oldChannelID, self.password) self.schid = 0 self.channel = 0 self.password = "" self.name = "" else: ts3lib.printMessageToCurrentTab( "{0} left channel {1}. [color=red]{2}[/color] client(s) remaining." .format(clientURL(schid, clientID), channelURL(schid, oldChannelID), maxclients - clients + 1)) print("fullchannel:", self.fullchannel, "newChannelID:", newChannelID) if self.fullchannel == newChannelID: self.fullchannel = 0 (error, maxclients) = ts3lib.getChannelVariable( schid, newChannelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) ts3lib.setChannelVariableAsInt( schid, newChannelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS, maxclients - 1) ts3lib.flushChannelUpdates(schid, newChannelID) self.schid = 0
def fakeChannel(self, schid, channelID): err, ownID = ts3lib.getClientID(schid) err, ownCID = ts3lib.getChannelOfClient(schid, ownID) # channel = self.ts3host.getChannel(schid, channelID) (error, name) = ts3lib.getChannelVariable( schid, channelID, ts3defines.ChannelProperties.CHANNEL_NAME) # name = name.encode("utf-8").decode(sys.stdout.encoding) if not error and name: ts3lib.setChannelVariableAsString( schid, ownCID, ts3defines.ChannelProperties.CHANNEL_NAME, self.str_replace(name)) """ (error, phonetic) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NAME_PHONETIC) if debug: print("err:", error, "CHANNEL_NAME_PHONETIC", phonetic) if not error and phonetic: ts3lib.setChannelVariableAsString(schid, 0,ts3defines.ChannelPropertiesRare.CHANNEL_NAME_PHONETIC,phonetic) (error, pw) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_FLAG_PASSWORD) if debug: print("err:", error, "CHANNEL_FLAG_PASSWORD", pw) if pw: (err, path, _pw) = ts3lib.getChannelConnectInfo(schid, channelID) if debug: print("err:", error, "_pw", _pw) ts3lib.setChannelVariableAsString(schid, 0,ts3defines.ChannelProperties.CHANNEL_PASSWORD,_pw if _pw else ".") """ """ (error, topic) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_TOPIC) if debug: print("err:", error, "CHANNEL_TOPIC", topic) if not error and topic: ts3lib.setChannelVariableAsString(schid, 0,ts3defines.ChannelProperties.CHANNEL_TOPIC,topic) ts3lib.requestChannelDescription(schid, channelID) (error, description) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_DESCRIPTION) if debug: print("err:", error, "CHANNEL_DESCRIPTION", description) if not error and description: ts3lib.setChannelVariableAsString(schid, 0,ts3defines.ChannelProperties.CHANNEL_DESCRIPTION,description.decode('utf-8')) """ """ (error, neededtp) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER) if debug: print("err:", error, "CHANNEL_NEEDED_TALK_POWER", neededtp) if not error and neededtp: ts3lib.setChannelVariableAsInt(schid, 0,ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER,neededtp) (error, codec) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_CODEC) if debug: print("err:", error, "CHANNEL_CODEC", codec) if not error and codec: ts3lib.setChannelVariableAsInt(schid, 0,ts3defines.ChannelProperties.CHANNEL_CODEC,codec) (error, quality) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_CODEC_QUALITY) if debug: print("err:", error, "CHANNEL_CODEC_QUALITY", quality) if not error and quality: ts3lib.setChannelVariableAsInt(schid, 0,ts3defines.ChannelProperties.CHANNEL_CODEC_QUALITY,quality) (error, latency) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_CODEC_LATENCY_FACTOR) if debug: print("err:", error, "CHANNEL_CODEC_LATENCY_FACTOR", latency) if not error and latency: ts3lib.setChannelVariableAsInt(schid, 0,ts3defines.ChannelProperties.CHANNEL_CODEC_LATENCY_FACTOR,latency) (error, unencrypted) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_CODEC_IS_UNENCRYPTED) if debug: print("err:", error, "CHANNEL_CODEC_IS_UNENCRYPTED", unencrypted) if not error and unencrypted: ts3lib.setChannelVariableAsInt(schid, 0,ts3defines.ChannelProperties.CHANNEL_CODEC_IS_UNENCRYPTED,unencrypted) (error, maxclients) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) if debug: print("err:", error, "CHANNEL_MAXCLIENTS", maxclients) if not error and maxclients: ts3lib.setChannelVariableAsInt(schid, 0,ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS,maxclients) (error, maxfamilyclients) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS) if debug: print("err:", error, "CHANNEL_MAXFAMILYCLIENTS", maxfamilyclients) if not error and maxfamilyclients: ts3lib.setChannelVariableAsInt(schid, 0,ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS,maxfamilyclients) (error, iconid) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_ICON_ID) if debug: print("err:", error, "CHANNEL_ICON_ID", iconid) if not error and iconid: ts3lib.setChannelVariableAsInt(schid, 0,ts3defines.ChannelPropertiesRare.CHANNEL_ICON_ID,iconid) """ self.retcode = ts3lib.createReturnCode() err = ts3lib.flushChannelUpdates(schid, ownCID, self.retcode) _err, errmsg = ts3lib.getErrorMessage(err) print("ts3lib.flushChannelUpdates", "schid:", schid, "ownID:", ownID, "ownCID:", ownCID, "retcode", self.retcode, "err", err, "errmsg", errmsg) if err == ts3defines.ERROR_ok: return err = ts3lib.flushChannelCreation(schid, 0, self.retcode) _err, errmsg = ts3lib.getErrorMessage(err) print("ts3lib.flushChannelCreation", "schid:", schid, "0", "retcode", self.retcode, "err", err, "errmsg", errmsg)
def onMenuItemEvent(self, schid, atype, menuItemID, channel): if atype != ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL: return try: (error, ownID) = ts3lib.getClientID(schid) (error, maxclients) = ts3lib.getChannelVariable( schid, channel, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) if self.debug: ts3lib.printMessageToCurrentTab( "error: {0} | maxclients: {1}".format(error, maxclients)) if menuItemID == 0: x = QWidget() x.setAttribute(Qt.WA_DeleteOnClose) password = QInputDialog.getText(x, "Enter Channel Password", "Password:"******"clients: {0}".format(clients)) (error, maxfamilyclients) = ts3lib.getChannelVariable( schid, channel, ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS) if self.debug: ts3lib.printMessageToCurrentTab( "error: {0} | maxfamilyclients: {1}".format( error, maxfamilyclients)) if clients < maxclients and clients < maxfamilyclients: ts3lib.requestClientMove(schid, ownID, channel, password) return True (error, name) = ts3lib.getChannelVariableAsString( schid, channel, ts3defines.ChannelProperties.CHANNEL_NAME) self.schid = schid self.channel = channel self.password = password self.cname = name if password == "": ts3lib.printMessageToCurrentTab( "Queued for channel [url=channelid://{0}]{1}[/url]. [color=red]{2}[/color] client(s) remaining." .format(channel, name, maxclients - clients + 1)) else: ts3lib.printMessageToCurrentTab( "Queued for channel [url=channelid://{0}]{1}[/url] with password \"{2}\". [color=red]{3}[/color] client(s) remaining." .format(channel, name, password, maxclients - clients + 1)) elif menuItemID == 1: ts3lib.setChannelVariableAsInt( schid, channel, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS, maxclients + 1) err = ts3lib.flushChannelUpdates(schid, channel) print("#1 error:", err, "msg:", ts3lib.getErrorMessage(err)) (error, ownID) = ts3lib.getClientID(schid) ts3lib.requestClientMove(schid, ownID, channel, "123") ts3lib.setChannelVariableAsInt( schid, channel, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS, maxclients) err = ts3lib.flushChannelUpdates(schid, channel) print("#2 error:", err, "msg:", ts3lib.getErrorMessage(err)) except: from traceback import format_exc ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
def flushUpdates(self): err = ts3lib.flushChannelUpdates(self.schid, self.channelID) #No documentation found about ERROR_ok_no_update, Why ?? if err != ts3defines.ERROR_ok and err != ts3defines.ERROR_ok_no_update: raise ts3Error("Error flushing channel updates: (%s, %s)" % (err, ts3lib.getErrorMessage(err)[1]))