Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-11 16:30:05 +03:00
1 parent cf48f2f350
commit 4a92d09e63
7 files changed
+571 -64

No files matched your search

+70 -4
View File
@@ -6,7 +6,8 @@
// TS3 Client Plugin SDK. The bot therefore runs as a plain daemon — no
// TeamSpeak client, no Weston/RDP, no plugin directory.
#include "echoion/plugin/CoreLoader.hpp"
#include "echoion/host/CoreLoader.hpp"
#include "echoion/protocol/Identity.hpp"
#include "echoion/standalone/StandaloneClientInterface.hpp"
#include <CoreInterface.hpp>
@@ -22,7 +23,9 @@
#include <iostream>
#include <memory>
#include <mutex>
#include <optional>
#include <string>
#include <string_view>
namespace
{
@@ -80,6 +83,62 @@ namespace
}
return "./Echoion.ts";
}
int importIdentity(int argc, char** argv,
const std::filesystem::path& defaultIdentityPath)
{
std::optional<std::filesystem::path> source;
auto destination = defaultIdentityPath;
bool force = false;
bool importRequested = false;
for (int i = 1; i < argc; ++i) {
const std::string_view argument{argv[i]};
if (argument == "--help") {
std::cout
<< "Usage: echoiond [--config PATH]\n"
" echoiond --import-identity EXPORT.ini "
"[--identity-path PATH] [--force]\n";
return 0;
}
if (argument == "--import-identity") {
importRequested = true;
if (i + 1 < argc &&
!std::string_view{argv[i + 1]}.starts_with("--")) {
source = argv[++i];
}
} else if (argument == "--identity-path" && i + 1 < argc) {
destination = argv[++i];
} else if (argument == "--force") {
force = true;
}
}
if (!importRequested) {
return -1;
}
if (!source) {
std::cerr << "--import-identity requires an exported INI path.\n";
return 2;
}
try {
if (std::filesystem::exists(destination) && !force) {
std::cerr << "Identity already exists at " << destination
<< "; pass --force to replace it.\n";
return 2;
}
const auto identity =
Echoion::Protocol::Identity::importTeamSpeakIni(source->string());
if (const auto parent = destination.parent_path(); !parent.empty()) {
std::filesystem::create_directories(parent);
}
identity.save(destination.string());
std::cout << "Imported TeamSpeak identity " << identity.uid()
<< " to " << destination << '\n';
return 0;
} catch (const std::exception& error) {
std::cerr << "Identity import failed: " << error.what() << '\n';
return 2;
}
}
} // namespace
int main(int argc, char** argv)
@@ -92,6 +151,12 @@ int main(int argc, char** argv)
std::filesystem::path cfgDir = configDir();
std::filesystem::path cfgPath = cfgDir / "config.json";
const auto identityPath = std::filesystem::path(envOr(
"ECHOION_IDENTITY_PATH", (cfgDir / "identity.txt").string()));
if (const auto importResult = importIdentity(argc, argv, identityPath);
importResult >= 0) {
return importResult;
}
// Optional CLI: --config <path>
for (int i = 1; i + 1 < argc; ++i) {
if (std::string(argv[i]) == "--config") {
@@ -100,8 +165,8 @@ int main(int argc, char** argv)
}
Echoion::Standalone::StandaloneSettings settings;
settings.identityPath =
envOr("ECHOION_IDENTITY_PATH", (cfgDir / "identity.txt").string());
settings.identityPath = identityPath.string();
settings.avatarCachePath = (cfgDir / "avatars").string();
settings.securityLevel = envInt("ECHOION_SECURITY_LEVEL", 8);
settings.opusBitrate = envInt("ECHOION_OPUS_BITRATE", 96000);
@@ -113,7 +178,7 @@ int main(int argc, char** argv)
return 1;
}
Echoion::Plugin::CoreLoader loader;
Echoion::Host::CoreLoader loader;
loader.setConfigPath(cfgPath);
auto corePathResolved = corePath();
@@ -137,6 +202,7 @@ int main(int argc, char** argv)
loader.setHotReloadCallback([&loader, interface] {
if (auto c = loader.getCore()) {
c->setPluginInterface(interface);
interface->unregisterEventCallback({});
interface->registerEventCallback(
[c](const Echoion::Api::PluginEvent& ev) {
std::ignore = c->onPluginEvent(ev);