Fix godless heathen bugs

This commit is contained in:
Emil 2023-08-24 06:57:59 -06:00
parent 4b2a66d6e2
commit e38e0d7575
No known key found for this signature in database
GPG Key ID: 5432DB986FDBCF8A

View File

@ -143,18 +143,16 @@ event_channel(irc_session_t * lsession,
(void) origin; (void) origin;
(void) message; (void) message;
(void) count; (void) count;
/* parses the command */ /* fetches username and logs message */
if (*message == PREFIX_COMMAND_CHAR) if (!(current_username = get_username(origin)))
{ current_username = get_username(origin); }
if (!current_username ||
message[1] == '\0')
{ return; } { return; }
/* Logs the message */
printf("<%s> %s\n", current_username, message); printf("<%s> %s\n", current_username, message);
/* Detects any re specified names */ /* Detects any respecified names */
/* message += parse_secondary_username(message); */ /* message += parse_secondary_username(message); */
/* Parse any commands */ /* Parse commands */
parse_command(message+1); if (*message == PREFIX_COMMAND_CHAR &&
message[1] != '\0')
{ parse_command(message+1); }
free(current_username); free(current_username);
current_username = NULL; current_username = NULL;
} }
@ -250,10 +248,12 @@ parse_command(char const * cmd)
#endif /* 0 */ #endif /* 0 */
if (strncmp(cmd, "magic", 5) == 0) if (strncmp(cmd, "magic", 5) == 0)
{ ircmsg(creds.channel, "%s: " IRC_YELLOW "%d" IRC_STOP, current_username, (rand() % atoi(arg)) + 1); } { 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) else if (strncmp(cmd, "poll", 4) == 0)
{ {
yes = no = 0; yes = no = 0;
vote_count = atoi(arg) + 1; vote_count = atoi(arg);
if (!vote_count) if (!vote_count)
{ ircmsg(creds.channel, "!poll NUMBER_OF_VOTES What your voting on ..."); } { ircmsg(creds.channel, "!poll NUMBER_OF_VOTES What your voting on ..."); }
else else
@ -271,7 +271,7 @@ parse_command(char const * cmd)
default: ircmsg(creds.channel, "Unknown: '%c', use y/n", *arg); goto stop; default: ircmsg(creds.channel, "Unknown: '%c', use y/n", *arg); goto stop;
} }
if (--vote_count) if (--vote_count)
{ ircmsg(creds.channel, "Votes remaining: %d", vote_count - 1); } { ircmsg(creds.channel, "Votes remaining: %d", vote_count); }
else else
{ ircmsg(creds.channel, "poll: %s", MAX(yes,no) ? "PASSED" : "REJECTED"); } { ircmsg(creds.channel, "poll: %s", MAX(yes,no) ? "PASSED" : "REJECTED"); }
} }