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 commandChannelKickMe(self, schid, targetMode, toID, fromID, params=""): if self.cfg.getboolean('general', 'customprefix'): prefix = self.cfg.get('general', 'prefix') else: (error, id) = ts3lib.getClientID(schid);prefix = self.clientURL(schid, id) (error, nickname) = ts3lib.getClientVariableAsString(schid, fromID, ts3defines.ClientProperties.CLIENT_NICKNAME) if params != "": ts3lib.requestClientKickFromChannel(schid, fromID, params) else: ts3lib.requestClientKickFromChannel(schid, fromID, "Command %sckickme used by %s" % (prefix, nickname))
def onClientMoveEvent(self, schid, clid, oldChannelID, newChannelID, visibility, moveMessage): if not self.uid: return if not newChannelID: return if visibility != ts3defines.Visibility.RETAIN_VISIBILITY: return (err, uid) = ts3lib.getClientVariable(schid, clid, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) if uid != self.uid: return ts3lib.requestClientKickFromChannel(schid, clid, "Nope zum %sten"%self.kicks) self.kicks += 1
def commandChannelBanMe(self, schid, targetMode, toID, fromID, params=""): (error, ownID) = ts3lib.getClientID(schid) if self.cfg.getboolean('general', 'customprefix'): prefix = self.cfg.get('general', 'prefix') else: prefix = self.clientURL(schid, ownID) (error, nickname) = ts3lib.getClientVariableAsString(schid, fromID, ts3defines.ClientProperties.CLIENT_NICKNAME) (error, dbid) = ts3lib.getClientVariableAsInt(schid, fromID, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) (error, chan) = ts3lib.getChannelOfClient(schid, ownID) if params == "": params = "Command %scbanme used by %s" % (prefix, nickname) ts3lib.requestSetClientChannelGroup(schid, [12], [chan], [dbid]) ts3lib.requestClientKickFromChannel(schid, fromID, params)
def kick(self, kickReason, tserv=False): if tserv: err = ts3lib.requestClientKickFromServer(self.schid, self.clientID, kickReason) else: err = ts3lib.requestClientKickFromChannel(self.schid, self.clientID, kickReason) if err != ts3defines.ERROR_ok: raise ts3Error("Error kicking client: (%s, %s)" % (err, ts3lib.getErrorMessage(err)[1]))
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 onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): try: if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL: if menuItemID == 1: # Message all Clients (error, clients) = ts3lib.getClientList(schid) msgs = self.getText(multiline=True,title="Message all %s clients on this server"%len(clients),text="Enter Private Message") if bool(self.ok) != True:return (error, ownID) = ts3lib.getClientID(schid) for c in clients: if c == ownID: continue for msg in msgs: ts3lib.requestSendPrivateTextMsg(schid, msg, c) elif menuItemID == 2: # OffineMessage all Clients (error, clients) = ts3lib.getClientList(schid) (error, ownID) = ts3lib.getClientID(schid) uids = [] for c in clients: if c == ownID: continue (error, uid) = ts3lib.getClientVariableAsString(schid, c, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) uids.append(uid) if not self.dlg: self.dlg = MessageDialog(schid, uids) self.dlg.show();self.dlg.raise_();self.dlg.activateWindow() elif menuItemID == 3: # Message all Channels (error, channels) = ts3lib.getChannelList(schid) msgs = self.getText(multiline=True,title="Message all %s channels on this server"%len(channels),text="Enter Channel Message") (error, ownID) = ts3lib.getClientID(schid) for c in channels: error = ts3lib.requestClientMove(schid, ownID, c, "123") if not error == ts3defines.ERROR_ok: continue for msg in msgs: ts3lib.requestSendChannelTextMsg(schid, msg, c) elif menuItemID == 4: # Poke all Clients (error, clients) = ts3lib.getClientList(schid) msgs = self.getText(title="Poke all %s clients on this server"%len(clients),text="Enter Poke Message",max=100) if bool(self.ok) != True:return (error, ownID) = ts3lib.getClientID(schid) for c in clients: if c == ownID: continue for msg in msgs: ts3lib.requestClientPoke(schid, c, msg) elif menuItemID == 5: # ChannelKick all Clients (error, clients) = ts3lib.getClientList(schid) msg = self.getText(title="Kick all %s clients on this server from their channel"%len(clients),text="Enter Kick Reason",multimsg=False,max=80) if bool(self.ok) != True:return (error, ownID) = ts3lib.getClientID(schid) for c in clients: if c == ownID: continue ts3lib.requestClientKickFromChannel(schid, c, msg) elif menuItemID == 6: # ChannelBan all Clients (error, clients) = ts3lib.getClientList(schid) msg = self.getText(title="ChannelBan all %s clients on this server"%len(clients),text="Enter Kick Reason",multimsg=False,max=80) if bool(self.ok) != True:return (error, ownID) = ts3lib.getClientID(schid) for c in clients: if c == ownID: continue (error, chan) = ts3lib.getChannelOfClient(schid, selectedItemID) (error, dbid) = ts3lib.getClientVariableAsUInt64(schid, c, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) ts3lib.requestSetClientChannelGroup(schid, [self.sbgroup], [chan], [dbid]) ts3lib.requestClientKickFromChannel(schid, c, msg) elif menuItemID == 7: # Kick all Clients (error, clients) = ts3lib.getClientList(schid) msg = self.getText(title="Kick all %s clients from this server"%len(clients),text="Enter Kick Reason",multimsg=False,max=80) if bool(self.ok) != True:return (error, ownID) = ts3lib.getClientID(schid) for c in clients: if c == ownID: continue ts3lib.requestClientKickFromServer(schid, c, msg) elif menuItemID == 8: # Ban all Clients (error, clients) = ts3lib.getClientList(schid) msg = self.getText(title="Ban all %s clients from this server"%len(clients),text="Enter Ban Reason",multimsg=False,max=80) if bool(self.ok) != True:return (error, ownID) = ts3lib.getClientID(schid) for c in clients: if c == ownID: continue ts3lib.banclient(schid, c, -1, msg) elif menuItemID == 9: # Delete all Channels (error, channels) = ts3lib.getChannelList(schid) confirmation = self.confirm('Delete all Channels', 'Do you really want to delete all {0} channels on this server?'.format(len(channels))) if not confirmation: return for c in channels: ts3lib.requestChannelDelete(schid, c, True) elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL: if menuItemID == 1: # Message all Clients (error, clients) = ts3lib.getChannelClientList(schid, selectedItemID) (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME) msgs = self.getText(multiline=True,title="Message to all %s clients in channel \"%s\""%(len(clients),name),text="Enter Private Message") if bool(self.ok) != True:return (error, ownID) = ts3lib.getClientID(schid) for c in clients: if c == ownID: continue for msg in msgs: ts3lib.requestSendPrivateTextMsg(schid, msg, c) if menuItemID == 2: # OfflineMessage all Clients (error, clients) = ts3lib.getChannelClientList(schid, selectedItemID) (error, ownID) = ts3lib.getClientID(schid) uids = [] for c in clients: if c == ownID: continue (error, uid) = ts3lib.getClientVariableAsString(schid, c, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) uids.append(uid) if not self.dlg: self.dlg = MessageDialog(schid, uids) self.dlg.show();self.dlg.raise_();self.dlg.activateWindow() elif menuItemID == 3: # Poke all Clients (error, clients) = ts3lib.getChannelClientList(schid, selectedItemID) (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME) msgs = self.getText(title="Poke all %s clients in channel \"%s\""%(len(clients),name),text="Enter Poke Message",max=100) if bool(self.ok) != True:return (error, ownID) = ts3lib.getClientID(schid) for c in clients: if c == ownID: continue for msg in msgs: ts3lib.requestClientPoke(schid, c, msg) elif menuItemID == 4: # ChannelKick all Clients (error, clients) = ts3lib.getChannelClientList(schid,selectedItemID) (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME) msg = self.getText(title="Kick all %s clients from channel \"%s\""%(len(clients),name),text="Enter Kick Reason",multimsg=False,max=80) if bool(self.ok) != True:return (error, ownID) = ts3lib.getClientID(schid) for c in clients: if c == ownID: continue ts3lib.requestClientKickFromChannel(schid, c, msg) elif menuItemID == 5: # ChannelBan all Clients (error, clients) = ts3lib.getChannelClientList(schid,selectedItemID) (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME) msg = self.getText(title="ChannelBan all %s clients from channel \"%s\""%(len(clients),name),text="Enter Kick Reason",multimsg=False,max=80) if bool(self.ok) != True:return (error, ownID) = ts3lib.getClientID(schid) for c in clients: if c == ownID: continue (error, dbid) = ts3lib.getClientVariableAsUInt64(schid, c, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) ts3lib.requestSetClientChannelGroup(schid, [self.sbgroup], [selectedItemID], [dbid]) ts3lib.requestClientKickFromChannel(schid, c, msg) elif menuItemID == 6: # Kick all Clients (error, clients) = ts3lib.getChannelClientList(schid,selectedItemID) (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME) msg = self.getText(title="Kick all %s clients in channel \"%s\" from this server"%(len(clients),name),text="Enter Kick Reason",multimsg=False,max=80) if bool(self.ok) != True:return (error, ownID) = ts3lib.getClientID(schid) for c in clients: if c == ownID: continue ts3lib.requestClientKickFromServer(schid, c, msg) elif menuItemID == 7: # Ban all Clients (error, clients) = ts3lib.getChannelClientList(schid,selectedItemID) (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME) msg = self.getText(title="Ban all %s clients in channel \"%s\""%(len(clients),name),text="Enter Ban Reason",multimsg=False,max=80) if bool(self.ok) != True:return (error, ownID) = ts3lib.getClientID(schid) for c in clients: if c == ownID: continue ts3lib.banclient(schid, c, -1, msg) except: from traceback import format_exc;ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)