Skip to content

Commit 03c42f6

Browse files
committed
Fixes and improvements
+ Updated launch parameter + Added SubscribeAll + Added IPv6 support + Updated proto
1 parent 19bf324 commit 03c42f6

File tree

6 files changed

+44
-22
lines changed

6 files changed

+44
-22
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Download the git repository with `git clone https://github.com/Splamy/TS3AudioBo
6565
1. See if you have NuGet by just executing `nuget`. If not, get `NuGet.exe` with `wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe`
6666
1. Go into the directory of the repository with `cd TS3AudioBot`
6767
1. Execute `nuget restore` or `mono ../Nuget.exe restore` to download all dependencies
68-
1. Execute `msbuild /p:Configuration=Release /p:Platform=AnyCPU TS3AudioBot.sln` to build the C# AudioBot
68+
1. Execute `msbuild /p:Configuration=Release TS3AudioBot.sln` to build the C# AudioBot
6969
1. Getting the dependencies
7070
* on **Ubuntu**:
7171
Run `sudo apt-get install libopus-dev ffmpeg`
@@ -106,4 +106,4 @@ This project is licensed under OSL-3.0.
106106
Why OSL-3.0:
107107
- 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.
108108
- If you create plugins you do not have to make them public like in GPL. (Although we would be happier if you shared them :)
109-
- 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.
109+
- 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.

TS3AudioBot/MainBot.cs

+18-10
Original file line numberDiff line numberDiff line change
@@ -93,30 +93,31 @@ private bool ReadParameter(string[] args)
9393
{
9494
case "-h":
9595
case "--help":
96-
Console.WriteLine(" --Quiet -q Deactivates all output to stdout.");
97-
Console.WriteLine(" --NoLog -L Deactivates writing to the logfile.");
98-
Console.WriteLine(" --Stack -s Adds the stacktrace to all log writes.");
99-
Console.WriteLine(" --Config -c <file> Specifies the path to the config file.");
100-
Console.WriteLine(" --help -h Prints this help....");
96+
Console.WriteLine(" --quiet -q Deactivates all output to stdout.");
97+
Console.WriteLine(" --no-log -L Deactivates writing to the logfile.");
98+
Console.WriteLine(" --stack -s Adds the stacktrace to all log writes.");
99+
Console.WriteLine(" --config -c <file> Specifies the path to the config file.");
100+
Console.WriteLine(" --version -V Gets the bot version.");
101+
Console.WriteLine(" --help -h Prints this help....");
101102
return false;
102103

103104
case "-q":
104-
case "--Quiet":
105+
case "--quiet":
105106
consoleOutput = false;
106107
break;
107108

108109
case "-L":
109-
case "--NoLog":
110+
case "--no-log":
110111
writeLog = false;
111112
break;
112113

113114
case "-s":
114-
case "--Stack":
115+
case "--stack":
115116
writeLogStack = true;
116117
break;
117118

118119
case "-c":
119-
case "--Config":
120+
case "--config":
120121
if (i >= args.Length - 1)
121122
{
122123
Console.WriteLine("No config file specified after \"{0}\"", args[i]);
@@ -125,6 +126,11 @@ private bool ReadParameter(string[] args)
125126
configFilePath = args[++i];
126127
break;
127128

129+
case "-V":
130+
case "--version":
131+
Console.WriteLine(Util.GetAssemblyData().ToLongString());
132+
return false;
133+
128134
default:
129135
Console.WriteLine("Unrecognized parameter: {0}", args[i]);
130136
return false;
@@ -1398,6 +1404,7 @@ public ICommandResult CommandTake(ExecutionInformation info, IEnumerable<IComman
13981404
throw new CommandException("Can't find a fitting return type for take", CommandExceptionReason.NoReturnMatch);
13991405
}
14001406

1407+
#if DEBUG
14011408
[Command("test", "Only for debugging purposes.")]
14021409
public JsonObject CommandTest(ExecutionInformation info, string privet)
14031410
{
@@ -1424,6 +1431,7 @@ public JsonTest(string msgval) : base(msgval)
14241431

14251432
}
14261433
}
1434+
#endif
14271435

14281436
[Command("unsubscribe", "Only lets you hear the music in active channels again.")]
14291437
public void CommandUnsubscribe(ExecutionInformation info)
@@ -1720,7 +1728,7 @@ public void Dispose()
17201728
PluginManager?.Dispose(); // before: SessionManager, logStream,
17211729
PluginManager = null;
17221730

1723-
PlayManager.Stop();
1731+
PlayManager?.Stop();
17241732

17251733
PlayerConnection?.Dispose(); // before: logStream,
17261734
PlayerConnection = null;

TS3AudioBot/PlayManager.cs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace TS3AudioBot
1313
using History;
1414
using ResourceFactories;
1515
using System;
16-
using TS3Client.Messages;
1716

1817
public class PlayManager
1918
{

TS3Client/Full/PacketHandler.cs

+14-6
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private void ConnectUdpClient(string host, ushort port)
125125

126126
remoteAddress = new IPEndPoint(ipAddr, port);
127127

128-
udpClient = new UdpClient();
128+
udpClient = new UdpClient(remoteAddress.AddressFamily);
129129
udpClient.Connect(remoteAddress);
130130
}
131131
catch (SocketException ex) { throw new Ts3Exception("Could not connect", ex); }
@@ -149,7 +149,7 @@ public void AddOutgoingPacket(byte[] packet, PacketType packetType, PacketFlags
149149
{
150150
if (Closed)
151151
return;
152-
152+
153153
if (NeedsSplitting(packet.Length))
154154
{
155155
if (packetType == PacketType.Voice || packetType == PacketType.VoiceWhisper)
@@ -191,8 +191,8 @@ private void AddOutgoingPacket(OutgoingPacket packet, PacketFlags flags = Packet
191191
else
192192
packet.PacketFlags |= flags | PacketFlags.Newprotocol;
193193
var ids = GetPacketCounter(packet.PacketType);
194-
packet.PacketId = ids.Item1;
195-
packet.GenerationId = ids.Item2;
194+
packet.PacketId = ids.Id;
195+
packet.GenerationId = ids.Generation;
196196
if (packet.PacketType == PacketType.Voice || packet.PacketType == PacketType.VoiceWhisper)
197197
NetUtil.H2N(packet.PacketId, packet.Data, 0);
198198
if (ts3Crypt.CryptoInitComplete)
@@ -213,8 +213,8 @@ private void AddOutgoingPacket(OutgoingPacket packet, PacketFlags flags = Packet
213213
}
214214
}
215215

216-
private Tuple<ushort, uint> GetPacketCounter(PacketType packetType)
217-
=> new Tuple<ushort, uint>(packetCounter[(int)packetType], generationCounter[(int)packetType]);
216+
private IdTuple GetPacketCounter(PacketType packetType)
217+
=> new IdTuple(packetCounter[(int)packetType], generationCounter[(int)packetType]);
218218
private void IncPacketCounter(PacketType packetType)
219219
{
220220
packetCounter[(int)packetType]++;
@@ -588,4 +588,12 @@ private void SendRaw(OutgoingPacket packet)
588588
udpClient.Send(packet.Raw, packet.Raw.Length);
589589
}
590590
}
591+
592+
struct IdTuple
593+
{
594+
public ushort Id { get; set; }
595+
public uint Generation { get; set; }
596+
597+
public IdTuple(ushort id, uint generation) { Id = id; Generation = generation; }
598+
}
591599
}

TS3Client/Full/Ts3FullClient.cs

+9-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public sealed class Ts3FullClient : Ts3BaseFunctions
4646
public override event NotifyEventHandler<TextMessage> OnTextMessageReceived;
4747
public override event NotifyEventHandler<ClientEnterView> OnClientEnterView;
4848
public override event NotifyEventHandler<ClientLeftView> OnClientLeftView;
49+
public event NotifyEventHandler<ClientMoved> OnClientMoved;
4950
public override event EventHandler<EventArgs> OnConnected;
5051
public override event EventHandler<DisconnectEventArgs> OnDisconnected;
5152
public event EventHandler<CommandError> OnErrorEvent;
@@ -157,15 +158,15 @@ private void InvokeEvent(LazyNotification lazyNotification)
157158
OnClientLeftView?.Invoke(this, clientLeftArr);
158159
break;
159160

160-
case NotificationType.ClientMoved: break;
161+
case NotificationType.ClientMoved: OnClientMoved?.Invoke(this, notification.Cast<ClientMoved>()); break;
161162
case NotificationType.ServerEdited: break;
162163
case NotificationType.TextMessage: OnTextMessageReceived?.Invoke(this, notification.Cast<TextMessage>()); break;
163164
case NotificationType.TokenUsed: break;
164165
// full client events
165166
case NotificationType.InitIvExpand: ProcessInitIvExpand((InitIvExpand)notification.FirstOrDefault()); break;
166167
case NotificationType.InitServer: ProcessInitServer((InitServer)notification.FirstOrDefault()); break;
167168
case NotificationType.ChannelList: break;
168-
case NotificationType.ChannelListFinished: break;
169+
case NotificationType.ChannelListFinished: ChannelSubscribeAll(); break;
169170
case NotificationType.ClientNeededPermissions: break;
170171
case NotificationType.ClientChannelGroupChanged: break;
171172
case NotificationType.ClientServerGroupAdded: break;
@@ -360,6 +361,12 @@ public void ClientDisconnect(MoveReason reason, string reasonMsg)
360361
new CommandParameter("reasonid", (int)reason),
361362
new CommandParameter("reasonmsg", reasonMsg) }));
362363

364+
public void ChannelSubscribeAll()
365+
=> Send("channelsubscribeall");
366+
367+
public void ChannelUnsubscribeAll()
368+
=> Send("channelunsubscribeall");
369+
363370
public void SendAudio(byte[] buffer, int length, Codec codec)
364371
{
365372
// [X,X,Y,DATA]

TS3Client/ts3protocol.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ The packet header values are set as following for all packets here:
267267
| nonce | N/A |
268268
| Type | Init1 |
269269
| Encrypted ||
270-
| Flags | Newprotocol |
270+
| Flags | Newprotocol, Unencrypted |
271271
| Packet Id | u16: 101 |
272272
| Client Id | u16: 0 |
273273

0 commit comments

Comments
 (0)