|
|
@@ -180,7 +180,7 @@ parse_command(char const * cmd) |
|
|
|
{ |
|
|
|
size_t i = 0; |
|
|
|
static int vote_count; |
|
|
|
static int yes, no, undecided; |
|
|
|
static int yes, no; |
|
|
|
static int vote_on = 0; |
|
|
|
char * msgswp = NULL; |
|
|
|
/* size_t len = strlen(cmd); */ |
|
|
@@ -243,7 +243,7 @@ parse_command(char const * cmd) |
|
|
|
{ ircmsg(creds.channel, "%s: " IRC_YELLOW "%d" IRC_STOP, current_username, (rand() % atoi(arg)) + 1); } |
|
|
|
else if (strncmp(cmd, "poll", 4) == 0) |
|
|
|
{ |
|
|
|
yes = no = undecided = 0; |
|
|
|
yes = no = 0; |
|
|
|
vote_on = 1; |
|
|
|
vote_count = atoi(arg); |
|
|
|
if (!vote_count) |
|
|
@@ -253,24 +253,21 @@ parse_command(char const * cmd) |
|
|
|
} |
|
|
|
else if (strncmp(cmd, "vote", 4) == 0) |
|
|
|
{ |
|
|
|
fprintf(stderr, "y%d n%d u%d vote_count %d\n", yes, no, undecided, vote_count); |
|
|
|
fprintf(stderr, "y%d n%d vote_count %d\n", yes, no, vote_count); |
|
|
|
if (vote_on && vote_count) |
|
|
|
{ |
|
|
|
switch (*arg) |
|
|
|
{ |
|
|
|
case 'Y': case 'y': ERRMSG("YYY"); ++yes; break; |
|
|
|
case 'N': case 'n': ERRMSG("NNN"); ++no; break; |
|
|
|
case 'U': case 'u': ERRMSG("UUU"); ++undecided; break; |
|
|
|
default: ircmsg(creds.channel, "Unknown vote meaning: '%c'", *arg); goto stop; |
|
|
|
default: ircmsg(creds.channel, "Unknown vote meaning: '%c', use y/n", *arg); goto stop; |
|
|
|
} |
|
|
|
if (--vote_count) |
|
|
|
{ ircmsg(creds.channel, "Votes remaining: %d", vote_count); } |
|
|
|
else |
|
|
|
{ |
|
|
|
ircmsg(creds.channel, "poll results: %s", |
|
|
|
MAX(undecided,MAX(yes,no)) ? "UNDECIDED" : |
|
|
|
MAX(yes,no) ? "PASSED" : |
|
|
|
yes == no ? "REJECTED" : " UNDECIDED"); |
|
|
|
MAX(yes,no) ? "PASSED" : "REJECTED"); |
|
|
|
vote_on = 0; |
|
|
|
} |
|
|
|
} |
|
|
|