summaryrefslogtreecommitdiff
path: root/commands.c
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2023-05-05 03:37:09 -0400
committerTest_User <hax@andrewyu.org>2023-05-05 03:37:09 -0400
commit9343cffa8c032d5b44fce89af7fc5d8709acd9aa (patch)
tree6498e35723a0bc72da07cebddf41ffca88cc0171 /commands.c
parent658cd5f4c8f2d18b263d5bcb992b3aa995470312 (diff)
downloadcoupserv-9343cffa8c032d5b44fce89af7fc5d8709acd9aa.tar.gz
coupserv-9343cffa8c032d5b44fce89af7fc5d8709acd9aa.zip
Add more commands, remove trailing ; from macro
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/commands.c b/commands.c
index 578ea47..a99e36e 100644
--- a/commands.c
+++ b/commands.c
@@ -37,6 +37,26 @@
struct table user_commands = {0};
+int help_command(struct string sender, struct string original_message, struct string to, uint64_t argc, struct string *argv) {
+ for (uint64_t i = 0; i < user_commands.len; i++) {
+ SEND(STRING(":1HC000000 PRIVMSG "));
+ SEND(to);
+ SEND(STRING(" :" "\x03" "04"));
+ SEND(user_commands.array[i].name);
+ SEND(STRING("\x0F" " "));
+ struct command_def *def = user_commands.array[i].ptr;
+ SEND(def->summary);
+ }
+
+ return 0;
+}
+static struct command_def help_command_def = {
+ .func = help_command,
+ .privs = {0},
+ .local_only = 0,
+ .summary = STRING("Shows a list of commands, or, when I write it up, help about a specific command\n"),
+};
+
int raw_command(struct string sender, struct string original_message, struct string to, uint64_t argc, struct string *argv) {
if (argv[0].len < original_message.len) {
original_message.data += argv[0].len + 1;
@@ -51,6 +71,7 @@ static struct command_def raw_command_def = {
.func = raw_command,
.privs = STRING("Admin"),
.local_only = 0,
+ .summary = STRING("Sends a raw message to the server\n"),
};
static struct pref_type_suff {
@@ -63,6 +84,12 @@ static struct pref_type_suff {
{STRING(":1HC000000 PRIVMSG "), 0, STRING(" :\x1b(0\n")},
{STRING(":1HC000000 KILL "), 1, STRING(" :Ejected (1 Impostor remains)\n")},
{STRING(":1HC000000 KILL "), 1, STRING(" :Ejected, and the crewmates have won.\n")},
+}, cr_strings[] = {
+ {STRING(":1HC000000 PRIVMSG "), 0, STRING(" :You are now a cruxian toxicpod, kill the sharded crewmates.\n")},
+ {STRING(":1HC000000 PRIVMSG "), 0, STRING(" :You are now a cruxian omura, kill the sharded crewmates.\n")},
+ {STRING(":1HC000000 PRIVMSG "), 0, STRING(" :You are now a cruxian oct, but you ran out of reactors.\n")},
+ {STRING(":1HC000000 KILL "), 1, STRING(" :Eliminated (You became a cruxian eclipse, but were drawn to my bait reactor)\n")},
+ {STRING(":1HC000000 PRIVMSG "), 0, STRING(" :You attempted to change into a cruxian navanax, but were caught in the act.\n")},
};
int sus_command(struct string sender, struct string original_message, struct string to, uint64_t argc, struct string *argv) {
@@ -81,13 +108,37 @@ static struct command_def sus_command_def = {
.func = sus_command,
.privs = {0},
.local_only = 0,
+ .summary = STRING("You seems a bit sus today\n"),
+};
+
+int cr_command(struct string sender, struct string original_message, struct string to, uint64_t argc, struct string *argv) {
+ uint64_t index = random() % (sizeof(cr_strings)/sizeof(cr_strings[0]));
+
+ SEND(cr_strings[index].pref);
+ if (cr_strings[index].type == 0)
+ SEND(to);
+ else
+ SEND(sender);
+ SEND(cr_strings[index].suff);
+
+ return 0;
+}
+static struct command_def cr_command_def = {
+ .func = cr_command,
+ .privs = {0},
+ .local_only = 0,
+ .summary = STRING("Join the crux side\n"),
};
int init_user_commands(void) {
+ srandom(time(NULL));
+
user_commands.array = malloc(0);
set_table_index(&user_commands, STRING(":"), &raw_command_def);
set_table_index(&user_commands, STRING("sus"), &sus_command_def);
+ set_table_index(&user_commands, STRING("cr"), &cr_command_def);
+ set_table_index(&user_commands, STRING("help"), &help_command_def);
return 0;
}