#pragma once #include "PluginTypes.hpp" #include "Types.hpp" #include #include #include #include #include #include #include #include namespace Echoion::Api { // Forward declarations class IPluginInterface; using PluginInterfacePtr = std::shared_ptr; // Plugin interface that the Core will use // MINIMAL VERSION - only depends on Types.hpp and PluginTypes.hpp // NO dependencies on TrackTypes, ConfigTypes, RpcTypes, etc. class IPluginInterface { public: virtual ~IPluginInterface() = default; // Lifecycle virtual Result initialize() = 0; virtual Result shutdown() = 0; // Client operations [[nodiscard]] virtual Result> getClients() = 0; [[nodiscard]] virtual Result> getClient(uint64_t clientId) = 0; // Network address of a client as reported by TeamSpeak // (CONNECTION_CLIENT_IP). Requires the bot to hold the // b_client_remoteaddress_view permission; hosts that cannot // resolve the address return nullopt. [[nodiscard]] virtual Result> getClientIp(uint64_t /*clientId*/) { return std::optional{}; } // Local filesystem path of the client's avatar image as cached // by the TeamSpeak client (getAvatar). The cache is only // populated for clients the TS client has seen; nullopt when the // client has no avatar or it is not (yet) downloaded. [[nodiscard]] virtual Result> getClientAvatarPath(uint64_t /*clientId*/) { return std::optional{}; } // The client's myTeamSpeak avatar URL, if set. Modern clients store // their avatar as a public HTTPS URL (CLIENT_MYTS_AVATAR, formatted // ",") rather than the legacy file-transfer avatar. // Returns the bare URL, or nullopt when unset/legacy. [[nodiscard]] virtual Result> getClientAvatarUrl(uint64_t /*clientId*/) { return std::optional{}; } // Actively fetch a client's avatar from the server into `destDir` // (used when it isn't in the TS client's own cache — e.g. the // client is not in view). Returns the local path once the file is // present; returns nullopt when the client has no avatar or the // download was just triggered and hasn't finished yet (a later // call returns the path). Downloads run asynchronously. [[nodiscard]] virtual Result> requestClientAvatar(uint64_t /*clientId*/, const std::string& /*destDir*/) { return std::optional{}; } virtual Result moveClient(uint64_t clientId, uint64_t channelId) = 0; virtual Result kickClient(uint64_t clientId, const std::string& reason) = 0; // Channel operations [[nodiscard]] virtual Result> getChannels() const = 0; [[nodiscard]] virtual Result> getChannel(uint64_t channelId) const = 0; // Messaging virtual Result sendTextMessage(uint64_t targetId, const std::string& message) = 0; virtual Result sendChannelMessage(uint64_t channelId, const std::string& message) = 0; virtual Result sendServerMessage(const std::string& message) = 0; // Audio virtual Result sendAudioData(const std::span& data) = 0; virtual Result setWhisperList(const std::vector& clientIds) = 0; // Independent audio timelines. A TeamSpeak connection has one voice // sequence, so hosts implement each stream with its own connection and // encoder. The default methods preserve compatibility for hosts that only // support the primary stream. using AudioStreamId = uint64_t; struct AudioStreamOptions { std::string name; ServerConfig server; std::vector recipients; }; [[nodiscard]] virtual Result createAudioStream(const AudioStreamOptions&) { return fail(ErrorCode::NotSupported, "independent audio streams are not supported by this host"); } virtual Result destroyAudioStream(AudioStreamId) { return fail(ErrorCode::NotSupported, "independent audio streams are not supported by this host"); } virtual Result sendAudioDataToStream( AudioStreamId, const std::span&) { return fail(ErrorCode::NotSupported, "independent audio streams are not supported by this host"); } virtual Result setAudioStreamRecipients( AudioStreamId, const std::vector&) { return fail(ErrorCode::NotSupported, "independent audio streams are not supported by this host"); } // Server connection // ServerConfig is defined in PluginTypes.hpp (self-contained) virtual Result connectToServer(const ServerConfig& config) = 0; virtual Result disconnectFromServer() = 0; [[nodiscard]] virtual bool isConnected() const = 0; virtual Result reconnect() = 0; // Event subscription virtual void registerEventCallback(const EventCallback& callback) = 0; virtual void unregisterEventCallback(const EventCallback& callback) = 0; }; } // namespace Echoion::Api