#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; virtual Result kickClientFromChannel(uint64_t /*clientId*/, const std::string& /*reason*/) { return fail(ErrorCode::NotSupported, "channel kick is not supported by this host"); } virtual Result banClient(uint64_t /*clientId*/, uint64_t /*durationSeconds*/, const std::string& /*reason*/) { return fail(ErrorCode::NotSupported, "bans are not supported by this host"); } [[nodiscard]] virtual Result> getBans() { return fail(ErrorCode::NotSupported, "ban listing is not supported by this host"); } virtual Result unban(uint64_t /*banId*/) { return fail(ErrorCode::NotSupported, "unban is not supported by this host"); } // Channel operations [[nodiscard]] virtual Result> getChannels() const = 0; [[nodiscard]] virtual Result> getChannel(uint64_t channelId) const = 0; virtual Result createChannel(const ChannelCreateOptions& /*options*/) { return fail(ErrorCode::NotSupported, "channel creation is not supported by this host"); } virtual Result editChannel(uint64_t /*channelId*/, const ChannelEditOptions& /*options*/) { return fail(ErrorCode::NotSupported, "channel editing is not supported by this host"); } virtual Result reorderChannel(uint64_t /*channelId*/, uint64_t /*parentId*/, uint64_t /*orderAfterId*/) { return fail(ErrorCode::NotSupported, "channel reordering is not supported by this host"); } virtual Result deleteChannel(uint64_t /*channelId*/, bool /*force*/) { return fail(ErrorCode::NotSupported, "channel deletion is not supported by this host"); } // Server-group administration. Membership changes use TeamSpeak's // stable client database id, not the connection-scoped client id. [[nodiscard]] virtual Result> getServerGroups() { return fail(ErrorCode::NotSupported, "server groups are not supported by this host"); } virtual Result addClientToServerGroup(uint64_t /*groupId*/, uint64_t /*clientDatabaseId*/) { return fail( ErrorCode::NotSupported, "server-group membership is not supported by this host"); } virtual Result removeClientFromServerGroup(uint64_t /*groupId*/, uint64_t /*clientDatabaseId*/) { return fail( ErrorCode::NotSupported, "server-group membership is not supported by this host"); } [[nodiscard]] virtual Result getTeamSpeakServerInfo() { return fail(ErrorCode::NotSupported, "server information is not supported by this host"); } // 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; // 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; // Host-owned control plane. Keep this generic JSON operation at the // very end of the ABI so updater/service operations can evolve // without shifting existing vtable entries. Hosts that do not // expose a control plane retain the previous behavior through this // default. [[nodiscard]] virtual Result hostControl(const std::string& /*method*/, const std::string& /*requestJson*/) { return fail(ErrorCode::NotSupported, "host control is not supported by this host"); } }; } // namespace Echoion::Api