]> PatchyGit - patchyircd.git/commitdiff
add lua refreshctcp command
authorEgor <egor@patchysicp.xyz>
Tue, 23 Jan 2024 05:02:34 +0000 (07:02 +0200)
committerEgor <egor@patchysicp.xyz>
Tue, 23 Jan 2024 05:02:34 +0000 (07:02 +0200)
lua/init.lua
src/admin.c

index 5a3cef2..c2ea68e 100644 (file)
@@ -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
index e2b7a5b..cd6da9e 100644 (file)
@@ -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);