From 9a47def27c2a1f9418a9bfad248eb3a86a90c8b0 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Mon, 23 Mar 2026 03:33:09 -0700 Subject: [PATCH] feat: add chat channel management (Join, Leave, GetChannelName) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JoinChannelByName(name, password) joins a chat channel. LeaveChannelByName(name) leaves a chat channel. GetChannelName(index) returns channel info (name, header, collapsed, channelNumber, count, active, category) — 7-field signature. Backed by existing joinChannel/leaveChannel/getChannelByIndex methods. Enables chat channel management addons and channel autojoining. --- src/addons/lua_engine.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/addons/lua_engine.cpp b/src/addons/lua_engine.cpp index 42dac796..0e5a08c2 100644 --- a/src/addons/lua_engine.cpp +++ b/src/addons/lua_engine.cpp @@ -5182,6 +5182,38 @@ void LuaEngine::registerCoreAPI() { if (gh) gh->requestPvpLog(); return 0; }}, + // --- Chat Channels --- + {"JoinChannelByName", [](lua_State* L) -> int { + auto* gh = getGameHandler(L); + const char* name = luaL_checkstring(L, 1); + const char* pw = luaL_optstring(L, 2, ""); + if (gh) gh->joinChannel(name, pw); + return 0; + }}, + {"LeaveChannelByName", [](lua_State* L) -> int { + auto* gh = getGameHandler(L); + const char* name = luaL_checkstring(L, 1); + if (gh) gh->leaveChannel(name); + return 0; + }}, + {"GetChannelName", [](lua_State* L) -> int { + auto* gh = getGameHandler(L); + int index = static_cast(luaL_checknumber(L, 1)); + if (!gh || index < 1) { lua_pushnil(L); return 1; } + std::string name = gh->getChannelByIndex(index - 1); + if (!name.empty()) { + lua_pushstring(L, name.c_str()); + lua_pushstring(L, ""); // header + lua_pushboolean(L, 0); // collapsed + lua_pushnumber(L, index); // channelNumber + lua_pushnumber(L, 0); // count + lua_pushboolean(L, 1); // active + lua_pushstring(L, "CHANNEL_CATEGORY_CUSTOM"); // category + return 7; + } + lua_pushnil(L); + return 1; + }}, // --- System Commands --- {"Logout", [](lua_State* L) -> int { auto* gh = getGameHandler(L);