fix: prevent fallthrough in calc handler and require op to quit in channels
This commit is contained in:
parent
eee05fc169
commit
dc8083cd24
1 changed files with 7 additions and 2 deletions
9
calc.c
9
calc.c
|
|
@ -874,9 +874,9 @@ static void irc_handle(Session *s, const char *raw) {
|
|||
char *existing = db_get_raw(key);
|
||||
if (existing) {
|
||||
free(existing);
|
||||
snprintf(resp, sizeof resp, "calc already exists: %s", key);
|
||||
snprintf(resp, sizeof resp, "calc already exists (use calc! to overwrite)");
|
||||
irc_msg(s, reply_target, resp);
|
||||
log_stamp(); fprintf(stderr, CLR_MAGENTA "CALC %s from %s:" CLR_RESET " %s\n", reply_target, src_nick, resp);
|
||||
log_stamp(); fprintf(stderr, CLR_MAGENTA "CALC %s from %s:" CLR_RESET " blocked re-add of %s\n", reply_target, src_nick, key);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -908,6 +908,7 @@ static void irc_handle(Session *s, const char *raw) {
|
|||
}
|
||||
irc_msg(s, reply_target, resp);
|
||||
log_stamp(); fprintf(stderr, CLR_MAGENTA "CALC %s from %s:" CLR_RESET " %s\n", reply_target, src_nick, resp);
|
||||
return;
|
||||
}
|
||||
not_calc:
|
||||
if (strncmp(msg, "!ping", 5) == 0 && (msg[5] == ' ' || msg[5] == '\0')) {
|
||||
|
|
@ -919,6 +920,10 @@ static void irc_handle(Session *s, const char *raw) {
|
|||
}
|
||||
if ((strcmp(msg, "!quit") == 0 || strcmp(msg, "!die") == 0)) {
|
||||
const char *reply_target = (tgt[0] == '#') ? tgt : src_nick;
|
||||
if (tgt[0] == '#' && !chan_is_op(tgt, src_nick)) {
|
||||
irc_msg(s, reply_target, "You need op to shut me down");
|
||||
return;
|
||||
}
|
||||
irc_msg(s, reply_target, "pffffff, bye. :(");
|
||||
running = 0;
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue