def processCommand(self, schid, fullcmd): try: cmd = fullcmd.split(' ', 1) mode = cmd[0].lower() _cmd = cmd[1].split(' ', 1) targetmode = _cmd[0].lower() command = _cmd[1] target = [] if targetmode in ["chan", "channel", "0"]: targetmode = ts3defines.PluginTargetMode.PluginCommandTarget_CURRENT_CHANNEL elif targetmode in ["serv", "server", "1"]: targetmode = ts3defines.PluginTargetMode.PluginCommandTarget_SERVER elif targetmode in ["cli", "client", "2"]: targetmode = ts3defines.PluginTargetMode.PluginCommandTarget_CLIENT _cmd = command[1].split(' ', 1) target = [int(_cmd[0])] command = _cmd[1] elif targetmode in ["chansub", "channelsubscribed", "3"]: targetmode = ts3defines.PluginTargetMode.PluginCommandTarget_CURRENT_CHANNEL_SUBSCRIBED_CLIENTS if mode in ["raw", "r", "true", "1"]: _ts3lib.sendPluginCommand(schid, command, targetmode, target) else: ts3lib.sendPluginCommand(schid, command, targetmode, target) return True except: ts3lib.printMessageToCurrentTab( "Syntax: [b]/py {} <raw> <channel,server,channelsubscribed,client <clid>> <cmd>" .format(self.commandKeyword)) ts3lib.logMessage( "Error while processing \"{}\"\n{}".format( fullcmd, format_exc()), ts3defines.LogLevel.LogLevel_WARNING, self.name, schid)
def _sendSendKey(cls, schid, reqcmd): retcode = _ts3lib.createReturnCode() cls.getStore(schid).sendKeyReturnCodes.append(retcode) snd = _SendKey.pack(reqcmd, cls.getStore(schid).publickey()) _ts3lib.sendPluginCommand(schid, snd.toString(), PluginTargetMode.PluginCommandTarget_CLIENT, [snd.receiver], retcode)
def _sendRequestKey(cls, schid, sender, target): retcode = _ts3lib.createReturnCode() req = _RequestKey.pack(sender, target) cls.getStore(schid).addRequest(target, req.data, retcode) _ts3lib.sendPluginCommand(schid, req.toString(), PluginTargetMode.PluginCommandTarget_CLIENT, [target], retcode)
def processCommand(self, schid, cmd): cmd = cmd.split(' ', 1) targetmode = cmd[0].lower() target = [] command = cmd[1] if targetmode in ["chan", "channel", "0"]: targetmode = ts3defines.PluginTargetMode.PluginCommandTarget_CURRENT_CHANNEL elif targetmode in ["serv", "server", "1"]: targetmode = ts3defines.PluginTargetMode.PluginCommandTarget_SERVER elif targetmode in ["cli", "client", "2"]: targetmode = ts3defines.PluginTargetMode.PluginCommandTarget_CLIENT _cmd = cmd[1].split(' ', 1) target = [int(_cmd[0])] command = _cmd[1] elif targetmode in ["chansub", "channelsubscribed", "3"]: targetmode = ts3defines.PluginTargetMode.PluginCommandTarget_CURRENT_CHANNEL_SUBSCRIBED_CLIENTS _ts3lib.sendPluginCommand(schid, command, targetmode, target) return True
def sendPluginCommand(cls, schid, command, targetMode, targetIDs, *returnCode): err, myid = _ts3lib.getClientID(schid) if err != ts3defines.ERROR_ok: return err # we need to send the command to each client separately, otherwise # an attacker could copy the complete cmd ("header", data and # signature) and resend the complete package to the other receiving # clients # because of this it's not possible to use # PluginCommandTarget_CURRENT_CHANNEL_SUBSCRIBED_CLIENTS if targetMode == PluginTargetMode.PluginCommandTarget_CURRENT_CHANNEL: err, mychan = _ts3lib.getChannelOfClient(schid, myid) if err != ts3defines.ERROR_ok: return err err, clids = _ts3lib.getChannelClientList(schid, mychan) if err != ts3defines.ERROR_ok: return err elif targetMode == PluginTargetMode.PluginCommandTarget_SERVER: err, clids = _ts3lib.getClientList(schid) if err != ts3defines.ERROR_ok: return err elif targetMode == PluginTargetMode.PluginCommandTarget_CLIENT: clids = targetIDs elif targetMode == PluginTargetMode.PluginCommandTarget_CURRENT_CHANNEL_SUBSCRIBED_CLIENTS: return ts3defines.ERROR_parameter_invalid signer = cls.getStore(schid).signer for client in clids: pkgs = _PluginCommand.pack(myid, client, command) for p in pkgs: p.sign(signer) _ts3lib.sendPluginCommand(schid, p.toString(), PluginTargetMode.PluginCommandTarget_CLIENT, [client], *returnCode) return ts3defines.ERROR_ok