diff options
-rw-r--r-- | config.h | 2 | ||||
-rw-r--r-- | general_network.c | 9 | ||||
-rw-r--r-- | protocols.c | 1 | ||||
-rw-r--r-- | protocols.h | 1 | ||||
-rw-r--r-- | protocols/inspircd2.c | 17 | ||||
-rw-r--r-- | protocols/inspircd2.h | 1 | ||||
-rw-r--r-- | psuedoclients/haxserv.c | 33 | ||||
-rw-r--r-- | psuedoclients/haxserv.h | 1 |
8 files changed, 61 insertions, 4 deletions
@@ -94,4 +94,6 @@ extern struct string HAXSERV_PREJOIN_CHANNELS[]; // = {STRING("#services"), ...} extern size_t HAXSERV_NUM_PREJOIN_CHANNELS; // = sizeof(HAXSERV_PREJOIN_CHANNELS) / sizeof(*HAXSERV_PREJOIN_CHANNELS); extern struct string HAXSERV_COMMAND_PREFIX; // = STRING("HaxServ: "); + +extern struct string HAXSERV_REQUIRED_OPER_TYPE; // = STRING("Admin"); #endif diff --git a/general_network.c b/general_network.c index 8493888..5a2bda2 100644 --- a/general_network.c +++ b/general_network.c @@ -555,6 +555,15 @@ int kick_channel(struct string from, struct string source, struct channel_info * } #endif +#ifdef USE_SERVER +#ifdef USE_HAXIRCD_PROTOCOL + protocols[HAXIRCD_PROTOCOL].propagate_kick_channel(from, source, channel, user, reason); +#endif +#ifdef USE_INSPIRCD2_PROTOCOL + protocols[INSPIRCD2_PROTOCOL].propagate_kick_channel(from, source, channel, user, reason); +#endif +#endif + return 1; } diff --git a/protocols.c b/protocols.c index b871429..afdbca5 100644 --- a/protocols.c +++ b/protocols.c @@ -52,6 +52,7 @@ struct protocol protocols[NUM_PROTOCOLS] = { .propagate_set_channel = inspircd2_protocol_propagate_set_channel, .propagate_join_channel = inspircd2_protocol_propagate_join_channel, .propagate_part_channel = inspircd2_protocol_propagate_part_channel, + .propagate_kick_channel = inspircd2_protocol_propagate_kick_channel, .propagate_privmsg = inspircd2_protocol_propagate_privmsg, .propagate_notice = inspircd2_protocol_propagate_notice, diff --git a/protocols.h b/protocols.h index 410bfb1..6d8a240 100644 --- a/protocols.h +++ b/protocols.h @@ -49,6 +49,7 @@ struct protocol { void (*propagate_set_channel)(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); void (*propagate_join_channel)(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users); void (*propagate_part_channel)(struct string from, struct channel_info *channel, struct user_info *user, struct string reason); + void (*propagate_kick_channel)(struct string from, struct string source, struct channel_info *channel, struct user_info *user, struct string reason); void (*propagate_privmsg)(struct string from, struct string source, struct string target, struct string msg); void (*propagate_notice)(struct string from, struct string source, struct string target, struct string msg); diff --git a/protocols/inspircd2.c b/protocols/inspircd2.c index e9b304a..5f546c7 100644 --- a/protocols/inspircd2.c +++ b/protocols/inspircd2.c @@ -669,6 +669,21 @@ void inspircd2_protocol_propagate_part_channel(struct string from, struct channe inspircd2_protocol_propagate(from, self, STRING("\n")); } +// [:source] KICK <channel> <user> [<reason>] +void inspircd2_protocol_propagate_kick_channel(struct string from, struct string source, struct channel_info *channel, struct user_info *user, struct string reason) { + struct server_info *self = get_table_index(server_list, SID); + + inspircd2_protocol_propagate(from, self, STRING(":")); + inspircd2_protocol_propagate(from, self, source); + inspircd2_protocol_propagate(from, self, STRING(" KICK ")); + inspircd2_protocol_propagate(from, self, channel->name); + inspircd2_protocol_propagate(from, self, STRING(" ")); + inspircd2_protocol_propagate(from, self, user->uid); + inspircd2_protocol_propagate(from, self, STRING(" :")); + inspircd2_protocol_propagate(from, self, reason); + inspircd2_protocol_propagate(from, self, STRING("\n")); +} + // [:source] PRIVMSG <target> <message> void inspircd2_protocol_propagate_privmsg(struct string from, struct string source, struct string target, struct string msg) { struct user_info *user = get_table_index(user_list, target); @@ -1415,7 +1430,7 @@ int inspircd2_protocol_handle_part(struct string source, size_t argc, struct str return 0; } -// [:source] KICK <channel> <user> [<reason>?] +// [:source] KICK <channel> <user> [<reason>] int inspircd2_protocol_handle_kick(struct string source, size_t argc, struct string *argv, size_t net, void *handle, struct server_config *config, char is_incoming) { if (argc < 2) { WRITES(2, STRING("[InspIRCd v2] Invalid KICK recieved! (Missing parameters)\r\n")); diff --git a/protocols/inspircd2.h b/protocols/inspircd2.h index bf3da7d..a7ac588 100644 --- a/protocols/inspircd2.h +++ b/protocols/inspircd2.h @@ -52,6 +52,7 @@ void inspircd2_protocol_propagate_kill_user(struct string from, struct string so void inspircd2_protocol_propagate_set_channel(struct string from, struct channel_info *channel, char is_new_channel, size_t user_count, struct user_info **users); void inspircd2_protocol_propagate_join_channel(struct string from, struct channel_info *channel, size_t user_count, struct user_info **users); void inspircd2_protocol_propagate_part_channel(struct string from, struct channel_info *channel, struct user_info *user, struct string reason); +void inspircd2_protocol_propagate_kick_channel(struct string from, struct string source, struct channel_info *channel, struct user_info *user, struct string reason); void inspircd2_protocol_propagate_privmsg(struct string from, struct string source, struct string target, struct string msg); void inspircd2_protocol_propagate_notice(struct string from, struct string source, struct string target, struct string msg); 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; |