From 80bd818208729b24262141b9068c427f9d8a097a Mon Sep 17 00:00:00 2001 From: Test_User Date: Fri, 14 Jun 2024 07:51:00 -0400 Subject: PRIVMSG/NOTICE support, improve kill_user --- general_network.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) (limited to 'general_network.c') diff --git a/general_network.c b/general_network.c index 6e80864..55423a1 100644 --- a/general_network.c +++ b/general_network.c @@ -352,7 +352,7 @@ void remove_user(struct string from, struct user_info *user, struct string reaso free(user); } -void kill_user(struct string from, struct string source, struct user_info *user, struct string reason) { +int kill_user(struct string from, struct string source, struct user_info *user, struct string reason) { #ifdef USE_SERVER #ifdef USE_HAXIRCD_PROTOCOL protocols[HAXIRCD_PROTOCOL].propagate_kill_user(from, source, user, reason); @@ -363,6 +363,8 @@ void kill_user(struct string from, struct string source, struct user_info *user, #endif remove_user(from, user, reason, 0); + + return 0; } int set_channel(struct string from, struct string name, size_t timestamp, size_t user_count, struct user_info **users) { @@ -514,3 +516,87 @@ void part_channel(struct string from, struct channel_info *channel, struct user_ free(channel); } } + +int kick_channel(struct string from, struct string source, struct channel_info *channel, struct user_info *user, struct string reason) { + return 1; +} + +int privmsg(struct string from, struct string sender, struct string target, struct string msg) { + do { + struct user_info *user = get_table_index(user_list, target); + if (user) + break; + struct server_info *server = get_table_index(server_list, target); + if (server) + break; + + char found = 0; + for (size_t i = 0; i < user_list.len; i++) { + user = user_list.array[i].ptr; + if (STRING_EQ(user->nick, target)) { + target = user->uid; + found = 1; + break; + } + } + if (found) + break; + + struct channel_info *channel = get_table_index(channel_list, target); + if (channel) + break; + + return 1; // Target not valid + } while (0); + +#ifdef USE_SERVER +#ifdef USE_HAXIRCD_PROTOCOL + protocols[HAXIRCD_PROTOCOL].propagate_privmsg(from, sender, target, msg); +#endif +#ifdef USE_INSPIRCD2_PROTOCOL + protocols[INSPIRCD2_PROTOCOL].propagate_privmsg(from, sender, target, msg); +#endif +#endif + + return 0; +} + +int notice(struct string from, struct string sender, struct string target, struct string msg) { + do { + struct user_info *user = get_table_index(user_list, target); + if (user) + break; + struct server_info *server = get_table_index(server_list, target); + if (server) + break; + + char found = 0; + for (size_t i = 0; i < user_list.len; i++) { + user = user_list.array[i].ptr; + if (STRING_EQ(user->nick, target)) { + target = user->uid; + found = 1; + break; + } + } + if (found) + break; + + struct channel_info *channel = get_table_index(channel_list, target); + if (channel) + break; + + return 1; // Target not valid + } while (0); + +#ifdef USE_SERVER +#ifdef USE_HAXIRCD_PROTOCOL + protocols[HAXIRCD_PROTOCOL].propagate_notice(from, sender, target, msg); +#endif +#ifdef USE_INSPIRCD2_PROTOCOL + protocols[INSPIRCD2_PROTOCOL].propagate_notice(from, sender, target, msg); +#endif +#endif + + return 0; +} -- cgit v1.2.3