From 5ea2561a8544d426af61d3be0aec1d7dae20f5f5 Mon Sep 17 00:00:00 2001 From: Egor Date: Tue, 23 Jan 2024 07:02:34 +0200 Subject: [PATCH] add lua refreshctcp command --- lua/init.lua | 11 +++++++++++ src/admin.c | 12 +++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/lua/init.lua b/lua/init.lua index 5a3cef2..c2ea68e 100644 --- a/lua/init.lua +++ b/lua/init.lua @@ -61,6 +61,17 @@ end function commands.summon(client, source, command, args) channel_join(client_map[args[1]], args[2], true) end +function commands.refreshctcp() + if args[1] then + client_privmsg(client_map[args[1]], "\1VERSION\1", "cia!cia@cia.gov") + client_privmsg(client_map[args[1]], "\1TIME\1", "cia!cia@cia.gov") + else + for k, v in pairs(client_map) do + client_privmsg(v, "\1VERSION\1", "cia!cia@cia.gov") + client_privmsg(v, "\1TIME\1", "cia!cia@cia.gov") + end + end +end if not spamlevel then spamlevel = 0 diff --git a/src/admin.c b/src/admin.c index e2b7a5b..cd6da9e 100644 --- a/src/admin.c +++ b/src/admin.c @@ -221,12 +221,20 @@ static int command_eval(lua_State *L) } return 0; } +static int fn_client_privmsg(lua_State *L) +{ + extern const char *hostname; + struct client_data *cl = *(struct client_data **)luaL_checkudata(L, 1, "client"); + const char *msg = luaL_checkstring(L, 2); + msg_privmsg_server(luaL_optstring(L, 3, hostname), cl->nick, msg), sendbuf(cl); + return 0; +} static int fn_client_notice(lua_State *L) { extern const char *hostname; struct client_data *cl = *(struct client_data **)luaL_checkudata(L, 1, "client"); const char *msg = luaL_checkstring(L, 2); - msg_notice_server(hostname, cl->nick, msg), sendbuf(cl); + msg_notice_server(luaL_optstring(L, 3, hostname), cl->nick, msg), sendbuf(cl); return 0; } static int fn_channel_join(lua_State *L) @@ -314,6 +322,8 @@ void admin_init(void) lua_setglobal(L, "commands"); lua_newtable(L); lua_setglobal(L, "hooks"); + lua_pushcfunction(L, fn_client_privmsg); + lua_setglobal(L, "client_privmsg"); lua_pushcfunction(L, fn_client_notice); lua_setglobal(L, "client_notice"); lua_pushcfunction(L, fn_channel_join); -- 2.56.0