Skip to content

Commit b170efd

Browse files
committed
added servergroupclientlist cmd
Ref #823
1 parent 0cbae9c commit b170efd

File tree

8 files changed

+20
-11
lines changed

8 files changed

+20
-11
lines changed

TS3AudioBot/MainCommands.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ public static async Task CommandNext(PlayManager playManager, InvokerData invoke
11481148
[Command("param", "_undocumented")] // TODO add documentation, when name decided
11491149
public static async Task<object?> CommandParam(ExecutionInformation info, int index)
11501150
{
1151-
if (!info.TryGet<AliasContext>(out var ctx) || ctx.Arguments == null)
1151+
if (!info.TryGet<AliasContext>(out var ctx) || ctx.Arguments is null)
11521152
throw new CommandException("No parameter available", CommandExceptionReason.CommandError);
11531153

11541154
if (index < 0 || index >= ctx.Arguments.Count)
@@ -1819,7 +1819,7 @@ public static JsonObject CommandWhisperList(IVoiceTarget targetManager)
18191819
strb.Append(strings.cmd_whisper_list_target_whisper_channel).Append(": [").Append(string.Join(",", x.WhisperChannel)).Append("]");
18201820
break;
18211821
case TargetSendMode.WhisperGroup:
1822-
if (x.GroupWhisper == null) throw new ArgumentNullException();
1822+
if (x.GroupWhisper is null) throw new ArgumentNullException();
18231823
strb.AppendFormat(strings.cmd_whisper_list_target_whispergroup, x.GroupWhisper.Type, x.GroupWhisper.Target, x.GroupWhisper.TargetId);
18241824
break;
18251825
default:

TS3AudioBot/ResourceFactories/AudioResource.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public AudioResource Add(string key, string value)
5555

5656
public string? Get(string key)
5757
{
58-
if (AdditionalData == null)
58+
if (AdditionalData is null)
5959
return null;
6060
return AdditionalData.TryGetValue(key, out var value) ? value : null;
6161
}

TS3AudioBot/Ts3Client.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public async Task Disconnect()
196196

197197
private void UpdateIndentityToSecurityLevel(int targetLevel)
198198
{
199-
if (identity == null) throw new InvalidOperationException();
199+
if (identity is null) throw new InvalidOperationException();
200200
if (TsCrypt.GetSecurityLevel(identity) < targetLevel)
201201
{
202202
Log.Info("Calculating up to required security level: {0}", targetLevel);
@@ -249,7 +249,7 @@ public async Task<ClientList> GetClientByName(string name)
249249
await RefreshClientBuffer(false);
250250
var client = Filter.DefaultFilter.Filter(
251251
clientbuffer.Select(cb => new KeyValuePair<string, ClientList>(cb.Name, cb)), name).FirstOrDefault().Value;
252-
if (client == null)
252+
if (client is null)
253253
throw new CommandException(strings.error_ts_no_client_found);
254254
return client;
255255
}
@@ -621,7 +621,7 @@ private bool AloneRecheckRequired(ClientId clientId, ChannelId channelId)
621621
private async ValueTask IsAloneRecheck()
622622
{
623623
var self = ts3FullClient.Book.Self();
624-
if (self == null)
624+
if (self is null)
625625
return;
626626
var ownChannel = self.Channel;
627627
ownChannelClients = ts3FullClient.Book.Clients.Values.Where(c => c.Channel == ownChannel && c != self).Select(c => c.Id).ToArray();

TS3AudioBot/Web/Api/WebApi.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public async Task ProcessApiV1Call(HttpContext context)
114114
Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
115115
var res = await command.Execute(execInfo, Array.Empty<ICommand>());
116116

117-
if (res == null)
117+
if (res is null)
118118
{
119119
response.StatusCode = (int)HttpStatusCode.NoContent;
120120
}

TSLib/Commands/TsCommand.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,12 @@ public TsCommand(string command, ICollection<ICommandPart> parameter) : this(com
4848
}
4949

5050
[DebuggerStepThrough]
51-
public virtual TsCommand Add(ICommandPart addParameter)
51+
public virtual TsCommand Add(ICommandPart? addParameter)
5252
{
53+
if (addParameter is null)
54+
return this;
5355
raw = null;
54-
if (parameter == null)
56+
if (parameter is null)
5557
parameter = new List<ICommandPart>();
5658
else if (parameter.IsReadOnly)
5759
parameter = new List<ICommandPart>(parameter);

TSLib/Commands/TsCommand.gen.tt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<#
1818
// "TimeSpan" (Currently removed, as it is too ambiguous)
1919
var types = new [] {"bool", "sbyte", "byte", "short", "ushort", "int", "uint", "long", "ulong", "float", "double", "string", "DateTime" };
20-
var aliasTypes = new [] { "Uid", "ClientDbId", "ClientId", "ChannelId", "ServerGroupId", "ChannelGroupId"};
20+
var aliasTypes = new [] { "Uid", "ClientDbId", "ClientId", "ChannelId", "ServerGroupId", "ChannelGroupId" };
2121
var classTypes = new [] { "string" };
2222
#>
2323

TSLib/Full/Book/Book.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public partial class Connection
2323
public Channel? CurrentChannel()
2424
{
2525
var self = Self();
26-
if (self == null)
26+
if (self is null)
2727
return null;
2828
return GetChannel(self.Channel);
2929
}

TSLib/TsBaseFunctions.cs

+7
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,13 @@ public Task<R<ServerConnectionInfo, CommandError>> GetServerConnectionInfo()
423423
=> SendHybrid<ServerConnectionInfo>(new TsCommand("serverrequestconnectioninfo"),
424424
NotificationType.ServerConnectionInfo).MapToSingle();
425425

426+
public Task<R<ServerGroupClientList[], CommandError>> ServerGroupClientList(ServerGroupId serverGroupId, bool getNames = false)
427+
=> SendHybrid<ServerGroupClientList>(new TsCommand("servergroupclientlist")
428+
{
429+
{ "sgid", serverGroupId },
430+
{ getNames ? new CommandOption("names") : null }
431+
}, NotificationType.ServerGroupClientList);
432+
426433
#endregion
427434
}
428435
}

0 commit comments

Comments
 (0)