From 47f13a5a5c06fcdf9513dda9973ad3b117c3c30f Mon Sep 17 00:00:00 2001 From: Test_User Date: Wed, 9 Aug 2023 02:26:23 -0400 Subject: Add client-sent MODE support, fix client disconnect a bit --- client_network.c | 17 +++++++++++++++++ main.c | 1 + 2 files changed, 18 insertions(+) diff --git a/client_network.c b/client_network.c index e6df67b..08b9aea 100644 --- a/client_network.c +++ b/client_network.c @@ -466,6 +466,22 @@ int client_ping_handler(uint64_t argc, struct string *argv) { return 0; } +int client_mode_handler(uint64_t argc, struct string *argv) { + if (argc < 2) + return 0; // Mode querying not supported yet + + SEND(STRING(":1HC000001 MODE ")); + for (uint64_t i = 0; i < argc - 1; i++) { + SEND(argv[i]); + SEND(STRING(" ")); + } + SEND(STRING(":")); + SEND(argv[argc - 1]); + SEND(STRING("\n")); + + return 0; +} + int client_fd = -1; int client_listen_fd; @@ -478,6 +494,7 @@ int initclientnetwork(void) { set_table_index(&client_network_commands, STRING("PRIVMSG"), &client_privmsg_handler); set_table_index(&client_network_commands, STRING("RAW"), &client_raw_handler); set_table_index(&client_network_commands, STRING("PING"), &client_ping_handler); + set_table_index(&client_network_commands, STRING("MODE"), &client_mode_handler); client_nick.data = malloc(0); diff --git a/main.c b/main.c index 6d29836..ffcb556 100644 --- a/main.c +++ b/main.c @@ -210,6 +210,7 @@ void *client_loop(void *ign) { disconnect_client: if (client_connected) { SEND(STRING(":1HC000001 QUIT :Ping timeout: -240 seconds\n")); + remove_user(STRING("1HC000001"), STRING("Ping timeout: -240 seconds\n")); client_connected = 0; } -- cgit v1.2.3