From e38e0d757573720dddcdc1ce6902d9ec005cf0c1 Mon Sep 17 00:00:00 2001 From: Emil Date: Thu, 24 Aug 2023 06:57:59 -0600 Subject: [PATCH] Fix godless heathen bugs --- src/irc.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/irc.c b/src/irc.c index eb393c1..850eb18 100644 --- a/src/irc.c +++ b/src/irc.c @@ -143,18 +143,16 @@ event_channel(irc_session_t * lsession, (void) origin; (void) message; (void) count; - /* parses the command */ - if (*message == PREFIX_COMMAND_CHAR) - { current_username = get_username(origin); } - if (!current_username || - message[1] == '\0') + /* fetches username and logs message */ + if (!(current_username = get_username(origin))) { return; } - /* Logs the message */ printf("<%s> %s\n", current_username, message); - /* Detects any re specified names */ + /* Detects any respecified names */ /* message += parse_secondary_username(message); */ - /* Parse any commands */ - parse_command(message+1); + /* Parse commands */ + if (*message == PREFIX_COMMAND_CHAR && + message[1] != '\0') + { parse_command(message+1); } free(current_username); current_username = NULL; } @@ -250,10 +248,12 @@ parse_command(char const * cmd) #endif /* 0 */ if (strncmp(cmd, "magic", 5) == 0) { ircmsg(creds.channel, "%s: " IRC_YELLOW "%d" IRC_STOP, current_username, (rand() % atoi(arg)) + 1); } + else if (strncmp(cmd, "echo", 3) == 0) + { ircmsg(creds.channel, "%s", arg); } else if (strncmp(cmd, "poll", 4) == 0) { yes = no = 0; - vote_count = atoi(arg) + 1; + vote_count = atoi(arg); if (!vote_count) { ircmsg(creds.channel, "!poll NUMBER_OF_VOTES What your voting on ..."); } else @@ -271,7 +271,7 @@ parse_command(char const * cmd) default: ircmsg(creds.channel, "Unknown: '%c', use y/n", *arg); goto stop; } if (--vote_count) - { ircmsg(creds.channel, "Votes remaining: %d", vote_count - 1); } + { ircmsg(creds.channel, "Votes remaining: %d", vote_count); } else { ircmsg(creds.channel, "poll: %s", MAX(yes,no) ? "PASSED" : "REJECTED"); } }