def onClientChannelGroupChangedEvent(self, schid, channelGroupID, channelID, clientID, invokerClientID, invokerName, invokerUniqueIdentity): if not self.check: return False if self.toggle: (error, _clid) = ts3lib.getClientID(schid) (error, _cid) = ts3lib.getChannelOfClient(schid, _clid) if clientID == _clid: if channelGroupID == self.sagroup: if self.ownchannels.__contains__(channelID): _t = False else: self.ownchannels.append(channelID) elif channelGroupID == self.smgroup: (error, neededTP) = ts3lib.getChannelVariableAsInt(schid, _cid, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER) if neededTP > 0: (error, clients) = ts3lib.getChannelClientList(schid, _cid) for client in clients: if client == _clid: continue (error, _cgid) = ts3lib.getClientVariableAsInt(schid, client, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) if _cgid == self.sagroup: continue (error, uid) = ts3lib.getClientVariableAsString(schid, client, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) if self.InContacts(uid) == 0: ts3lib.requestClientSetIsTalker(schid, client, True) elif channelID == _cid and channelGroupID == self.sbgroup: #(error, uid) = ts3lib.getClientVariableAsString(schid, clientID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) (error, _cid) = ts3lib.getChannelOfClient(schid, clientID) if _cid in self.ownchannels: ts3lib.requestClientKickFromChannel(schid, clientID, "You were banned by \"%s\""%invokerName + (" for \"%s\""%invokerName) if self.reason != "" else "")
def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moveMessage): if not self.check: return False if self.toggle: (error, _clid) = ts3lib.getClientID(schid) (error, _cid) = ts3lib.getChannelOfClient(schid, _clid) (error, _cgid) = ts3lib.getClientVariableAsInt( schid, _clid, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) if not clientID == _clid: (error, uid) = ts3lib.getClientVariableAsString( schid, clientID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) if oldChannelID == 0: self.checkUser( uid ) # and _cgid == self.smgroup or _cgid == self.sagroup if newChannelID == _cid and _cgid == self.smgroup: (error, neededTP) = ts3lib.getChannelVariableAsInt( schid, _cid, ts3defines.ChannelPropertiesRare. CHANNEL_NEEDED_TALK_POWER) if neededTP > 0: if self.InContacts(uid) == 0: ts3lib.requestClientSetIsTalker( schid, clientID, True)
def onUserLoggingMessageEvent(self, logMessage, logLevel, logChannel, schid, logTime, completeLogString): if logLevel != ts3defines.LogLevel.LogLevel_DEBUG: return if schid != ts3lib.getCurrentServerConnectionHandlerID(): return if logChannel != "VolumeLeveler": return clid, level = parseMessage(logMessage) if not clid in self.clients: return # date = parseTime(logTime) if self.clients[clid] > self.maxviolations: self.clients[clid] = 0 client = self.ts3host.getUser(schid, clid) if not client.server.me.getChannelGroupId() in [self.tabs[schid]["channelModGroup"], client.server.defaultChannelAdminGroup]: client.mute() return (err, country) = ts3lib.getClientVariable(schid, clid, ts3defines.ClientPropertiesRare.CLIENT_COUNTRY) msg = "[color=red]You exceeded the volume limit {violations} times, your talk power has been revoked!" if country in ["DE", "AT", "CH"]: msg = "[color=red]Du hast {violations} mal das Lautstaerkelimit von {limit} ueberschritten, deine Talk Power wurde entzogen!" tp = client.channel.neededTalkPower if not tp or tp < 1 or tp == "-1": ts3lib.requestSetClientChannelGroup(schid, [self.tabs[schid]["channelBanGroup"]], [client.channel.channelID], [client.databaseID]) err = ts3lib.requestClientSetIsTalker(schid, clid, False) if err != ts3defines.ERROR_ok: return client.sendTextMsg(msg.replace("{violations}",str(self.maxviolations)).replace("{limit}",str(self.maxlevel))) return if level > self.maxlevel: self.clients[clid] += 1 print(clid, level, self.clients[clid])
def doContactActions(self, schid, clientID): # Own client ID and own channel (error, myid) = ts3.getClientID(schid) (error, mych) = ts3.getChannelOfClient(schid, myid) (error, cch) = ts3.getChannelOfClient(schid, clientID) (error, isDefaultChannel) = ts3.getChannelVariableAsInt(schid, mych, ts3defines.ChannelProperties.CHANNEL_FLAG_DEFAULT) # Only react if client joins my channel and at least one setting is activated if not isDefaultChannel == 1 and cch == mych and not myid == clientID and (self.settings["f_channelgroup"] or self.settings["f_talkpower"] or self.settings["b_channelgroup"] or self.settings["b_kick"]): # Contact status check (error, cuid) = ts3.getClientVariableAsString(schid, clientID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) status = self.contactStatus(cuid) # Only react if friend or blocked joined the channel if status == 0 or status == 1: # blocked if status == 1: # Assign blocked channelgroup if self.settings["b_channelgroup"]: channelgroup = self.setClientChannelGroup(schid, 1, clientID, mych) # kick blocked if self.settings["b_kick"]: ts3.requestClientKickFromChannel(schid, clientID, self.settings["b_kick_message"], self.error_kickFromChannel) (error, new_cch) = ts3.getChannelOfClient(schid, clientID) # Send message to blocked user if kick was valid if not new_cch == mych and self.settings["b_message"]: ts3.requestSendPrivateTextMsg(schid, self.settings["b_message_message"], clientID, self.error_sendMessage) # freinds if status == 0: # Assign friends channelgroup if self.settings["f_channelgroup"]: self.setClientChannelGroup(schid, 0, clientID, mych) # Grant friends talkpower if self.settings["f_talkpower"]: ts3.requestClientSetIsTalker(schid, clientID, True, self.error_setClientTalkpower) # Send message to friends if self.settings["f_message"]: ts3.requestSendPrivateTextMsg(schid, self.settings["f_message_message"], clientID, self.error_sendMessage)
def revokeTalkPower(self, schid, clid, revoke=True): self.retcode = ts3lib.createReturnCode() ts3lib.requestClientSetIsTalker(schid, clid, not revoke, self.retcode)
def isTalker(self, value): err = ts3lib.requestClientSetIsTalker(self.schid, self.clientID, value) if err != ts3defines.ERROR_ok: raise ts3Error("Error setting client talker status: (%s, %s)" % (err, ts3lib.getErrorMessage(err)[1]))