Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-12 02:34:34 +03:00
1 parent a7ffe73a6c
commit c1a11ffe29
29 files changed
+433 -123

No files matched your search

+30 -1
View File
@@ -2,6 +2,7 @@
#include <Void/Functional/Result.hpp>
#include <Void/TeamSpeak/Identity.hpp>
#include <Void/TeamSpeak/Command.hpp>
#include <Void/TeamSpeak/Types.hpp>
#include <chrono>
@@ -27,10 +28,15 @@ namespace Void::TeamSpeak
};
struct CommandResponse {
using Record = std::map<std::string, std::string>;
using Record = CommandFields;
std::vector<Record> records;
};
struct CommandEvent {
std::string name;
std::vector<CommandResponse::Record> records;
};
struct Events {
std::function<void()> connected;
std::function<void()> disconnected;
@@ -38,6 +44,12 @@ namespace Void::TeamSpeak
std::function<void(std::string_view)> debug;
std::function<void(std::string_view,
const std::map<std::string, std::string>&)> command;
std::function<void(const CommandEvent&)> commandBatch;
std::function<void(const RemoteClient&)> clientEntered;
std::function<void(const ClientLeft&)> clientLeft;
std::function<void(const ClientMoved&)> clientMoved;
std::function<void(const TextMessage&)> textMessage;
std::function<void(const ChannelChanged&)> channelChanged;
std::function<void(std::span<const std::uint8_t>)> voice;
};
@@ -69,10 +81,19 @@ namespace Void::TeamSpeak
[[nodiscard]] Void::Result::Result<std::vector<ServerGroup>, Error>
serverGroups(
std::chrono::milliseconds timeout = std::chrono::seconds{3});
[[nodiscard]] Void::Result::Result<std::vector<ChannelGroup>, Error>
channelGroups(
std::chrono::milliseconds timeout = std::chrono::seconds{3});
[[nodiscard]] Void::Result::Result<std::vector<Permission>, Error>
permissions(
std::chrono::milliseconds timeout = std::chrono::seconds{3});
[[nodiscard]] Void::Result::Result<void, Error>
addToServerGroup(ServerGroupId group, ClientDatabaseId client);
[[nodiscard]] Void::Result::Result<void, Error>
removeFromServerGroup(ServerGroupId group, ClientDatabaseId client);
[[nodiscard]] Void::Result::Result<void, Error>
setChannelGroup(ChannelGroupId group, ChannelId channel,
ClientDatabaseId client);
[[nodiscard]] Void::Result::Result<void, Error>
sendText(TextTarget target, std::string_view message);
[[nodiscard]] Void::Result::Result<void, Error>
@@ -85,6 +106,14 @@ namespace Void::TeamSpeak
ChannelId channel = {},
std::string_view channelPassword = {},
std::chrono::milliseconds timeout = std::chrono::seconds{10});
[[nodiscard]] Void::Result::Result<void, Error>
upload(const std::filesystem::path& source,
std::string_view remotePath, ChannelId channel = {},
std::string_view channelPassword = {}, bool overwrite = false,
std::chrono::milliseconds timeout = std::chrono::seconds{10});
[[nodiscard]] Void::Result::Result<void, Error>
deleteFile(std::string_view remotePath, ChannelId channel = {},
std::string_view channelPassword = {});
[[nodiscard]] Void::Result::Result<void, Error>
sendVoice(std::span<const std::uint8_t> opusFrame);
+14
View File
@@ -0,0 +1,14 @@
#pragma once
#include <map>
#include <string>
#include <string_view>
namespace Void::TeamSpeak
{
using CommandFields = std::map<std::string, std::string>;
// Build a TeamSpeak command with protocol-safe escaping for every value.
[[nodiscard]] std::string buildCommand(
std::string_view name, const CommandFields& fields = {});
}
+2 -2
View File
@@ -1,10 +1,10 @@
#pragma once
#include <echoion/protocol/Identity.hpp>
#include <Void/TeamSpeak/Protocol/Identity.hpp>
namespace Void::TeamSpeak
{
// Modern public name; the implementation remains source-compatible during
// the extraction release.
using Identity = Echoion::Protocol::Identity;
using Identity = Void::TeamSpeak::Protocol::Identity;
}
@@ -7,7 +7,7 @@
#include <string>
#include <vector>
namespace Echoion::Protocol
namespace Void::TeamSpeak::Protocol
{
// Escape / unescape a single token per the TS3 rules
@@ -33,4 +33,4 @@ namespace Echoion::Protocol
// Parse a raw command / notify line into name + params (+ pipe groups).
ParsedCommand parseCommand(const std::string& raw);
} // namespace Echoion::Protocol
} // namespace Void::TeamSpeak::Protocol
@@ -15,7 +15,7 @@
#include <string>
#include <vector>
namespace Echoion::Protocol::Crypto
namespace Void::TeamSpeak::Protocol::Crypto
{
using Bytes = std::vector<uint8_t>;
@@ -85,4 +85,4 @@ namespace Echoion::Protocol::Crypto
// base64(sha1(utf8(password))); empty string for empty password.
std::string hashPassword(const std::string& password);
} // namespace Echoion::Protocol::Crypto
} // namespace Void::TeamSpeak::Protocol::Crypto
@@ -11,7 +11,7 @@
#include <string>
#include <vector>
namespace Echoion::Protocol
namespace Void::TeamSpeak::Protocol
{
class Identity
@@ -62,4 +62,4 @@ namespace Echoion::Protocol
uint64_t keyOffset_ = 0;
};
} // namespace Echoion::Protocol
} // namespace Void::TeamSpeak::Protocol
@@ -10,7 +10,7 @@
#include <span>
#include <vector>
namespace Echoion::Protocol
namespace Void::TeamSpeak::Protocol
{
using Bytes = std::vector<uint8_t>;
@@ -42,4 +42,4 @@ namespace Echoion::Protocol
std::array<uint8_t, 64>
getSharedSecret2(ByteView serverDerivedKey, ByteView tempPrivateKey);
} // namespace Echoion::Protocol
} // namespace Void::TeamSpeak::Protocol
@@ -8,7 +8,7 @@
#include <span>
#include <vector>
namespace Echoion::Protocol
namespace Void::TeamSpeak::Protocol
{
using Bytes = std::vector<uint8_t>;
@@ -20,4 +20,4 @@ namespace Echoion::Protocol
// Throws std::runtime_error on malformed input or unsupported level.
Bytes qlzDecompress(ByteView data);
} // namespace Echoion::Protocol
} // namespace Void::TeamSpeak::Protocol
@@ -8,8 +8,8 @@
// send methods are thread-safe (guarded by an internal mutex) so the audio
// thread can call sendVoice() directly. Callbacks fire on the loop thread.
#include "echoion/protocol/Command.hpp"
#include "echoion/protocol/Identity.hpp"
#include "Void/TeamSpeak/Protocol/Command.hpp"
#include "Void/TeamSpeak/Protocol/Identity.hpp"
#include <Void/Net/Socket.hpp>
#include <atomic>
@@ -26,7 +26,7 @@
#include <thread>
#include <vector>
namespace Echoion::Protocol
namespace Void::TeamSpeak::Protocol
{
enum class PacketType : uint8_t {
@@ -53,7 +53,7 @@ namespace Echoion::Protocol
std::string host;
uint16_t port = 9987;
const Identity* identity = nullptr; // not owned
std::string nickname = "EchoionBot";
std::string nickname = "VoidTeamspeak";
std::string serverPassword;
std::string defaultChannel; // channel id or name
std::string channelPassword;
@@ -122,6 +122,11 @@ namespace Echoion::Protocol
const std::string& remotePath, const std::string& destination,
uint64_t channelId = 0, const std::string& channelPassword = {},
std::chrono::milliseconds timeout = std::chrono::seconds{10});
CommandResult uploadFile(
const std::string& source, const std::string& remotePath,
uint64_t channelId = 0, const std::string& channelPassword = {},
bool overwrite = false,
std::chrono::milliseconds timeout = std::chrono::seconds{10});
private:
@@ -227,4 +232,4 @@ namespace Echoion::Protocol
std::atomic<uint16_t> transferId_{0};
};
} // namespace Echoion::Protocol
} // namespace Void::TeamSpeak::Protocol
@@ -7,7 +7,7 @@
#include <string>
#include <vector>
namespace Echoion::Protocol::Util
namespace Void::TeamSpeak::Protocol::Util
{
using Bytes = std::vector<uint8_t>;
@@ -21,4 +21,4 @@ namespace Echoion::Protocol::Util
std::string toHex(ByteView data);
Bytes fromHex(const std::string& hex);
} // namespace Echoion::Protocol::Util
} // namespace Void::TeamSpeak::Protocol::Util
+1
View File
@@ -1,6 +1,7 @@
#pragma once
#include <Void/TeamSpeak/Client.hpp>
#include <Void/TeamSpeak/Command.hpp>
#include <Void/TeamSpeak/Identity.hpp>
#include <Void/TeamSpeak/Library.hpp>
#include <Void/TeamSpeak/Types.hpp>
+36
View File
@@ -46,6 +46,17 @@ namespace Void::TeamSpeak
std::string uniqueId;
};
struct ClientLeft {
ClientId id;
int reasonId{};
std::string reasonMessage;
};
struct ClientMoved {
ClientId id;
ChannelId channel;
};
struct Channel {
ChannelId id;
std::optional<ChannelId> parent;
@@ -59,12 +70,37 @@ namespace Void::TeamSpeak
int type{};
};
struct ChannelGroup {
ChannelGroupId id;
std::string name;
int type{};
};
struct Permission {
PermissionId id;
std::string name;
std::string description;
};
enum class TextTargetKind { Client = 1, Channel = 2, Server = 3 };
struct TextTarget {
TextTargetKind kind{TextTargetKind::Client};
std::uint64_t id{};
};
struct TextMessage {
TextTarget target;
ClientId invoker;
std::string invokerName;
std::string message;
};
enum class ChannelChangeKind { Created, Updated, Moved, Deleted };
struct ChannelChanged {
ChannelChangeKind kind{ChannelChangeKind::Updated};
Channel channel;
};
struct Error {
enum class Code {
InvalidArgument,