Files
EchoionApi/include/echoion/api/interfaces/PluginInterface.hpp
T
2026-07-11 00:44:08 +03:00

121 lines
4.1 KiB
C++

#pragma once
#include "PluginTypes.hpp"
#include "Types.hpp"
#include <expected>
#include <filesystem>
#include <functional>
#include <future>
#include <memory>
#include <span>
#include <string>
#include <vector>
namespace Echoion::Api
{
// Forward declarations
class IPluginInterface;
using PluginInterfacePtr = std::shared_ptr<IPluginInterface>;
// 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<void> initialize() = 0;
virtual Result<void> shutdown() = 0;
// Client operations
[[nodiscard]] virtual Result<std::vector<ClientInfo>>
getClients() = 0;
[[nodiscard]] virtual Result<std::optional<ClientInfo>>
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<std::optional<std::string>>
getClientIp(uint64_t /*clientId*/)
{
return std::optional<std::string>{};
}
// 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<std::optional<std::string>>
getClientAvatarPath(uint64_t /*clientId*/)
{
return std::optional<std::string>{};
}
// The client's myTeamSpeak avatar URL, if set. Modern clients store
// their avatar as a public HTTPS URL (CLIENT_MYTS_AVATAR, formatted
// "<version>,<url>") rather than the legacy file-transfer avatar.
// Returns the bare URL, or nullopt when unset/legacy.
[[nodiscard]] virtual Result<std::optional<std::string>>
getClientAvatarUrl(uint64_t /*clientId*/)
{
return std::optional<std::string>{};
}
// 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<std::optional<std::string>>
requestClientAvatar(uint64_t /*clientId*/,
const std::string& /*destDir*/)
{
return std::optional<std::string>{};
}
virtual Result<void> moveClient(uint64_t clientId,
uint64_t channelId) = 0;
virtual Result<void> kickClient(uint64_t clientId,
const std::string& reason) = 0;
// Channel operations
[[nodiscard]] virtual Result<std::vector<ChannelInfo>>
getChannels() const = 0;
[[nodiscard]] virtual Result<std::optional<ChannelInfo>>
getChannel(uint64_t channelId) const = 0;
// Messaging
virtual Result<void>
sendTextMessage(uint64_t targetId,
const std::string& message) = 0;
virtual Result<void>
sendChannelMessage(uint64_t channelId,
const std::string& message) = 0;
virtual Result<void>
sendServerMessage(const std::string& message) = 0;
// Audio
virtual Result<void>
sendAudioData(const std::span<const short>& data) = 0;
virtual Result<void>
setWhisperList(const std::vector<uint64_t>& clientIds) = 0;
// Server connection
// ServerConfig is defined in PluginTypes.hpp (self-contained)
virtual Result<void>
connectToServer(const ServerConfig& config) = 0;
virtual Result<void> disconnectFromServer() = 0;
[[nodiscard]] virtual bool isConnected() const = 0;
virtual Result<void> reconnect() = 0;
// Event subscription
virtual void
registerEventCallback(const EventCallback& callback) = 0;
virtual void
unregisterEventCallback(const EventCallback& callback) = 0;
};
} // namespace Echoion::Api