making WEB

Signed-off-by: faumaray <faumaray@gmail.com>
This commit is contained in:
faumaray committed 2026-07-11 00:45:17 +03:00
1 parent d146f11f02
commit 5c036d91fb
72 files changed
+5875 -1243

No files matched your search

+44 -1
View File
@@ -6,16 +6,18 @@
#include <Types.hpp>
#include <Void/Async/ThreadPool.hpp>
#include <atomic>
#include <memory>
#include <chrono>
#include <condition_variable>
#include <functional>
#include <future>
#include <map>
#include <memory>
#include <mutex>
#include <optional>
#include <queue>
#include <string>
#include <thread>
#include <unordered_map>
#include <vector>
namespace Echoion::Core
@@ -148,6 +150,47 @@ namespace Echoion::Core
class HelpCommand;
void registerHelpCommand();
// Internal page-navigator command (!page/!next/!prev), defined in
// the .cpp so it can reach the paged-reply cache below.
class PageNavCommand;
void registerPageCommands();
// Resolve the language a client should be answered in: their stored
// per-user preference (kv_store "lang:<uid>") if any, else the
// configured bot default, else English.
[[nodiscard]] I18n::Language resolveLanguage(
uint64_t clientId,
const std::weak_ptr<MusicManager>& musicManager) const;
// --- Oversized-reply pagination -------------------------------
// Long replies (from any command except help / the navigator) are
// kept to a single message: page 1 is sent with a footer and the
// remaining pages are cached here for !page/!next/!prev.
struct PagedReply {
std::vector<std::string> pages;
std::size_t current = 0;
std::chrono::steady_clock::time_point ts{};
};
mutable std::mutex pagedMutex_;
std::unordered_map<uint64_t, PagedReply> pagedReplies_;
static constexpr std::size_t kPageLimitBytes = 700;
static constexpr std::chrono::minutes kPageTtl{10};
// Split `text` into pages, cache pages 2..N for `clientId`, and
// return page 1 (with a footer when there is more than one page).
// Replies that already fit one message pass through unchanged.
std::string paginateReply(uint64_t clientId, std::string text,
I18n::Language lang);
// Re-render a cached page for `clientId`. When `absolute` is set
// the current page jumps to it (1-based, clamped); otherwise it
// moves by `delta`. Returns std::nullopt when nothing is cached /
// expired.
std::optional<std::string>
renderCachedPage(uint64_t clientId,
std::optional<long> absolute, int delta,
I18n::Language lang);
std::string prefix_ = "!";
// Non-owning service registry threaded into each CommandContext