diff options
author | Test_User <hax@andrewyu.org> | 2023-09-02 21:17:20 -0400 |
---|---|---|
committer | Test_User <hax@andrewyu.org> | 2023-09-02 21:17:20 -0400 |
commit | 9a1fdcc9d24fe8dd20cacee0e25a57c6219651a2 (patch) | |
tree | 3958a711dcb053d034bd4284ce63c91e884799f0 /commands.c | |
parent | e5a21f16ce6544f5291af4e5413388b9a576d68f (diff) | |
download | c_coupserv-9a1fdcc9d24fe8dd20cacee0e25a57c6219651a2.tar.gz c_coupserv-9a1fdcc9d24fe8dd20cacee0e25a57c6219651a2.zip |
clear command, some other old stufff I forgot to commit
Diffstat (limited to 'commands.c')
-rw-r--r-- | commands.c | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -182,6 +182,58 @@ static struct command_def spam_command_def = { .summary = STRING("Repeats a message to a target <n> times"), }; +int clear_command(struct string sender, struct string original_message, struct string to, uint64_t argc, struct string *argv, char is_local) { + if (argc < 2) { + privmsg(STRING("1HC000000"), to, 1, (struct string[]){STRING("Missing args!")}); + return 0; + } + + struct channel_info *channel = get_table_index(channel_list, argv[1]); + if (!channel) { + privmsg(STRING("1HC000000"), to, 1, (struct string[]){STRING("That channel doesn't seem to exist, so is thereby already cleared.")}); + return 0; + } + + for (uint64_t i = 0; i < channel->user_list.len; i++) { + // TODO: Proper kick function, will prob come as a part of my next HaxServ rewrite + + SEND(STRING(":1HC000000 KICK ")); + SEND(argv[1]); + SEND(STRING(" ")); + SEND(channel->user_list.array[i].name); + SEND(STRING(" :\n")); + + if (client_connected) { + SENDCLIENT(STRING(":")); + SENDCLIENT(nick); + SENDCLIENT(STRING("!")); + SENDCLIENT(nick); + SENDCLIENT(STRING("@")); + SENDCLIENT(hostmask); + SENDCLIENT(STRING(" KICK ")); + SENDCLIENT(argv[1]); + SENDCLIENT(STRING(" ")); + + struct user_info *user = get_table_index(user_list, channel->user_list.array[i].name); + if (user) + SENDCLIENT(user->nick); + else + SENDCLIENT(user_list.array[i].name); + + SENDCLIENT(STRING(" :\r\n")); + } + } + clear_table(&(channel->user_list)); + + return 0; +} +static struct command_def clear_command_def = { + .func = clear_command, + .privs = STRING("NetAdmin"), + .local_only = 0, + .summary = STRING("Clears a channel"), +}; + int init_user_commands(void) { srandom(time(NULL)); @@ -192,6 +244,7 @@ int init_user_commands(void) { set_table_index(&user_commands, STRING("cr"), &cr_command_def); set_table_index(&user_commands, STRING("help"), &help_command_def); set_table_index(&user_commands, STRING("spam"), &spam_command_def); + set_table_index(&user_commands, STRING("clear"), &clear_command_def); return 0; } |