// serverrequestconnectioninfo // servergetvariables // Splitted base commands public override R <ServerGroupAddResponse, CommandError> ServerGroupAdd(string name, GroupType?type = null) { var cmd = new Ts3Command("servergroupadd", new List <ICommandPart> { new CommandParameter("name", name) }); if (type.HasValue) { cmd.AppendParameter(new CommandParameter("type", (int)type.Value)); } var result = SendNotifyCommand(cmd, NotificationType.ServerGroupList); if (!result.Ok) { return(result.Error); } return(result.Value.Notifications .Cast <ServerGroupList>() .Where(x => x.Name == name) .Take(1) .Select(x => new ServerGroupAddResponse() { ServerGroupId = x.ServerGroupId }) .WrapSingle()); }
// serverrequestconnectioninfo // servergetvariables // Splitted base commands public override ServerGroupAddResponse ServerGroupAdd(string name, PermissionGroupDatabaseType?type = null) { var cmd = new Ts3Command("servergroupadd", new List <ICommandPart> { new CommandParameter("name", name) }); if (type.HasValue) { cmd.AppendParameter(new CommandParameter("type", (int)type.Value)); } var answer = SendSpecialCommand(cmd, NotificationType.ServerGroupList).Notifications .Cast <ServerGroupList>() .FirstOrDefault(x => x.Name == name); if (answer == null) { throw new Ts3CommandException(new CommandError() { Id = Ts3ErrorCode.custom_error, Message = "Missing answer" }); } else { return new ServerGroupAddResponse() { ServerGroupId = answer.ServerGroupId } }; }
private void SendCommandBase(WaitBlock wb, Ts3Command com) { lock (CommmandQueueLock) { if (com.ExpectResponse) { var retCode = new CommandParameter("return_code", returnCode); com.AppendParameter(retCode); msgProc.EnqueueRequest(retCode.Value, wb); returnCode++; } byte[] data = Util.Encoder.GetBytes(com.ToString()); lock (StatusLock) { if (wasExit) { throw new Ts3CommandException(new CommandError { Id = Ts3ErrorCode.custom_error, Message = "Connection closed" }); } packetHandler.AddOutgoingPacket(data, PacketType.Command); } } }
public CmdR FileTransferRenameFile(ChannelIdT channelId, string oldName, string channelPassword, string newName, ChannelIdT?targetChannel = null, string targetChannelPassword = "") { var cmd = new Ts3Command("ftrenamefile", new List <ICommandPart> { new CommandParameter("cid", channelId), new CommandParameter("oldname", oldName), new CommandParameter("newname", newName), new CommandParameter("cpw", channelPassword) }); if (targetChannel.HasValue) { cmd.AppendParameter(new CommandParameter("tcid", targetChannel.Value)); cmd.AppendParameter(new CommandParameter("tcpw", targetChannelPassword)); } return(SendCommand <ResponseVoid>(cmd)); }
public void takeAction(Client client, string section, bool alreadyBlocked = false) { if (!alreadyBlocked) { if (!String.IsNullOrWhiteSpace(cfg[section]["msg"])) { try { Message(client, parseMSG(cfg[section]["msg"], client)); } catch (Exception ex) { PluginLog(Log.Level.Warning, $"Could not message {client.NickName}:\n{ex.Message}"); } } if (!String.IsNullOrWhiteSpace(cfg[section]["poke"])) { try { Poke(client, parseMSG(cfg[section]["poke"], client)); } catch (Exception ex) { PluginLog(Log.Level.Warning, $"Could not poke {client.NickName}:\n{ex.Message}"); } } } if (cfg[section]["kickonly"] == "true") { //bot.QueryConnection.KickClientFromServer(client.Id, (parseMSG(cfg[section]["reason"]); try { // clientkick reasonid=5 reasonmsg=test clid=1 var cmd = new Ts3Command("clientkick", new List <ICommandPart>() { new CommandParameter("clid", client.Id), new CommandParameter("reasonid", 5) }); if (!alreadyBlocked && parseMSG(cfg[section]["reason"], client).Length < 100) { cmd.AppendParameter(new CommandParameter("reasonmsg", parseMSG(cfg[section]["reason"], client))); } lib.SendCommand <ResponseVoid>(cmd); } catch (Exception ex) { PluginLog(Log.Level.Warning, $"Could not kick {client.NickName}:\n{ex.Message}"); } } else { try { // banclient clid=1 time=0 banreason=text var cmd = new Ts3Command("banclient", new List <ICommandPart>() { new CommandParameter("clid", client.Id), new CommandParameter("time", parseMSG(cfg[section]["bantime"], client)) }); if (!alreadyBlocked && parseMSG(cfg[section]["reason"], client).Length < 100) { cmd.AppendParameter(new CommandParameter("banreason", parseMSG(cfg[section]["reason"], client))); } lib.SendCommand <ResponseVoid>(cmd); } catch (Exception ex) { PluginLog(Log.Level.Warning, $"Could not ban {client.NickName}:\n{ex.Message}"); } } }
public void ClientMove(ClientIdT clientId, ChannelIdT channelId, string channelPassword = null) { var cmd = new Ts3Command("clientmove", new List <ICommandPart> { new CommandParameter("clid", clientId), new CommandParameter("cid", channelId) }); if (channelPassword != null) { cmd.AppendParameter(new CommandParameter("cpw", channelPassword)); } SendCommand <ResponseVoid>(cmd); }
public CmdR ClientMove(ClientIdT clientId, ChannelIdT channelId, string channelPassword = null) { var cmd = new Ts3Command("clientmove", new List <ICommandPart> { new CommandParameter("clid", clientId), new CommandParameter("cid", channelId) }); if (channelPassword != null) { cmd.AppendParameter(new CommandParameter("cpw", ClientType == ClientType.Full ? Full.Ts3Crypt.HashPassword(channelPassword) : channelPassword)); } return(SendCommand <ResponseVoid>(cmd)); }
protected override IEnumerable <T> SendCommand <T>(Ts3Command com) { var retCode = new CommandParameter("return_code", returnCode); if (com.ExpectResponse) { com.AppendParameter(retCode); } using (var wb = new WaitBlock()) { lock (CommmandQueueLock) { if (com.ExpectResponse) { msgProc.EnqueueRequest(retCode.Value, wb); returnCode++; } byte[] data = Util.Encoder.GetBytes(com.ToString()); lock (StatusLock) { if (wasExit) { throw new Ts3CommandException(new CommandError { Id = Ts3ErrorCode.custom_error, Message = "Connection closed" }); } packetHandler.AddOutgoingPacket(data, PacketType.Command); } } if (com.ExpectResponse) { return(wb.WaitForMessage <T>()); } else { return(null); } } }
private void SendCommandBase(WaitBlock wb, Ts3Command com) { lock (statusLock) { if (context.WasExit || (!Connected && com.ExpectResponse)) { throw new Ts3CommandException(Util.TimeOutCommandError); } if (com.ExpectResponse) { var responseNumber = ++returnCode; var retCodeParameter = new CommandParameter("return_code", responseNumber); com.AppendParameter(retCodeParameter); msgProc.EnqueueRequest(retCodeParameter.Value, wb); } byte[] data = Util.Encoder.GetBytes(com.ToString()); packetHandler.AddOutgoingPacket(data, PacketType.Command); } }
private E <CommandError> SendCommandBase(WaitBlock wb, Ts3Command com) { lock (statusLock) { if (context.WasExit || (!Connected && com.ExpectResponse)) { return(Util.TimeOutCommandError); } if (com.ExpectResponse) { var responseNumber = ++returnCode; var retCodeParameter = new CommandParameter("return_code", responseNumber); com.AppendParameter(retCodeParameter); msgProc.EnqueueRequest(retCodeParameter.Value, wb); } var message = com.ToString(); LogCmd.Debug("[O] {0}", message); byte[] data = Util.Encoder.GetBytes(message); packetHandler.AddOutgoingPacket(data, PacketType.Command); } return(E <CommandError> .OkR); }