Skip to content

Commit c7e44e4

Browse files
committed
Merge branch 'develop'
2 parents 65aa9a1 + 7cb413a commit c7e44e4

File tree

320 files changed

+10101
-7719
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

320 files changed

+10101
-7719
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
.vs/
1313
.vscode/
1414
.idea/
15+
[Pp]roperties/
1516

1617
# Build results
1718
[Dd]ebug/

.gitmodules

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "TS3Client/Declarations"]
2-
path = TS3Client/Declarations
1+
[submodule "TSLib/Declarations"]
2+
path = TSLib/Declarations
33
url = https://github.com/ReSpeak/tsdeclarations

Directory.Build.targets

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<Project>
22
<ItemGroup>
3-
<PackageReference Include="NLog" Version="4.6.7" />
4-
<PackageReference Condition="'$(TargetFramework)' != 'netcoreapp2.2'" Include="System.Memory" Version="4.5.3" />
3+
<PackageReference Include="NLog" Version="4.6.8" />
4+
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
5+
<PackageReference Condition="'$(TargetFramework)' == 'net472'" Include="System.Memory" Version="4.5.3" />
6+
<PackageReference Condition="'$(TargetFramework)' == 'netstandard2.0'" Include="System.Memory" Version="4.5.3" />
57
</ItemGroup>
68
</Project>

GitVersion.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
assembly-versioning-scheme: MajorMinorPatch
2+
mode: Mainline
3+
branches:
4+
master:
5+
tag: ''
6+
increment: Patch
7+
prevent-increment-of-merged-branch-version: true
8+
track-merge-target: false
9+
regex: ^master$
10+
tracks-release-branches: false
11+
is-release-branch: false
12+
is-mainline: true
13+
develop:
14+
tag: alpha
15+
increment: Minor
16+
prevent-increment-of-merged-branch-version: false
17+
track-merge-target: true
18+
regex: ^develop$
19+
tracks-release-branches: true
20+
is-release-branch: false
21+
ignore:
22+
sha: []
23+
merge-message-formats: {}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ Translations need to be manually approved and will then be automatically built a
121121
This project is licensed under [OSL-3.0](https://opensource.org/licenses/OSL-3.0).
122122

123123
Why OSL-3.0:
124-
- OSL allows you to link to our libraries without needing to disclose your own project, which might be useful if you want to use the TS3Client as a library.
124+
- OSL allows you to link to our libraries without needing to disclose your own project, which might be useful if you want to use the TSLib as a library.
125125
- If you create plugins you do not have to make them public like in GPL. (Although we would be happy if you shared them :)
126126
- With OSL we want to allow you providing the TS3AB as a service (even commercially). We do not want the software to be sold but the service. We want this software to be free for everyone.
127127
- TL; DR? https://tldrlegal.com/license/open-software-licence-3.0

TS3ABotUnitTests/BotCommandTests.cs

+82-83
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,31 @@
1-
// TS3AudioBot - An advanced Musicbot for Teamspeak 3
2-
// Copyright (C) 2017 TS3AudioBot contributors
3-
//
4-
// This program is free software: you can redistribute it and/or modify
5-
// it under the terms of the Open Software License v. 3.0
6-
//
7-
// You should have received a copy of the Open Software License along with this
8-
// program. If not, see <https://opensource.org/licenses/OSL-3.0>.
1+
using NUnit.Framework;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Globalization;
5+
using System.Linq;
6+
using System.Reflection;
7+
using System.Threading;
8+
using TS3AudioBot;
9+
using TS3AudioBot.Algorithm;
10+
using TS3AudioBot.CommandSystem;
11+
using TS3AudioBot.CommandSystem.Ast;
12+
using TS3AudioBot.CommandSystem.CommandResults;
13+
using TS3AudioBot.CommandSystem.Commands;
14+
using TS3AudioBot.Dependency;
15+
using TSLib;
916

1017
namespace TS3ABotUnitTests
1118
{
12-
using NUnit.Framework;
13-
using System;
14-
using System.Collections.Generic;
15-
using System.Globalization;
16-
using System.Linq;
17-
using System.Reflection;
18-
using System.Threading;
19-
using TS3AudioBot;
20-
using TS3AudioBot.Dependency;
21-
using TS3AudioBot.Algorithm;
22-
using TS3AudioBot.Audio;
23-
using TS3AudioBot.CommandSystem;
24-
using TS3AudioBot.CommandSystem.Ast;
25-
using TS3AudioBot.CommandSystem.CommandResults;
26-
using TS3AudioBot.CommandSystem.Commands;
27-
2819
[TestFixture]
2920
public class BotCommandTests
3021
{
31-
private readonly CommandManager cmdMgr;
32-
33-
public BotCommandTests()
34-
{
35-
cmdMgr = new CommandManager(null);
36-
cmdMgr.RegisterCollection(MainCommands.Bag);
37-
}
38-
3922
[Test]
4023
public void BotCommandTest()
4124
{
4225
var execInfo = Utils.GetExecInfo("ic3");
4326
string CallCommand(string command)
4427
{
45-
return cmdMgr.CommandSystem.ExecuteCommand(execInfo, command);
28+
return CommandManager.ExecuteCommand(execInfo, command);
4629
}
4730

4831
var output = CallCommand("!help");
@@ -93,6 +76,23 @@ string CallCommand(string command)
9376
Assert.Throws<CommandException>(() => CallCommand("!if a == b text (!)"));
9477
}
9578

79+
[Test]
80+
public void TailStringTest()
81+
{
82+
var execInfo = Utils.GetExecInfo("ic3");
83+
var group = execInfo.GetModule<CommandManager>().RootGroup;
84+
group.AddCommand("cmd", new FunctionCommand(s => s));
85+
string CallCommand(string command)
86+
{
87+
return CommandManager.ExecuteCommand(execInfo, command);
88+
}
89+
90+
Assert.AreEqual("a", CallCommand("!cmd a"));
91+
Assert.AreEqual("a b", CallCommand("!cmd a b"));
92+
Assert.AreEqual("a", CallCommand("!cmd a \" b"));
93+
Assert.AreEqual("a b 1", CallCommand("!cmd a b 1"));
94+
}
95+
9696
[Test]
9797
public void XCommandSystemFilterTest()
9898
{
@@ -145,32 +145,30 @@ public void XCommandSystemFilterTest()
145145
[Test]
146146
public void XCommandSystemTest()
147147
{
148-
var execInfo = Utils.GetExecInfo("ic3");
149-
var commandSystem = new XCommandSystem();
150-
var group = commandSystem.RootCommand;
148+
var execInfo = Utils.GetExecInfo("ic3", false);
149+
var group = execInfo.GetModule<CommandManager>().RootGroup;
151150
group.AddCommand("one", new FunctionCommand(() => "ONE"));
152151
group.AddCommand("two", new FunctionCommand(() => "TWO"));
153152
group.AddCommand("echo", new FunctionCommand(s => s));
154153
group.AddCommand("optional", new FunctionCommand(GetType().GetMethod(nameof(OptionalFunc), BindingFlags.NonPublic | BindingFlags.Static)));
155154

156155
// Basic tests
157-
Assert.AreEqual("ONE", ((StringCommandResult)commandSystem.Execute(execInfo,
158-
new ICommand[] { new StringCommand("one") })).Content);
159-
Assert.AreEqual("ONE", commandSystem.ExecuteCommand(execInfo, "!one"));
160-
Assert.AreEqual("TWO", commandSystem.ExecuteCommand(execInfo, "!t"));
161-
Assert.AreEqual("TEST", commandSystem.ExecuteCommand(execInfo, "!e TEST"));
162-
Assert.AreEqual("ONE", commandSystem.ExecuteCommand(execInfo, "!o"));
156+
Assert.AreEqual("ONE", CommandManager.ExecuteCommand(execInfo, new ICommand[] { new ResultCommand(new PrimitiveResult<string>("one")) }));
157+
Assert.AreEqual("ONE", CommandManager.ExecuteCommand(execInfo, "!one"));
158+
Assert.AreEqual("TWO", CommandManager.ExecuteCommand(execInfo, "!t"));
159+
Assert.AreEqual("TEST", CommandManager.ExecuteCommand(execInfo, "!e TEST"));
160+
Assert.AreEqual("ONE", CommandManager.ExecuteCommand(execInfo, "!o"));
163161

164162
// Optional parameters
165-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!e"));
166-
Assert.AreEqual("NULL", commandSystem.ExecuteCommand(execInfo, "!op"));
167-
Assert.AreEqual("NOT NULL", commandSystem.ExecuteCommand(execInfo, "!op 1"));
163+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!e"));
164+
Assert.AreEqual("NULL", CommandManager.ExecuteCommand(execInfo, "!op"));
165+
Assert.AreEqual("NOT NULL", CommandManager.ExecuteCommand(execInfo, "!op 1"));
168166

169167
// Command chaining
170-
Assert.AreEqual("TEST", commandSystem.ExecuteCommand(execInfo, "!e (!e TEST)"));
171-
Assert.AreEqual("TWO", commandSystem.ExecuteCommand(execInfo, "!e (!t)"));
172-
Assert.AreEqual("NOT NULL", commandSystem.ExecuteCommand(execInfo, "!op (!e TEST)"));
173-
Assert.AreEqual("ONE", commandSystem.ExecuteCommand(execInfo, "!(!e on)"));
168+
Assert.AreEqual("TEST", CommandManager.ExecuteCommand(execInfo, "!e (!e TEST)"));
169+
Assert.AreEqual("TWO", CommandManager.ExecuteCommand(execInfo, "!e (!t)"));
170+
Assert.AreEqual("NOT NULL", CommandManager.ExecuteCommand(execInfo, "!op (!e TEST)"));
171+
Assert.AreEqual("ONE", CommandManager.ExecuteCommand(execInfo, "!(!e on)"));
174172

175173
// Command overloading
176174
var intCom = new Func<int, string>(_ => "INT");
@@ -180,17 +178,16 @@ public void XCommandSystemTest()
180178
new FunctionCommand(strCom.Method, strCom.Target)
181179
}));
182180

183-
Assert.AreEqual("INT", commandSystem.ExecuteCommand(execInfo, "!overlord 1"));
184-
Assert.AreEqual("STRING", commandSystem.ExecuteCommand(execInfo, "!overlord a"));
185-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!overlord"));
181+
Assert.AreEqual("INT", CommandManager.ExecuteCommand(execInfo, "!overlord 1"));
182+
Assert.AreEqual("STRING", CommandManager.ExecuteCommand(execInfo, "!overlord a"));
183+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!overlord"));
186184
}
187185

188186
[Test]
189187
public void XCommandSystemTest2()
190188
{
191189
var execInfo = Utils.GetExecInfo("exact");
192-
var commandSystem = new XCommandSystem();
193-
var group = commandSystem.RootCommand;
190+
var group = execInfo.GetModule<CommandManager>().RootGroup;
194191

195192
var o1 = new OverloadedFunctionCommand();
196193
o1.AddCommand(new FunctionCommand(new Action<int>((_) => { })));
@@ -204,25 +201,25 @@ public void XCommandSystemTest2()
204201
o2.AddCommand("b", new FunctionCommand(new Action(() => { })));
205202
group.AddCommand("three", o2);
206203

207-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!one"));
208-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!one \"\""));
209-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!one (!print \"\")"));
210-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!one string"));
211-
Assert.DoesNotThrow(() => commandSystem.ExecuteCommand(execInfo, "!one 42"));
212-
Assert.DoesNotThrow(() => commandSystem.ExecuteCommand(execInfo, "!one 4200000000000"));
213-
214-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!two"));
215-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!two \"\""));
216-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!two (!print \"\")"));
217-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!two 42"));
218-
Assert.DoesNotThrow(() => commandSystem.ExecuteCommand(execInfo, "!two None"));
219-
220-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!three"));
221-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!three \"\""));
222-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!three (!print \"\")"));
223-
Assert.Throws<CommandException>(() => commandSystem.ExecuteCommand(execInfo, "!three c"));
224-
Assert.DoesNotThrow(() => commandSystem.ExecuteCommand(execInfo, "!three a"));
225-
Assert.DoesNotThrow(() => commandSystem.ExecuteCommand(execInfo, "!three b"));
204+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!one"));
205+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!one \"\""));
206+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!one (!print \"\")"));
207+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!one string"));
208+
Assert.DoesNotThrow(() => CommandManager.ExecuteCommand(execInfo, "!one 42"));
209+
Assert.DoesNotThrow(() => CommandManager.ExecuteCommand(execInfo, "!one 4200000000000"));
210+
211+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!two"));
212+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!two \"\""));
213+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!two (!print \"\")"));
214+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!two 42"));
215+
Assert.DoesNotThrow(() => CommandManager.ExecuteCommand(execInfo, "!two None"));
216+
217+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!three"));
218+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!three \"\""));
219+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!three (!print \"\")"));
220+
Assert.Throws<CommandException>(() => CommandManager.ExecuteCommand(execInfo, "!three c"));
221+
Assert.DoesNotThrow(() => CommandManager.ExecuteCommand(execInfo, "!three a"));
222+
Assert.DoesNotThrow(() => CommandManager.ExecuteCommand(execInfo, "!three b"));
226223
}
227224

228225
[Test]
@@ -231,10 +228,16 @@ public void EnsureAllCommandsHaveEnglishDocumentationEntry()
231228
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en");
232229
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en");
233230

231+
var execInfo = Utils.GetExecInfo("exact");
232+
var cmdMgr = execInfo.GetModule<CommandManager>();
233+
var errors = new List<string>();
234234
foreach (var cmd in cmdMgr.AllCommands)
235235
{
236-
Assert.IsFalse(string.IsNullOrEmpty(cmd.Description), $"Command {cmd.FullQualifiedName} has no documentation");
236+
if (string.IsNullOrEmpty(cmd.Description))
237+
errors.Add($"Command {cmd.FullQualifiedName} has no documentation");
237238
}
239+
if (errors.Count > 0)
240+
Assert.Fail(string.Join("\n", errors));
238241
}
239242

240243
[Test]
@@ -269,19 +272,15 @@ public static void TestStringParsing(string inp, string outp)
269272

270273
internal static class Utils
271274
{
272-
private static readonly CommandManager cmdMgr;
273-
274-
static Utils()
275+
public static ExecutionInformation GetExecInfo(string matcher, bool addMainCommands = true)
275276
{
276-
cmdMgr = new CommandManager(null);
277-
cmdMgr.RegisterCollection(MainCommands.Bag);
278-
}
277+
var cmdMgr = new CommandManager(null);
278+
if (addMainCommands)
279+
cmdMgr.RegisterCollection(MainCommands.Bag);
279280

280-
public static ExecutionInformation GetExecInfo(string matcher)
281-
{
282281
var execInfo = new ExecutionInformation();
283282
execInfo.AddModule(new CallerInfo(false) { SkipRightsChecks = true, CommandComplexityMax = int.MaxValue });
284-
execInfo.AddModule(new InvokerData("InvokerUid"));
283+
execInfo.AddModule(new InvokerData((Uid)"InvokerUid"));
285284
execInfo.AddModule(Filter.GetFilterByName(matcher));
286285
execInfo.AddModule(cmdMgr);
287286
return execInfo;

TS3ABotUnitTests/M3uParserTests.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
using NUnit.Framework;
2+
using System.IO;
3+
using System.Text;
4+
using TS3AudioBot.ResourceFactories.AudioTags;
5+
16
namespace TS3ABotUnitTests
27
{
3-
using NUnit.Framework;
4-
using System.IO;
5-
using System.Text;
6-
using TS3AudioBot.ResourceFactories.AudioTags;
7-
88
[TestFixture]
9-
class M3uParserTests
9+
internal class M3uParserTests
1010
{
1111
[Test]
1212
public void SimpleListTest()

TS3ABotUnitTests/RingQueueTest.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
using NUnit.Framework;
2+
using System;
3+
using TSLib.Full;
4+
15
namespace TS3ABotUnitTests
26
{
3-
using NUnit.Framework;
4-
using System;
5-
using TS3Client.Full;
6-
77
[TestFixture]
8-
class RingQueueTest
8+
internal class RingQueueTest
99
{
1010

1111
[Test]

TS3ABotUnitTests/TS3ABotUnitTests.csproj

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Library</OutputType>
5-
<TargetFrameworks>netcoreapp2.2;net472</TargetFrameworks>
5+
<TargetFrameworks>netcoreapp2.2;netcoreapp3.1;net472</TargetFrameworks>
66

77
<LangVersion>7.3</LangVersion>
88
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -11,13 +11,16 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="NUnit" Version="3.12.0" />
14-
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
14+
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
15+
<PrivateAssets>all</PrivateAssets>
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
</PackageReference>
18+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
1619
</ItemGroup>
1720

1821
<ItemGroup>
1922
<ProjectReference Include="..\TS3AudioBot\TS3AudioBot.csproj" />
20-
<ProjectReference Include="..\TS3Client\TS3Client.csproj" />
23+
<ProjectReference Include="..\TSLib\TSLib.csproj" />
2124
</ItemGroup>
2225

2326
</Project>

0 commit comments

Comments
 (0)