From 55c968cbe14ab1867cdd25edca90fcb8553d853a Mon Sep 17 00:00:00 2001 From: Test_User Date: Fri, 14 Jun 2024 20:24:27 -0400 Subject: KICK support, more HaxServ stuff --- psuedoclients/haxserv.c | 33 ++++++++++++++++++++++++++++++--- psuedoclients/haxserv.h | 1 + 2 files changed, 31 insertions(+), 3 deletions(-) (limited to 'psuedoclients') diff --git a/psuedoclients/haxserv.c b/psuedoclients/haxserv.c index 88695f3..dd6562c 100644 --- a/psuedoclients/haxserv.c +++ b/psuedoclients/haxserv.c @@ -70,6 +70,9 @@ int haxserv_psuedoclient_init(void) { return 1; if (set_table_index(&haxserv_psuedoclient_commands, STRING("CR"), &haxserv_psuedoclient_cr_command_def) != 0) return 1; + haxserv_psuedoclient_clear_command_def.privs = HAXSERV_REQUIRED_OPER_TYPE; + if (set_table_index(&haxserv_psuedoclient_commands, STRING("CLEAR"), &haxserv_psuedoclient_clear_command_def) != 0) + return 1; return 0; } @@ -202,7 +205,6 @@ int haxserv_psuedoclient_help_command(struct string from, struct string sender, } struct command_def haxserv_psuedoclient_help_command_def = { .func = haxserv_psuedoclient_help_command, - .privs = {0}, .summary = STRING("Shows a list of commands."), .name = STRING("help"), }; @@ -241,7 +243,6 @@ int haxserv_psuedoclient_sus_command(struct string from, struct string sender, s } struct command_def haxserv_psuedoclient_sus_command_def = { .func = haxserv_psuedoclient_sus_command, - .privs = {0}, .summary = STRING("You seem a bit sus today."), .name = STRING("sus"), }; @@ -263,7 +264,33 @@ int haxserv_psuedoclient_cr_command(struct string from, struct string sender, st } struct command_def haxserv_psuedoclient_cr_command_def = { .func = haxserv_psuedoclient_cr_command, - .privs = {0}, .summary = STRING("Join the crux side."), .name = STRING("cr"), }; + +int haxserv_psuedoclient_clear_command(struct string from, struct string sender, struct string original_message, struct string respond_to, size_t argc, struct string *argv) { + if (argc < 1) { + notice(SID, HAXSERV_UID, respond_to, STRING("Missing args!")); + return 0; + } + + struct channel_info *channel = get_table_index(channel_list, argv[0]); + if (!channel) { + notice(SID, HAXSERV_UID, respond_to, STRING("That channel doesn't seem to exist, so is thereby already cleared.")); + return 0; + } + + size_t i = 0; + while (channel->user_list.len > i) { + if (kick_channel(SID, HAXSERV_UID, channel, channel->user_list.array[i].ptr, STRING("")) != 0) { + i++; + } + } + + return 0; +} +struct command_def haxserv_psuedoclient_clear_command_def = { + .func = haxserv_psuedoclient_clear_command, + .summary = STRING("Clears a channel."), + .name = STRING("clear"), +}; diff --git a/psuedoclients/haxserv.h b/psuedoclients/haxserv.h index dff42b4..d94df4f 100644 --- a/psuedoclients/haxserv.h +++ b/psuedoclients/haxserv.h @@ -48,3 +48,4 @@ extern struct table haxserv_psuedoclient_commands; extern struct command_def haxserv_psuedoclient_help_command_def; extern struct command_def haxserv_psuedoclient_sus_command_def; extern struct command_def haxserv_psuedoclient_cr_command_def; +extern struct command_def haxserv_psuedoclient_clear_command_def; -- cgit v1.2.3