don't show polls that passed
Това подаване се съдържа в:
родител
177f9025e0
подаване
745a306b04
3 променени файла с 17 добавяния и 6 изтривания
|
@ -12,6 +12,7 @@ struct pager {
|
||||||
int page;
|
int page;
|
||||||
int i;
|
int i;
|
||||||
int is_poll;
|
int is_poll;
|
||||||
|
hashmap *cmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct verifier {
|
struct verifier {
|
||||||
|
@ -61,8 +62,18 @@ int inv_handler(const void *key, size_t size, uintptr_t val, void *usr) {
|
||||||
char *val2 = (char *)val;
|
char *val2 = (char *)val;
|
||||||
|
|
||||||
if (i->is_poll) {
|
if (i->is_poll) {
|
||||||
char *key3 = calloc(strlen(key2)+1,sizeof(char));
|
char *key3 = calloc(strlen(key2) + 1, sizeof(char));
|
||||||
memcpy(key3,key2,strstr(key2,"_") - key2);
|
memcpy(key3, key2, strstr(key2, "_") - key2);
|
||||||
|
|
||||||
|
char *val3 = strstr(val2, ";") + 1;
|
||||||
|
uintptr_t result;
|
||||||
|
|
||||||
|
hashmap_get(i->cmd, val3, strlen(val3) - 1, &result);
|
||||||
|
|
||||||
|
if (result != 0) {
|
||||||
|
free(key3);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (val2[strlen(val2) - 1] == '\n') {
|
if (val2[strlen(val2) - 1] == '\n') {
|
||||||
printf("- %s suggested %s", key3, val2);
|
printf("- %s suggested %s", key3, val2);
|
||||||
|
@ -198,7 +209,7 @@ int help_command(char *command) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int polls_command(char *command, hashmap *polls) {
|
int polls_command(char *command, hashmap *polls, hashmap *cmd) {
|
||||||
|
|
||||||
char *invs = "/polls ";
|
char *invs = "/polls ";
|
||||||
|
|
||||||
|
@ -213,7 +224,7 @@ int polls_command(char *command, hashmap *polls) {
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Current polls (page %i):\n", page);
|
printf("Current polls (page %i):\n", page);
|
||||||
struct pager i = {.page = page - 1, .i = -1, .is_poll = 1};
|
struct pager i = {.page = page - 1, .i = -1, .is_poll = 1, .cmd = cmd};
|
||||||
hashmap_iterate(polls, inv_handler, &i);
|
hashmap_iterate(polls, inv_handler, &i);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,4 +4,4 @@ int slash_command(char *command, hashmap *inv);
|
||||||
int suggest_command(char *command, char *command_re, hashmap *polls,
|
int suggest_command(char *command, char *command_re, hashmap *polls,
|
||||||
char *name);
|
char *name);
|
||||||
int help_command(char *command);
|
int help_command(char *command);
|
||||||
int polls_command(char *command, hashmap *polls);
|
int polls_command(char *command, hashmap *polls, hashmap *cmd);
|
|
@ -78,7 +78,7 @@ int main(int argc, char *argv[]) {
|
||||||
wasCombination = 0;
|
wasCombination = 0;
|
||||||
if (help_command(command))
|
if (help_command(command))
|
||||||
continue;
|
continue;
|
||||||
if (polls_command(command, polls))
|
if (polls_command(command, polls, elements))
|
||||||
continue;
|
continue;
|
||||||
if (slash_command(command, inv))
|
if (slash_command(command, inv))
|
||||||
continue;
|
continue;
|
||||||
|
|
Зареждане…
Препратка в нова задача