aboutsummaryrefslogtreecommitdiff
path: root/server_network.c
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2024-05-31 18:51:08 -0400
committerTest_User <hax@andrewyu.org>2024-05-31 18:51:08 -0400
commit3bacc8fa14cc617c7298a74e44cc27d4cc54d2c1 (patch)
treee822491c44cea8b1f7cea6b4eda3695755c83e92 /server_network.c
parent462f11de02e2cde6c4c196acf9c3dfa8c6d75f3d (diff)
downloadcoupserv-3bacc8fa14cc617c7298a74e44cc27d4cc54d2c1.tar.gz
coupserv-3bacc8fa14cc617c7298a74e44cc27d4cc54d2c1.zip
Don't respond to channels that it's not in
Diffstat (limited to 'server_network.c')
-rw-r--r--server_network.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/server_network.c b/server_network.c
index d75b494..6d63c5f 100644
--- a/server_network.c
+++ b/server_network.c
@@ -700,6 +700,13 @@ int privmsg_handler(struct string sender, uint64_t argc, struct string *argv) {
if (argv[1].len < command_prefix.len || memcmp(argv[1].data, command_prefix.data, command_prefix.len) != 0)
return 0;
+ struct channel_info *channel_info = get_table_index(channel_list, argv[0]);
+ if (!channel_info)
+ return 0;
+
+ if (!has_table_index(channel_info->user_list, STRING("1HC000000")))
+ return 0;
+
offset = command_prefix.len;
} else if (STRING_EQ(argv[0], STRING("1HC000000"))) {
offset = 0;
@@ -940,7 +947,23 @@ int initservernetwork(void) {
if (add_local_client(STRING("1HC000000"), nick, hostmask, nick, nick, current_time, 0) != 0)
return 1;
+ struct user_info *user_info = get_table_index(user_list, STRING("1HC000000"));
+
for (uint64_t i = 0; i < num_prejoin_channels; i++) {
+ struct channel_info *channel;
+ channel = malloc(sizeof(*channel));
+ if (!channel)
+ return 1;
+ *channel = (struct channel_info){
+ .ts = (uint64_t)current_time,
+ .topic = {.data = malloc(0), .len = 0},
+ .topic_ts = 0,
+ .modes = {.array = malloc(0), .len = 0},
+ .user_list = {.array = malloc(0), .len = 0},
+ .metadata = {.array = malloc(0), .len = 0},
+ };
+ set_table_index(&channel_list, prejoin_channels[i], channel);
+ set_table_index(&(channel->user_list), STRING("1HC000000"), user_info);
SEND(STRING("FJOIN "));
SEND(prejoin_channels[i]);
SEND(STRING(" "));