int whois_access(struct userrec *user, struct userrec *whois_user) { if (user == whois_user) return 1; struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0 }, whois = { FR_GLOBAL | FR_CHAN, 0, 0, 0}; get_user_flagrec(user, &fr, NULL); get_user_flagrec(whois_user, &whois, NULL); /* Don't show hub bots from leaf bots. */ if (!conf.bot->hub && whois_user->bot && bot_hublevel(whois_user) < 999) return 0; if ( (isowner(whois_user->handle) && !isowner(user->handle)) || (glob_admin(whois) && !glob_admin(fr)) || (glob_owner(whois) && !glob_owner(fr)) || (glob_master(whois) && !glob_master(fr)) || (glob_bot(whois) && !glob_master(fr)) ) return 0; return 1; }
static int msg_release(char *nick, char *host, struct userrec *u, char *par) { char *pass = NULL; if (match_my_nick(nick)) return BIND_RET_BREAK; if (u && u->bot) return BIND_RET_BREAK; pass = newsplit(&par); if (u && u_pass_match(u, pass) && !u_pass_match(u, "-")) { struct flag_record fr = {FR_GLOBAL, 0, 0, 0 }; get_user_flagrec(u, &fr, NULL); if (glob_master(fr)) { putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! RELEASE"), nick, host, u->handle); egg_timeval_t howlong; howlong.sec = 5; howlong.usec = 0; timer_create(&howlong, "Release jupenick", (Function) release_nick); // release_nick(); } else putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! failed RELEASE (User it not +m)"), nick, host, u->handle); } else putlog(LOG_CMDS, "*", STR("(%s!%s) !%s! failed RELEASE"), nick, host, u ? u->handle : "*"); return BIND_RET_BREAK; }
static void got_invite(struct chanset_t *chan, char *nick, char *from, char *who, char *ch, struct userrec *u) { char s[UHOSTLEN]; simple_sprintf(s, "%s!%s", nick, from); newinvite(chan, who, s); check_tcl_mode(nick, from, u, chan->dname, "+I", who); if (!(chan = modebind_refresh(ch, from, &user, NULL, NULL))) return; if (channel_pending(chan) || HALFOP_CANTDOMODE('I')) return; if (!match_my_nick(nick)) { if (nick[0] && channel_nouserinvites(chan) && !glob_bot(user) && !glob_master(user) && !chan_master(user)) { add_mode(chan, '-', 'I', who); return; } if ((!nick[0]) && (bounce_modes)) reversing = 1; } if (reversing || (bounce_invites && (!nick[0]) && (!u_equals_mask(global_invites, who) || !u_equals_mask(chan->invites, who)))) add_mode(chan, '-', 'I', who); }
static void cmd_mns_chrec(int idx, char *par) { char *nick = NULL, *chn = NULL; struct userrec *u1 = NULL; struct chanuserrec *chanrec = NULL; if (!par[0]) { dprintf(idx, "Usage: -chrec <user> [channel]\n"); return; } nick = newsplit(&par); u1 = get_user_by_handle(userlist, nick); if (!u1) { dprintf(idx, "No such user.\n"); return; } if (!par[0]) { struct chanset_t *chan; chan = findchan_by_dname(dcc[idx].u.chat->con_chan); if (chan) chn = chan->dname; else { dprintf(idx, "Invalid console channel.\n"); return; } } else chn = newsplit(&par); get_user_flagrec(dcc[idx].user, &user, chn); get_user_flagrec(u1, &victim, chn); if (privchan(user, findchan_by_dname(chn), PRIV_OP)) { dprintf(idx, "No such channel.\n"); return; } if ((!glob_master(user) && !chan_master(user)) || /* drummer */ (chan_owner(victim) && !chan_owner(user) && !glob_owner(user)) || (glob_owner(victim) && !glob_owner(user))) { dprintf(idx, "You have no permission to do that.\n"); return; } chanrec = get_chanrec(u1, chn); if (!chanrec) { dprintf(idx, "User %s doesn't have a channel record for %s.\n", nick, chn); return; } putlog(LOG_CMDS, "*", "#%s# -chrec %s %s", dcc[idx].nick, nick, chn); del_chanrec(u1, chn); dprintf(idx, "Removed %s channel record from %s.\n", chn, nick); if (conf.bot->hub) write_userfile(idx); }
static void got_unexempt(struct chanset_t *chan, char *nick, char *from, char *who, char *ch, struct userrec *u) { masklist *e = chan->channel.exempt, *old = NULL; masklist *b; int match = 0; while (e && e->mask[0] && rfc_casecmp(e->mask, who)) { old = e; e = e->next; } if (e && e->mask[0]) { if (old) old->next = e->next; else chan->channel.exempt = e->next; nfree(e->mask); nfree(e->who); nfree(e); } check_tcl_mode(nick, from, u, chan->dname, "-e", who); if (!(chan = modebind_refresh(ch, from, &user, NULL, NULL))) return; if (channel_pending(chan)) return; if (u_sticky_mask(chan->exempts, who) || u_sticky_mask(global_exempts, who)) add_mode(chan, '+', 'e', who); /* If exempt was removed by master then leave it else check for bans */ if (!nick[0] && glob_bot(user) && !glob_master(user) && !chan_master(user)) { b = chan->channel.ban; while (b->mask[0] && !match) { if (mask_match(b->mask, who)) { add_mode(chan, '+', 'e', who); match = 1; } else b = b->next; } } if ((u_equals_mask(global_exempts, who) || u_equals_mask(chan->exempts, who)) && me_op(chan) && !channel_dynamicexempts(chan) && (!glob_bot(user) || !(bot_flags(u) & BOT_SHARE))) add_mode(chan, '+', 'e', who); }
static void got_key(struct chanset_t *chan, char *nick, char *from, char *key) { if (!nick[0] && bounce_modes) reversing = 1; if (!(glob_master(user) || glob_bot(user) || chan_master(user)) && !match_my_nick(nick)) { if ((reversing && !chan->key_prot[0]) || (chan->mode_mns_prot & CHANKEY)) { if (strlen(key) != 0) add_mode(chan, '-', 'k', key); else add_mode(chan, '-', 'k', ""); } if ((chan->mode_pls_prot & CHANKEY) && (chan->key_prot[0] != 0) && strcmp(key, chan->key_prot)) { add_mode(chan, '+', 'k', chan->key_prot); } } }
/* Get icon symbol for a user (depending on access level) * * (*) owner on any channel * (+) master on any channel * (%) botnet master * (@) op on any channel * (^) halfop on any channel * (-) other */ char geticon(int idx) { struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0 }; if (!dcc[idx].user) return '-'; get_user_flagrec(dcc[idx].user, &fr, 0); if (glob_owner(fr) || chan_owner(fr)) return '*'; if (glob_master(fr) || chan_master(fr)) return '+'; if (glob_botmast(fr)) return '%'; if (glob_op(fr) || chan_op(fr)) return '@'; if (glob_halfop(fr) || chan_halfop(fr)) return '^'; return '-'; }
static void irc_report(int idx, int details) { struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 }; char ch[1024], q[256], *p; int k, l; struct chanset_t *chan; strcpy(q, "Channels: "); k = 10; for (chan = chanset; chan; chan = chan->next) { if (idx != DP_STDOUT) get_user_flagrec(dcc[idx].user, &fr, chan->dname); if ((idx == DP_STDOUT) || glob_master(fr) || chan_master(fr)) { p = NULL; if (!channel_inactive(chan)) { if (chan->status & CHAN_JUPED) p = MISC_JUPED; else if (!(chan->status & CHAN_ACTIVE)) p = MISC_TRYING; else if (chan->status & CHAN_PEND) p = MISC_PENDING; else if ((chan->dname[0] != '+') && !me_op(chan)) p = MISC_WANTOPS; } l = simple_sprintf(ch, "%s%s%s%s, ", chan->dname, p ? " (" : "", p ? p : "", p ? ")" : ""); if ((k + l) > 70) { dprintf(idx, " %s\n", q); strcpy(q, " "); k = 10; } k += my_strcpy(q + k, ch); } } if (k > 10) { q[k - 2] = 0; dprintf(idx, " %s\n", q); } }
static void got_uninvite(struct chanset_t *chan, char *nick, char *from, char *who, char *ch, struct userrec *u) { masklist *inv = chan->channel.invite, *old = NULL; while (inv->mask[0] && rfc_casecmp(inv->mask, who)) { old = inv; inv = inv->next; } if (inv->mask[0]) { if (old) old->next = inv->next; else chan->channel.invite = inv->next; nfree(inv->mask); nfree(inv->who); nfree(inv); } check_tcl_mode(nick, from, u, chan->dname, "-I", who); if (!(chan = modebind_refresh(ch, from, &user, NULL, NULL))) return; if (channel_pending(chan)) return; if (u_sticky_mask(chan->invites, who) || u_sticky_mask(global_invites, who)) add_mode(chan, '+', 'I', who); if (!nick[0] && glob_bot(user) && !glob_master(user) && !chan_master(user) && (chan->channel.mode & CHANINV)) add_mode(chan, '+', 'I', who); if ((u_equals_mask(global_invites, who) || u_equals_mask(chan->invites, who)) && me_op(chan) && !channel_dynamicinvites(chan) && (!glob_bot(user) || !(bot_flags(u) & BOT_SHARE))) add_mode(chan, '+', 'I', who); }
static void channels_report(int idx, int details) { int i; char s[1024], s1[100], s2[100]; struct chanset_t *chan; struct flag_record fr = { FR_CHAN | FR_GLOBAL, 0, 0, 0, 0, 0 }; for (chan = chanset; chan; chan = chan->next) { /* Get user's flags if output isn't going to stdout */ if (idx != DP_STDOUT) get_user_flagrec(dcc[idx].user, &fr, chan->dname); /* Don't show channel information to someone who isn't a master */ if ((idx != DP_STDOUT) && !glob_master(fr) && !chan_master(fr)) continue; s[0] = 0; sprintf(s, " %-20s: ", chan->dname); if (channel_inactive(chan)) strcat(s, "(inactive)"); else if (channel_pending(chan)) strcat(s, "(pending)"); else if (!channel_active(chan)) strcat(s, "(not on channel)"); else { s1[0] = 0; sprintf(s1, "%3d member%s", chan->channel.members, (chan->channel.members == 1) ? "" : "s"); strcat(s, s1); s2[0] = 0; get_mode_protect(chan, s2); if (s2[0]) { s1[0] = 0; sprintf(s1, ", enforcing \"%s\"", s2); strcat(s, s1); } s2[0] = 0; if (channel_greet(chan)) strcat(s2, "greet, "); if (channel_autoop(chan)) strcat(s2, "auto-op, "); if (channel_bitch(chan)) strcat(s2, "bitch, "); if (s2[0]) { s2[strlen(s2) - 2] = 0; s1[0] = 0; sprintf(s1, " (%s)", s2); strcat(s, s1); } /* If it's a !chan, we want to display it's unique name too <cybah> */ if (chan->dname[0] == '!') { s1[0] = 0; sprintf(s1, ", unique name %s", chan->name); strcat(s, s1); } } dprintf(idx, "%s\n", s); if (details) { s[0] = 0; i = 0; if (channel_enforcebans(chan)) i += my_strcpy(s + i, "enforcebans "); if (channel_dynamicbans(chan)) i += my_strcpy(s + i, "dynamicbans "); if (!channel_nouserbans(chan)) i += my_strcpy(s + i, "userbans "); if (channel_autoop(chan)) i += my_strcpy(s + i, "autoop "); if (channel_bitch(chan)) i += my_strcpy(s + i, "bitch "); if (channel_greet(chan)) i += my_strcpy(s + i, "greet "); if (channel_protectops(chan)) i += my_strcpy(s + i, "protectops "); if (channel_protecthalfops(chan)) i += my_strcpy(s + i, "protecthalfops "); if (channel_protectfriends(chan)) i += my_strcpy(s + i, "protectfriends "); if (channel_dontkickops(chan)) i += my_strcpy(s + i, "dontkickops "); if (channel_logstatus(chan)) i += my_strcpy(s + i, "statuslog "); if (channel_revenge(chan)) i += my_strcpy(s + i, "revenge "); if (channel_revenge(chan)) i += my_strcpy(s + i, "revengebot "); if (channel_secret(chan)) i += my_strcpy(s + i, "secret "); if (channel_shared(chan)) i += my_strcpy(s + i, "shared "); if (!channel_static(chan)) i += my_strcpy(s + i, "dynamic "); if (channel_autovoice(chan)) i += my_strcpy(s + i, "autovoice "); if (channel_autohalfop(chan)) i += my_strcpy(s + i, "autohalfop "); if (channel_cycle(chan)) i += my_strcpy(s + i, "cycle "); if (channel_seen(chan)) i += my_strcpy(s + i, "seen "); if (channel_dynamicexempts(chan)) i += my_strcpy(s + i, "dynamicexempts "); if (!channel_nouserexempts(chan)) i += my_strcpy(s + i, "userexempts "); if (channel_dynamicinvites(chan)) i += my_strcpy(s + i, "dynamicinvites "); if (!channel_nouserinvites(chan)) i += my_strcpy(s + i, "userinvites "); if (channel_inactive(chan)) i += my_strcpy(s + i, "inactive "); if (channel_nodesynch(chan)) i += my_strcpy(s + i, "nodesynch "); dprintf(idx, " Options: %s\n", s); if (chan->need_op[0]) dprintf(idx, " To get ops, I do: %s\n", chan->need_op); if (chan->need_invite[0]) dprintf(idx, " To get invited, I do: %s\n", chan->need_invite); if (chan->need_limit[0]) dprintf(idx, " To get the channel limit raised, I do: %s\n", chan->need_limit); if (chan->need_unban[0]) dprintf(idx, " To get unbanned, I do: %s\n", chan->need_unban); if (chan->need_key[0]) dprintf(idx, " To get the channel key, I do: %s\n", chan->need_key); if (chan->idle_kick) dprintf(idx, " Kicking idle users after %d minute%s\n", chan->idle_kick, (chan->idle_kick != 1) ? "s" : ""); if (chan->stopnethack_mode) dprintf(idx, " stopnethack-mode: %d\n", chan->stopnethack_mode); if (chan->revenge_mode) dprintf(idx, " revenge-mode: %d\n", chan->revenge_mode); dprintf(idx, " ban-type: %d\n", chan->ban_type); dprintf(idx, " Bans last %d minute%s.\n", chan->ban_time, (chan->ban_time == 1) ? "" : "s"); dprintf(idx, " Exemptions last %d minute%s.\n", chan->exempt_time, (chan->exempt_time == 1) ? "" : "s"); dprintf(idx, " Invitations last %d minute%s.\n", chan->invite_time, (chan->invite_time == 1) ? "" : "s"); } } }
void channels_report(int idx, int details) { int i; char s[1024] = "", s2[100] = ""; struct flag_record fr = {FR_CHAN | FR_GLOBAL, 0, 0, 0 }; for (struct chanset_t *chan = chanset; chan; chan = chan->next) { if (idx != DP_STDOUT) get_user_flagrec(dcc[idx].user, &fr, chan->dname, chan); if (!privchan(fr, chan, PRIV_OP) && ((idx == DP_STDOUT) || glob_master(fr) || chan_master(fr))) { s[0] = 0; if (chan_bitch(chan)) strlcat(s, "bitch, ", sizeof(s)); if (s[0]) s[strlen(s) - 2] = 0; if (!s[0]) strlcpy(s, "lurking", sizeof(s)); get_mode_protect(chan, s2, sizeof(s2)); if (channel_closed(chan)) { if (chan->closed_invite) strlcat(s2, "i", sizeof(s2)); if (chan->closed_private) strlcat(s2, "p", sizeof(s2)); } if (shouldjoin(chan)) { if (channel_active(chan)) { /* If it's a !chan, we want to display it's unique name too <cybah> */ if (chan->dname[0]=='!') { dprintf(idx, " %-20s: %2d member%s enforcing \"%s\" (%s), " "unique name %s\n", chan->dname, chan->channel.members, (chan->channel.members==1) ? "," : "s,", s2, s, chan->name); } else { dprintf(idx, " %-20s: %2d member%s enforcing \"%s\" (%s)\n", chan->dname, chan->channel.members, chan->channel.members == 1 ? "," : "s,", s2, s); } } else { if (!conf.bot->hub) dprintf(idx, " %-20s: (%s), enforcing \"%s\" (%s)\n", chan->dname, channel_pending(chan) ? "pending" : "not on channel", s2, s); else dprintf(idx, " %-20s: (%s), enforcing \"%s\" (%s)\n", chan->dname, "limbo", s2, s); } } else { dprintf(idx, " %-20s: channel is set +inactive\n", chan->dname); } if (details) { s[0] = 0; i = 0; i += my_strcpy(s + i, "dynamic "); if (channel_enforcebans(chan)) i += my_strcpy(s + i, "enforcebans "); if (channel_dynamicbans(chan)) i += my_strcpy(s + i, "dynamicbans "); if (!channel_nouserbans(chan)) i += my_strcpy(s + i, "userbans "); if (channel_bitch(chan)) i += my_strcpy(s + i, "bitch "); /* if (channel_revenge(chan)) i += my_strcpy(s + i, "revenge "); if (channel_revenge(chan)) i += my_strcpy(s + i, "revengebot "); */ if (channel_secret(chan)) i += my_strcpy(s + i, "secret "); if (channel_cycle(chan)) i += my_strcpy(s + i, "cycle "); if (channel_dynamicexempts(chan)) i += my_strcpy(s + i, "dynamicexempts "); if (!channel_nouserexempts(chan)) i += my_strcpy(s + i, "userexempts "); if (channel_dynamicinvites(chan)) i += my_strcpy(s + i, "dynamicinvites "); if (!channel_nouserinvites(chan)) i += my_strcpy(s + i, "userinvites "); if (!shouldjoin(chan)) i += my_strcpy(s + i, "inactive "); if (channel_nodesynch(chan)) i += my_strcpy(s + i, "nodesynch "); if (channel_closed(chan)) i += my_strcpy(s + i, "closed "); if (HAVE_TAKE && channel_take(chan)) i += my_strcpy(s + i, "take "); if (channel_voice(chan)) i += my_strcpy(s + i, "voice "); if (channel_autoop(chan)) i += my_strcpy(s + i, "autoop "); if (channel_meankicks(chan)) i += my_strcpy(s + i, "meankicks "); if (channel_rbl(chan)) i += my_strcpy(s + i, "rbl "); if (channel_voicebitch(chan)) i += my_strcpy(s + i, "voicebitch "); if (channel_protect(chan)) i += my_strcpy(s + i, "protect "); /* Chanflag template * if (channel_temp(chan)) * i += my_strcpy(s + i, "temp "); */ if (channel_nomassjoin(chan)) i += my_strcpy(s + i, "nomassjoin "); if (channel_botbitch(chan)) i += my_strcpy(s + i, "botbitch "); if (channel_backup(chan)) i += my_strcpy(s + i, "backup "); if (channel_fastop(chan)) i += my_strcpy(s + i, "fastop "); if (channel_privchan(chan)) i += my_strcpy(s + i, "private "); dprintf(idx, " Options: %s\n", s); if (chan->limitraise) dprintf(idx, " Raising limit +%d every 2 minutes\n", chan->limitraise); /* if (chan->revenge_mode) dprintf(idx, " revenge-mode %d\n", chan->revenge_mode); */ dprintf(idx, " Bans last %d mins.\n", chan->ban_time); dprintf(idx, " Exemptions last %d mins.\n", chan->exempt_time); dprintf(idx, " Invitations last %d mins.\n", chan->invite_time); } } } }
static void channels_report(int idx, int details) { struct chanset_t *chan; int i; char s[1024], s2[100]; struct flag_record fr = { FR_CHAN | FR_GLOBAL, 0, 0, 0, 0, 0 }; for (chan = chanset; chan; chan = chan->next) { if (idx != DP_STDOUT) get_user_flagrec(dcc[idx].user, &fr, chan->dname); if ((idx == DP_STDOUT) || glob_master(fr) || chan_master(fr)) { s[0] = 0; if (channel_greet(chan)) strcat(s, "greet, "); if (channel_autoop(chan)) strcat(s, "auto-op, "); if (channel_bitch(chan)) strcat(s, "bitch, "); if (s[0]) s[strlen(s) - 2] = 0; if (!s[0]) strcpy(s, MISC_LURKING); get_mode_protect(chan, s2); if (!channel_inactive(chan)) { if (channel_active(chan)) { /* If it's a !chan, we want to display it's unique name too <cybah> */ if (chan->dname[0] == '!') { dprintf(idx, " %-20s: %3d member%s enforcing \"%s\" (%s), " "unique name %s\n", chan->dname, chan->channel.members, (chan->channel.members == 1) ? "," : "s,", s2, s, chan->name); } else { dprintf(idx, " %-20s: %3d member%s enforcing \"%s\" (%s)\n", chan->dname, chan->channel.members, chan->channel.members == 1 ? "," : "s,", s2, s); } } else { dprintf(idx, " %-20s: (%s), enforcing \"%s\" (%s)\n", chan->dname, channel_pending(chan) ? "pending" : "not on channel", s2, s); } } else { dprintf(idx, " %-20s: channel is set +inactive\n", chan->dname); } if (details) { s[0] = 0; i = 0; if (channel_enforcebans(chan)) i += my_strcpy(s + i, "enforcebans "); if (channel_dynamicbans(chan)) i += my_strcpy(s + i, "dynamicbans "); if (!channel_nouserbans(chan)) i += my_strcpy(s + i, "userbans "); if (channel_autoop(chan)) i += my_strcpy(s + i, "autoop "); if (channel_bitch(chan)) i += my_strcpy(s + i, "bitch "); if (channel_greet(chan)) i += my_strcpy(s + i, "greet "); if (channel_protectops(chan)) i += my_strcpy(s + i, "protectops "); if (channel_protecthalfops(chan)) i += my_strcpy(s + i, "protecthalfops "); if (channel_protectfriends(chan)) i += my_strcpy(s + i, "protectfriends "); if (channel_dontkickops(chan)) i += my_strcpy(s + i, "dontkickops "); if (channel_logstatus(chan)) i += my_strcpy(s + i, "statuslog "); if (channel_revenge(chan)) i += my_strcpy(s + i, "revenge "); if (channel_revenge(chan)) i += my_strcpy(s + i, "revengebot "); if (channel_secret(chan)) i += my_strcpy(s + i, "secret "); if (channel_shared(chan)) i += my_strcpy(s + i, "shared "); if (!channel_static(chan)) i += my_strcpy(s + i, "dynamic "); if (channel_autovoice(chan)) i += my_strcpy(s + i, "autovoice "); if (channel_autohalfop(chan)) i += my_strcpy(s + i, "autohalfop "); if (channel_cycle(chan)) i += my_strcpy(s + i, "cycle "); if (channel_dynamicexempts(chan)) i += my_strcpy(s + i, "dynamicexempts "); if (!channel_nouserexempts(chan)) i += my_strcpy(s + i, "userexempts "); if (channel_dynamicinvites(chan)) i += my_strcpy(s + i, "dynamicinvites "); if (!channel_nouserinvites(chan)) i += my_strcpy(s + i, "userinvites "); if (channel_inactive(chan)) i += my_strcpy(s + i, "inactive "); if (channel_nodesynch(chan)) i += my_strcpy(s + i, "nodesynch "); dprintf(idx, " Options: %s\n", s); if (chan->need_op[0]) dprintf(idx, " To get ops, I do: %s\n", chan->need_op); if (chan->need_invite[0]) dprintf(idx, " To get invited, I do: %s\n", chan->need_invite); if (chan->need_limit[0]) dprintf(idx, " To get the channel limit raised, I do: %s\n", chan->need_limit); if (chan->need_unban[0]) dprintf(idx, " To get unbanned, I do: %s\n", chan->need_unban); if (chan->need_key[0]) dprintf(idx, " To get the channel key, I do: %s\n", chan->need_key); if (chan->stopnethack_mode) dprintf(idx, " stopnethack-mode: %d\n", chan->stopnethack_mode); if (chan->revenge_mode) dprintf(idx, " revenge-mode: %d\n", chan->revenge_mode); dprintf(idx, " Bans last %d minute%s.\n", chan->ban_time, (chan->ban_time != 1) ? "s" : ""); dprintf(idx, " Exemptions last %d minute%s.\n", chan->exempt_time, (chan->exempt_time != 1) ? "s" : ""); dprintf(idx, " Invitations last %d minute%s.\n", chan->invite_time, (chan->invite_time != 1) ? "s" : ""); } } } }
static void cmd_chanset(int idx, char *par) { char *chname = NULL, result[RESULT_LEN] = ""; struct chanset_t *chan = NULL; int all = 0; if (!par[0]) { putlog(LOG_CMDS, "*", "#%s# chanset %s", dcc[idx].nick, par); dprintf(idx, "Usage: chanset [%schannel|*|default] <settings>\n", CHANMETA); return; } // Determine channel name if (strchr(CHANMETA, par[0]) || !strncasecmp(par, "default", 7) || !strncmp(par, "*", 1)) chname = newsplit(&par); else { if (strncmp(dcc[idx].u.chat->con_chan, "*", 1) && !(chan = findchan_by_dname(chname = dcc[idx].u.chat->con_chan))) { dprintf(idx, "Invalid console channel.\n"); return; } chname = dcc[idx].u.chat->con_chan; } if (chname && chname[0]) { if (!strncmp(chname, "*", 1)) { all = 1; get_user_flagrec(dcc[idx].user, &user, chanset ? chanset->dname : ""); if (!glob_owner(user)) { dprintf(idx, "You need to be a global owner to use '%schanset *'.\n", (dcc[idx].u.chat->channel >= 0) ? settings.dcc_prefix : ""); return; } } else if (!strcasecmp(chname, "default")) { chan = chanset_default; } else chan = findchan_by_dname(chname); } if (!all && !chan && chname && chname[0]) { dprintf(idx, "No such channel.\n"); return; } if (!par[0]) { dprintf(idx, "Usage: chanset [%schannel|*|default] <settings>\n", CHANMETA); return; } if (!all) { get_user_flagrec(dcc[idx].user, &user, chan->dname); if (privchan(user, chan, PRIV_OP)) { dprintf(idx, "No such channel.\n"); return; } if (!glob_master(user) && !chan_master(user)) { dprintf(idx, "You don't have access to %s. \n", chan->dname); return; } else if ((strstr(par, "+private") || strstr(par, "-private")) && (!glob_owner(user))) { dprintf(idx, "You don't have access to set +/-private on %s (halting command).\n", chan->dname); return; } else if ((strstr(par, "+backup") || strstr(par, "-backup")) && (!glob_owner(user))) { dprintf(idx, "You don't have access to set +/-backup on %s (halting command).\n", chan->dname); return; } else if ((strstr(par, "+inactive") || strstr(par, "-inactive")) && (!glob_owner(user))) { dprintf(idx, "You don't have access to set +/-inactive on %s (halting command).\n", chan->dname); return; } } putlog(LOG_CMDS, "*", "#%s# chanset (%s) %s", dcc[idx].nick, all ? "*" : chan->dname, par); if (do_chanset(result, all ? NULL : chan, par, DO_LOCAL | DO_NET | CMD) == ERROR) { dprintf(idx, "Error trying to set { %s } on %s: %s\n", par, all ? "all channels" : chan->dname, result); return; } if (all) dprintf(idx, "Successfully set modes { %s } on all channels (Including the default).\n", par); else dprintf(idx, "Successfully set modes { %s } on %s\n", par, chan->dname); if (conf.bot->hub) write_userfile(idx); }
static void cmd_chaninfo(int idx, char *par) { char *chname = NULL, work[512] = ""; struct chanset_t *chan = NULL; int cnt = 0; if (!par[0]) { chname = dcc[idx].u.chat->con_chan; if (chname[0] == '*') { dprintf(idx, "Your console channel is invalid.\n"); return; } } else { chname = newsplit(&par); get_user_flagrec(dcc[idx].user, &user, chname); if (!glob_master(user) && !chan_master(user)) { dprintf(idx, "You don't have access to %s.\n", chname); return; } } if (!strcasecmp(chname, "default")) chan = chanset_default; else chan = findchan_by_dname(chname); if (!chan || (chan && privchan(user, chan, PRIV_OP))) { dprintf(idx, "No such channel.\n"); return; } else { char nick[HANDLEN + 1] = "", date[81] = ""; int deflag = 0; if (chan->added_ts) { strftime(date, sizeof date, "%c %Z", gmtime(&(chan->added_ts))); } else date[0] = 0; if (chan->added_by && chan->added_by[0]) strlcpy(nick, chan->added_by, sizeof(nick)); else nick[0] = 0; putlog(LOG_CMDS, "*", "#%s# chaninfo %s", dcc[idx].nick, chname); if (nick[0] && date[0]) dprintf(idx, "Settings for channel %s (Added %s by %s%s%s):\n", chan->dname, date, BOLD(idx), nick, BOLD_END(idx)); else dprintf(idx, "Settings for channel %s:\n", chan->dname); /* FIXME: SHOW_CHAR() here */ get_mode_protect(chan, work, sizeof(work)); dprintf(idx, "Protect modes (chanmode): %s\n", work[0] ? work : "None"); dprintf(idx, "Groups: %s\n", chan->groups && chan->groups->length() ? static_cast<bd::String>(chan->groups->join(" ")).c_str() : "None"); dprintf(idx, "FiSH Key: %s\n", chan->fish_key[0] ? chan->fish_key : "not set"); // dprintf(idx, "Protect topic (topic) : %s\n", chan->topic[0] ? chan->topic : ""); /* Chanchar template * dprintf(idx, "String temp: %s\n", chan->temp[0] ? chan->temp : "NULL"); */ dprintf(idx, "Channel flags:\n"); work[0] = 0; SHOW_FLAG("autoop", channel_autoop(chan)); SHOW_FLAG("backup", channel_backup(chan)); SHOW_FLAG("bitch", channel_bitch(chan)); SHOW_FLAG("botbitch", channel_botbitch(chan)); SHOW_FLAG("closed", channel_closed(chan)); SHOW_FLAG("cycle", channel_cycle(chan)); SHOW_FLAG("enforcebans", channel_enforcebans(chan)); SHOW_FLAG("fastop", channel_fastop(chan)); SHOW_FLAG("floodban", channel_floodban(chan)); SHOW_FLAG("inactive", channel_inactive(chan)); SHOW_FLAG("nodesynch", channel_nodesynch(chan)); SHOW_FLAG("private", channel_privchan(chan)); SHOW_FLAG("protect", channel_protect(chan)); SHOW_FLAG("rbl", channel_rbl(chan)); if (HAVE_TAKE) SHOW_FLAG("take", channel_take(chan)); SHOW_FLAG("voice", channel_voice(chan)); SHOW_FLAG("voicebitch", channel_voicebitch(chan)); SHOW_FLAG("", 0); SHOW_FLAG("dynamicbans", channel_dynamicbans(chan)); SHOW_FLAG("userbans", !channel_nouserbans(chan)); SHOW_FLAG("dynamicexempts", channel_dynamicexempts(chan)); SHOW_FLAG("userexempts", !channel_nouserexempts(chan)); SHOW_FLAG("dynamicinvites", channel_dynamicinvites(chan)); SHOW_FLAG("userinvites", !channel_nouserinvites(chan)); SHOW_FLAG("", 0); work[0] = 0; /* Chanflag template * SHOW_FLAG("template", channel_template(chan)); * also include %ctemp in dprintf. */ work[0] = cnt = 0; /* Chanint template * SHOW_INT("Desc: ", integer, "YES", "NO"); */ dprintf(idx, "Channel settings:\n"); deflag = chan->bad_cookie; SHOW_INT("Auto-delay: ", chan->auto_delay, NULL, "None"); SHOW_INT("Bad-cookie:" , chan->bad_cookie, DEFLAG_STR, "Ignore"); SHOW_INT("Ban-time: ", chan->ban_time, NULL, "Forever"); SHOW_INT("Ban-type: ", chan->ban_type, NULL, "3"); SHOW_INT("Closed-ban: ", chan->closed_ban, NULL, "Don't!"); SHOW_INT("Closed-invite:", chan->closed_invite, NULL, "Don't!"); SHOW_INT("Closed-Private:", chan->closed_private, NULL, "Don't!"); SHOW_INT("Closed-Exempt:", chan->closed_exempt_mode, F_STR(chan->closed_exempt_mode), "None"); SHOW_INT("Exempt-time: ", chan->exempt_time, NULL, "Forever"); SHOW_INT("Flood-exempt: ", chan->flood_exempt_mode, F_STR(chan->flood_exempt_mode), "None"); SHOW_INT("Flood-lock-time: ", chan->flood_lock_time, NULL, "Don't"); SHOW_INT("Caps-Limit(%): ", chan->capslimit, NULL, "None"); SHOW_INT("Color-Limit: ", chan->colorlimit, NULL, "None"); SHOW_INT("Invite-time: ", chan->invite_time, NULL, "Forever"); SHOW_INT("Knock: ", chan->knock_flags, F_STR(chan->knock_flags), "None"); SHOW_INT("Limit raise (limit): ", chan->limitraise, NULL, "Disabled"); deflag = chan->manop; SHOW_INT("Manop: ", chan->manop, DEFLAG_STR, "Ignore"); deflag = chan->mdop; SHOW_INT("Mdop: ", chan->mdop, DEFLAG_STR, "Ignore"); deflag = chan->mop; SHOW_INT("Mop: ", chan->mop, DEFLAG_STR, "Ignore"); deflag = chan->revenge; SHOW_INT("Revenge: ", chan->revenge, DEFLAG_STR, "Ignore"); SHOW_INT("Protect-backup: ", chan->protect_backup, "Do!", "Don't!"); SHOW_INT("Voice-non-ident: ", chan->voice_non_ident, "Do!", "Don't!"); SHOW_INT("Voice-moderate:", chan->voice_moderate, "Do!", "Don't!"); dprintf(idx, "Flood settings: chan bytes ctcp join kick deop nick mjoin mpub mbytes mctcp\n"); dprintf(idx, " number: %3d %4d %3d %3d %3d %3d %3d %3d %3d %4d %3d\n", chan->flood_pub_thr, chan->flood_bytes_thr, chan->flood_ctcp_thr, chan->flood_join_thr, chan->flood_kick_thr, chan->flood_deop_thr, chan->flood_nick_thr, chan->flood_mjoin_thr, chan->flood_mpub_thr, chan->flood_mbytes_thr, chan->flood_mctcp_thr); dprintf(idx, " time : %3u %4u %3u %3u %3u %3u %3u %3u %3u %4u %4u\n", chan->flood_pub_time, chan->flood_bytes_time, chan->flood_ctcp_time, chan->flood_join_time, chan->flood_kick_time, chan->flood_deop_time, chan->flood_nick_time, chan->flood_mjoin_time, chan->flood_mpub_time, chan->flood_mbytes_time, chan->flood_mctcp_time); } }
static int gotmode(char *from, char *origmsg) { char *nick, *ch, *op, *chg, *msg; char s[UHOSTLEN], buf[511]; char ms2[3]; int z; struct userrec *u; memberlist *m; struct chanset_t *chan; strncpy(buf, origmsg, 510); buf[510] = 0; msg = buf; /* Usermode changes? */ if (msg[0] && (strchr(CHANMETA, msg[0]) != NULL)) { ch = newsplit(&msg); chg = newsplit(&msg); reversing = 0; chan = findchan(ch); if (!chan) { putlog(LOG_MISC, "*", CHAN_FORCEJOIN, ch); dprintf(DP_SERVER, "PART %s\n", ch); } else if (channel_active(chan) || channel_pending(chan)) { z = strlen(msg); if (msg[--z] == ' ') /* I hate cosmetic bugs :P -poptix */ msg[z] = 0; putlog(LOG_MODES, chan->dname, "%s: mode change '%s %s' by %s", ch, chg, msg, from); u = get_user_by_host(from); get_user_flagrec(u, &user, ch); nick = splitnick(&from); m = ismember(chan, nick); if (m) m->last = now; if (m && channel_active(chan) && (me_op(chan) || (me_halfop(chan) && !chan_hasop(m))) && !(glob_friend(user) || chan_friend(user) || (channel_dontkickops(chan) && (chan_op(user) || (glob_op(user) && !chan_deop(user))))) && !match_my_nick(nick)) { if (chan_fakeop(m) || chan_fakehalfop(m)) { putlog(LOG_MODES, ch, CHAN_FAKEMODE, ch); dprintf(DP_MODE, "KICK %s %s :%s\n", ch, nick, CHAN_FAKEMODE_KICK); m->flags |= SENTKICK; reversing = 1; } else if (!chan_hasop(m) && !chan_hashalfop(m) && !channel_nodesynch(chan)) { putlog(LOG_MODES, ch, CHAN_DESYNCMODE, ch); dprintf(DP_MODE, "KICK %s %s :%s\n", ch, nick, CHAN_DESYNCMODE_KICK); m->flags |= SENTKICK; reversing = 1; } } ms2[0] = '+'; ms2[2] = 0; while ((ms2[1] = *chg)) { int todo = 0; switch (*chg) { case '+': ms2[0] = '+'; break; case '-': ms2[0] = '-'; break; case 'i': todo = CHANINV; if (!nick[0] && bounce_modes) reversing = 1; break; case 'p': todo = CHANPRIV; if (!nick[0] && bounce_modes) reversing = 1; break; case 's': todo = CHANSEC; if (!nick[0] && bounce_modes) reversing = 1; break; case 'm': todo = CHANMODER; if (!nick[0] && bounce_modes) reversing = 1; break; case 'c': todo = CHANNOCLR; if (!nick[0] && bounce_modes) reversing = 1; break; case 'C': todo = CHANNOCTCP; if (!nick[0] && bounce_modes) reversing = 1; break; case 'R': todo = CHANREGON; if (!nick[0] && bounce_modes) reversing = 1; break; case 'M': todo = CHANMODREG; if (!nick[0] && bounce_modes) reversing = 1; break; case 'r': todo = CHANLONLY; if (!nick[0] && bounce_modes) reversing = 1; break; case 'D': todo = CHANDELJN; if (!nick[0] && bounce_modes) reversing = 1; break; case 'u': todo = CHANSTRIP; if (!nick[0] && bounce_modes) reversing = 1; break; case 'N': todo = CHANNONOTC; if (!nick[0] && bounce_modes) reversing = 1; break; case 'T': todo = CHANNOAMSG; if (!nick[0] && bounce_modes) reversing = 1; break; case 'd': todo = CHANINVIS; break; case 't': todo = CHANTOPIC; if (!nick[0] && bounce_modes) reversing = 1; break; case 'n': todo = CHANNOMSG; if (!nick[0] && bounce_modes) reversing = 1; break; case 'a': todo = CHANANON; if (!nick[0] && bounce_modes) reversing = 1; break; case 'q': todo = CHANQUIET; if (!nick[0] && bounce_modes) reversing = 1; break; case 'l': if (!nick[0] && bounce_modes) reversing = 1; if (ms2[0] == '-') { check_tcl_mode(nick, from, u, chan->dname, ms2, ""); /* The Tcl proc might have modified/removed the chan or user */ if (!(chan = modebind_refresh(ch, from, &user, NULL, NULL))) return 0; if (channel_active(chan)) { if (reversing && (chan->channel.maxmembers != 0)) { simple_sprintf(s, "%d", chan->channel.maxmembers); add_mode(chan, '+', 'l', s); } else if ((chan->limit_prot != 0) && !glob_master(user) && !chan_master(user) && !match_my_nick(nick)) { simple_sprintf(s, "%d", chan->limit_prot); add_mode(chan, '+', 'l', s); } } chan->channel.maxmembers = 0; } else { op = newsplit(&msg); fixcolon(op); if (op == '\0') break; chan->channel.maxmembers = atoi(op); check_tcl_mode(nick, from, u, chan->dname, ms2, int_to_base10(chan->channel.maxmembers)); /* The Tcl proc might have modified/removed the chan or user */ if (!(chan = modebind_refresh(ch, from, &user, NULL, NULL))) return 0; if (channel_pending(chan)) break; if ((reversing && !(chan->mode_pls_prot & CHANLIMIT)) || ((chan->mode_mns_prot & CHANLIMIT) && !glob_master(user) && !chan_master(user))) add_mode(chan, '-', 'l', ""); if ((chan->limit_prot != chan->channel.maxmembers) && (chan->mode_pls_prot & CHANLIMIT) && (chan->limit_prot != 0) && !glob_master(user) && !chan_master(user)) { simple_sprintf(s, "%d", chan->limit_prot); add_mode(chan, '+', 'l', s); } } break; case 'k': if (ms2[0] == '+') chan->channel.mode |= CHANKEY; else chan->channel.mode &= ~CHANKEY; op = newsplit(&msg); fixcolon(op); if (op == '\0') { break; } check_tcl_mode(nick, from, u, chan->dname, ms2, op); /* The Tcl proc might have modified/removed the chan or user */ if (!(chan = modebind_refresh(ch, from, &user, NULL, NULL))) return 0; if (ms2[0] == '+') { set_key(chan, op); if (channel_active(chan)) got_key(chan, nick, from, op); } else { if (channel_active(chan)) { if (reversing && chan->channel.key[0]) add_mode(chan, '+', 'k', chan->channel.key); else if (chan->key_prot[0] && !glob_master(user) && !chan_master(user) && !match_my_nick(nick)) add_mode(chan, '+', 'k', chan->key_prot); } set_key(chan, NULL); } break; case 'o': op = newsplit(&msg); fixcolon(op); if (ms2[0] == '+') got_op(chan, nick, from, op, u, &user); else got_deop(chan, nick, from, op, u); break; case 'h': op = newsplit(&msg); fixcolon(op); if (ms2[0] == '+') got_halfop(chan, nick, from, op, u, &user); else got_dehalfop(chan, nick, from, op, u); break; case 'v': op = newsplit(&msg); fixcolon(op); m = ismember(chan, op); if (!m) { if (channel_pending(chan)) break; putlog(LOG_MISC, chan->dname, CHAN_BADCHANMODE, chan->dname, op); chan->status |= CHAN_PEND; refresh_who_chan(chan->name); } else { simple_sprintf(s, "%s!%s", m->nick, m->userhost); get_user_flagrec(m->user ? m->user : get_user_by_host(s), &victim, chan->dname); if (ms2[0] == '+') { m->flags &= ~SENTVOICE; m->flags |= CHANVOICE; check_tcl_mode(nick, from, u, chan->dname, ms2, op); if (!(chan = modebind_refresh(ch, from, &user, s, &victim))) return 0; if (channel_active(chan) && !glob_master(user) && !chan_master(user) && !match_my_nick(nick)) { if (chan_quiet(victim) || (glob_quiet(victim) && !chan_voice(victim))) add_mode(chan, '-', 'v', op); else if (reversing) add_mode(chan, '-', 'v', op); } } else { m->flags &= ~SENTDEVOICE; m->flags &= ~CHANVOICE; check_tcl_mode(nick, from, u, chan->dname, ms2, op); if (!(chan = modebind_refresh(ch, from, &user, s, &victim))) return 0; if (channel_active(chan) && !glob_master(user) && !chan_master(user) && !match_my_nick(nick)) { if ((channel_autovoice(chan) && !chan_quiet(victim) && (chan_voice(victim) || glob_voice(victim))) || (!chan_quiet(victim) && (glob_gvoice(victim) || chan_gvoice(victim)))) add_mode(chan, '+', 'v', op); else if (reversing) add_mode(chan, '+', 'v', op); } } } break; case 'b': op = newsplit(&msg); fixcolon(op); if (ms2[0] == '+') got_ban(chan, nick, from, op, ch, u); else got_unban(chan, nick, from, op, ch, u); break; case 'e': op = newsplit(&msg); fixcolon(op); if (ms2[0] == '+') got_exempt(chan, nick, from, op, ch, u); else got_unexempt(chan, nick, from, op, ch, u); break; case 'I': op = newsplit(&msg); fixcolon(op); if (ms2[0] == '+') got_invite(chan, nick, from, op, ch, u); else got_uninvite(chan, nick, from, op, ch, u); break; } if (todo) { check_tcl_mode(nick, from, u, chan->dname, ms2, ""); if (!(chan = modebind_refresh(ch, from, &user, NULL, NULL))) return 0; if (ms2[0] == '+') chan->channel.mode |= todo; else chan->channel.mode &= ~todo; if (channel_active(chan)) { if ((((ms2[0] == '+') && (chan->mode_mns_prot & todo)) || ((ms2[0] == '-') && (chan->mode_pls_prot & todo))) && !glob_master(user) && !chan_master(user) && !match_my_nick(nick)) add_mode(chan, ms2[0] == '+' ? '-' : '+', *chg, ""); else if (reversing && ((ms2[0] == '+') || (chan->mode_pls_prot & todo)) && ((ms2[0] == '-') || (chan->mode_mns_prot & todo))) add_mode(chan, ms2[0] == '+' ? '-' : '+', *chg, ""); } } chg++; } if (!me_op(chan) && !nick[0]) chan->status |= CHAN_ASKEDMODES; } } return 0; }
static void channels_report(int idx, int details) { struct chanset_t *chan; int i; char s[1024], s2[100]; struct flag_record fr = {FR_CHAN | FR_GLOBAL, 0, 0, 0, 0, 0}; chan = chanset; while (chan != NULL) { if (idx != DP_STDOUT) get_user_flagrec(dcc[idx].user, &fr, chan->name); if ((idx == DP_STDOUT) || glob_master(fr) || chan_master(fr)) { s[0] = 0; if (channel_greet(chan)) strcat(s, "greet, "); if (channel_autoop(chan)) strcat(s, "auto-op, "); if (channel_bitch(chan)) strcat(s, "bitch, "); if (s[0]) s[strlen(s) - 2] = 0; if (!s[0]) strcpy(s, MISC_LURKING); get_mode_protect(chan, s2); if (!channel_inactive(chan)) { if (channel_active(chan)) { dprintf(idx, " %-10s: %2d member%s enforcing \"%s\" (%s)\n", chan->name, chan->channel.members, chan->channel.members == 1 ? "," : "s,", s2, s); } else { dprintf(idx, " %-10s: (%s), enforcing \"%s\" (%s)\n", chan->name, channel_pending(chan) ? "pending" : "inactive", s2, s); } } else { dprintf(idx, " %-10s: no IRC support for this channel\n", chan->name); } if (details) { s[0] = 0; i = 0; if (channel_clearbans(chan)) i += my_strcpy(s + i, "clear-bans "); if (channel_enforcebans(chan)) i += my_strcpy(s + i, "enforce-bans "); if (channel_dynamicbans(chan)) i += my_strcpy(s + i, "dynamic-bans "); if (channel_nouserbans(chan)) i += my_strcpy(s + i, "forbid-user-bans "); if (channel_autoop(chan)) i += my_strcpy(s + i, "op-on-join "); if (channel_bitch(chan)) i += my_strcpy(s + i, "bitch "); if (channel_greet(chan)) i += my_strcpy(s + i, "greet "); if (channel_protectops(chan)) i += my_strcpy(s + i, "protect-ops "); if (channel_protectfriends(chan)) i += my_strcpy(s + i, "protect-friends "); if (channel_dontkickops(chan)) i += my_strcpy(s + i, "dont-kick-ops "); if (channel_wasoptest(chan)) i += my_strcpy(s + i, "was-op-test "); if (channel_logstatus(chan)) i += my_strcpy(s + i, "log-status "); if (channel_revenge(chan)) i += my_strcpy(s + i, "revenge "); if (channel_stopnethack(chan)) i += my_strcpy(s + i, "stopnethack "); if (channel_secret(chan)) i += my_strcpy(s + i, "secret "); if (channel_shared(chan)) i += my_strcpy(s + i, "shared "); if (!channel_static(chan)) i += my_strcpy(s + i, "dynamic "); if (channel_autovoice(chan)) i += my_strcpy(s + i, "autovoice "); if (channel_cycle(chan)) i += my_strcpy(s + i, "cycle "); if (channel_seen(chan)) i += my_strcpy(s + i, "seen "); if (channel_dynamicexempts(chan)) i += my_strcpy(s + i, "dynamic-exempts "); if (channel_nouserexempts(chan)) i += my_strcpy(s + i, "forbid-user-exempts "); if (channel_dynamicinvites(chan)) i += my_strcpy(s + i, "dynamic-invites "); if (channel_nouserinvites(chan)) i += my_strcpy(s + i, "forbid-user-invites "); if (channel_inactive(chan)) i += my_strcpy(s + i, "inactive "); dprintf(idx, " Options: %s\n", s); if (chan->need_op[0]) dprintf(idx, " To get ops I do: %s\n", chan->need_op); if (chan->need_invite[0]) dprintf(idx, " To get invited I do: %s\n", chan->need_invite); if (chan->need_limit[0]) dprintf(idx, " To get the channel limit up'd I do: %s\n", chan->need_limit); if (chan->need_unban[0]) dprintf(idx, " To get unbanned I do: %s\n", chan->need_unban); if (chan->need_key[0]) dprintf(idx, " To get the channel key I do: %s\n", chan->need_key); if (chan->idle_kick) dprintf(idx, " Kicking idle users after %d min\n", chan->idle_kick); } } chan = chan->next; } if (details) { dprintf(idx, " Bans last %d mins.\n", ban_time); dprintf(idx, " Exemptions last %d mins.\n", exempt_time); dprintf(idx, " Invitations last %d mins.\n", invite_time); } }
static void got_ban(struct chanset_t *chan, char *nick, char *from, char *who, char *ch, struct userrec *u) { char me[UHOSTLEN], s[UHOSTLEN], s1[UHOSTLEN]; memberlist *m; struct userrec *targ; egg_snprintf(me, sizeof me, "%s!%s", botname, botuserhost); egg_snprintf(s, sizeof s, "%s!%s", nick, from); newban(chan, who, s); check_tcl_mode(nick, from, u, chan->dname, "+b", who); if (!(chan = modebind_refresh(ch, from, &user, NULL, NULL))) return; if (channel_pending(chan) || HALFOP_CANTDOMODE('b')) return; if (match_addr(who, me) && !isexempted(chan, me)) { add_mode(chan, '-', 'b', who); reversing = 1; return; } if (!match_my_nick(nick)) { if (nick[0] && channel_nouserbans(chan) && !glob_bot(user) && !glob_master(user) && !chan_master(user)) { add_mode(chan, '-', 'b', who); return; } for (m = chan->channel.member; m && m->nick[0]; m = m->next) { egg_snprintf(s1, sizeof s1, "%s!%s", m->nick, m->userhost); if (match_addr(who, s1)) { targ = get_user_by_host(s1); if (targ) { get_user_flagrec(targ, &victim, chan->dname); if ((glob_friend(victim) || (glob_op(victim) && !chan_deop(victim)) || chan_friend(victim) || chan_op(victim)) && !glob_master(user) && !glob_bot(user) && !chan_master(user) && !isexempted(chan, s1)) { add_mode(chan, '-', 'b', who); return; } } } } } refresh_exempt(chan, who); if (nick[0] && channel_enforcebans(chan)) { register maskrec *b; int cycle; char resn[512] = ""; for (cycle = 0; cycle < 2; cycle++) { for (b = cycle ? chan->bans : global_bans; b; b = b->next) { if (match_addr(b->mask, who)) { if (b->desc && b->desc[0] != '@') egg_snprintf(resn, sizeof resn, "%s %s", IRC_PREBANNED, b->desc); else resn[0] = 0; } } } kick_all(chan, who, resn[0] ? resn : IRC_BANNED, match_my_nick(nick) ? 0 : 1); } if (!nick[0] && (bounce_bans || bounce_modes) && (!u_equals_mask(global_bans, who) || !u_equals_mask(chan->bans, who))) add_mode(chan, '-', 'b', who); }
static void got_dehalfop(struct chanset_t *chan, char *nick, char *from, char *who, struct userrec *opu) { memberlist *m; char ch[sizeof chan->name]; char s[UHOSTLEN], s1[UHOSTLEN]; struct userrec *u; int had_halfop; m = ismember(chan, who); if (!m) { if (channel_pending(chan)) return; putlog(LOG_MISC, chan->dname, CHAN_BADCHANMODE, chan->dname, who); chan->status |= CHAN_PEND; refresh_who_chan(chan->name); return; } strcpy(ch, chan->name); simple_sprintf(s, "%s!%s", m->nick, m->userhost); simple_sprintf(s1, "%s!%s", nick, from); u = get_user_by_host(s); get_user_flagrec(u, &victim, chan->dname); had_halfop = chan_hasop(m); /* Flags need to be set correctly right from the beginning now, so that * add_mode() doesn't get irritated. */ m->flags &= ~(CHANHALFOP | SENTDEHALFOP | FAKEHALFOP); check_tcl_mode(nick, from, opu, chan->dname, "-h", who); if (!(chan = modebind_refresh(ch, from, &user, s, &victim)) || !(m = ismember(chan, who))) return; /* Check comments in got_op() (drummer) */ m->flags &= ~WASHALFOP; if (channel_pending(chan)) return; /* Dehalfop'd someone on my oplist? */ if (HALFOP_CANDOMODE('h')) { int ok = 1; if (!glob_dehalfop(victim) && !chan_dehalfop(victim)) { if (channel_protecthalfops(chan) && (glob_master(victim) || chan_master(victim) || glob_halfop(victim) || chan_halfop(victim))) ok = 0; else if (channel_protectfriends(chan) && (glob_friend(victim) || chan_friend(victim))) ok = 0; } if ((reversing || !ok) && had_halfop && !match_my_nick(nick) && rfc_casecmp(who, nick) && !match_my_nick(who) && !glob_master(user) && !chan_master(user) && !glob_bot(user) && ((chan_halfop(victim) || (glob_halfop(victim) && !chan_dehalfop(victim))) || !channel_bitch(chan))) add_mode(chan, '+', 'h', who); } if (!nick[0]) putlog(LOG_MODES, chan->dname, "TS resync (%s): %s deopped by %s", chan->dname, who, from); if (!(m->flags & (CHANVOICE | STOPWHO))) { chan->status |= CHAN_PEND; refresh_who_chan(chan->name); m->flags |= STOPWHO; } }
static void got_deop(struct chanset_t *chan, char *nick, char *from, char *who, struct userrec *opu) { memberlist *m; char ch[sizeof chan->name]; char s[UHOSTLEN], s1[UHOSTLEN]; struct userrec *u; int had_halfop; m = ismember(chan, who); if (!m) { if (channel_pending(chan)) return; putlog(LOG_MISC, chan->dname, CHAN_BADCHANMODE, chan->dname, who); chan->status |= CHAN_PEND; refresh_who_chan(chan->name); return; } strcpy(ch, chan->name); simple_sprintf(s, "%s!%s", m->nick, m->userhost); simple_sprintf(s1, "%s!%s", nick, from); u = get_user_by_host(s); get_user_flagrec(u, &victim, chan->dname); had_halfop = chan_hasop(m); /* Flags need to be set correctly right from the beginning now, so that * add_mode() doesn't get irritated. */ m->flags &= ~(CHANOP | SENTDEOP | FAKEOP); check_tcl_mode(nick, from, opu, chan->dname, "-o", who); if (!(chan = modebind_refresh(ch, from, &user, s, &victim)) || !(m = ismember(chan, who))) return; m->flags &= ~WASOP; if (channel_pending(chan)) return; if (HALFOP_CANDOMODE('o')) { int ok = 1; if (!glob_deop(victim) && !chan_deop(victim)) { if (channel_protectops(chan) && (glob_master(victim) || chan_master(victim) || glob_op(victim) || chan_op(victim))) ok = 0; else if (channel_protectfriends(chan) && (glob_friend(victim) || chan_friend(victim))) ok = 0; } if ((reversing || !ok) && had_halfop && !match_my_nick(nick) && rfc_casecmp(who, nick) && !match_my_nick(who) && !glob_master(user) && !chan_master(user) && !glob_bot(user) && ((chan_op(victim) || (glob_op(victim) && !chan_deop(victim))) || !channel_bitch(chan))) add_mode(chan, '+', 'o', who); } if (!nick[0]) putlog(LOG_MODES, chan->dname, "TS resync (%s): %s deopped by %s", chan->dname, who, from); /* Check for mass deop */ if (nick[0]) detect_chan_flood(nick, from, s1, chan, FLOOD_DEOP, who, 0); /* Having op hides your +v and +h status -- so now that someone's lost ops, * check to see if they have +v or +h */ if (!(m->flags & (CHANVOICE | CHANHALFOP | STOPWHO))) { chan->status |= CHAN_PEND; refresh_who_chan(chan->name); m->flags |= STOPWHO; } /* Was the bot deopped? */ if (match_my_nick(who)) { /* Cancel any pending kicks and modes */ memberlist *m2; for (m2 = chan->channel.member; m2 && m2->nick[0]; m2 = m2->next) m2->flags &= ~(SENTKICK | SENTDEOP | SENTOP | SENTVOICE | SENTDEVOICE); check_tcl_need(chan->dname, "op"); if (chan->need_op[0]) do_tcl("need-op", chan->need_op); if (!nick[0]) putlog(LOG_MODES, chan->dname, "TS resync deopped me on %s :(", chan->dname); } if (nick[0]) maybe_revenge(chan, s1, s, REVENGE_DEOP); }
static void got_halfop(struct chanset_t *chan, char *nick, char *from, char *who, struct userrec *opu, struct flag_record *opper) { memberlist *m; char s[UHOSTLEN]; char ch[sizeof chan->name]; struct userrec *u; int check_chan = 0; int snm = chan->stopnethack_mode; m = ismember(chan, who); if (!m) { if (channel_pending(chan)) return; putlog(LOG_MISC, chan->dname, CHAN_BADCHANMODE, chan->dname, who); chan->status |= CHAN_PEND; refresh_who_chan(chan->name); return; } /* Did *I* just get halfopped? */ if (!me_op(chan) && !me_halfop(chan) && match_my_nick(who)) check_chan = 1; strcpy(ch, chan->name); simple_sprintf(s, "%s!%s", m->nick, m->userhost); if (!m->user) u = get_user_by_host(s); else u = m->user; get_user_flagrec(u, &victim, chan->dname); /* Flags need to be set correctly right from the beginning now, so that * add_mode() doesn't get irritated. */ m->flags |= CHANHALFOP; check_tcl_mode(nick, from, opu, chan->dname, "+h", who); if (!(chan = modebind_refresh(ch, from, opper, s, &victim)) || !(m = ismember(chan, who))) return; m->flags &= ~SENTHALFOP; if (channel_pending(chan)) return; if (nick[0] && HALFOP_CANDOMODE('h') && !match_my_nick(who) && !match_my_nick(nick)) { if (channel_bitch(chan) && !(glob_master(*opper) || glob_bot(*opper)) && !chan_master(*opper) && !(glob_halfop(victim) || glob_op(victim) || glob_bot(victim)) && !chan_op(victim) && !chan_halfop(victim)) add_mode(chan, '-', 'h', who); else if ((chan_dehalfop(victim) || (glob_dehalfop(victim) && !chan_halfop(victim))) && !glob_master(*opper) && !chan_master(*opper)) add_mode(chan, '-', 'h', who); else if (reversing) add_mode(chan, '-', 'h', who); } else if (reversing && HALFOP_CANDOMODE('h') && !match_my_nick(who) && !match_my_nick(nick)) add_mode(chan, '-', 'h', who); if (!nick[0] && HALFOP_CANDOMODE('h') && !match_my_nick(who)) { if (chan_dehalfop(victim) || (glob_dehalfop(victim) && !chan_halfop(victim))) { m->flags |= FAKEHALFOP; add_mode(chan, '-', 'h', who); } else if (snm > 0 && snm < 7 && !((channel_autohalfop(chan) || glob_autohalfop(victim) || chan_autohalfop(victim)) && (chan_halfop(victim) || (glob_halfop(victim) && !chan_dehalfop(victim)))) && !glob_exempt(victim) && !chan_exempt(victim)) { if (snm == 5) snm = channel_bitch(chan) ? 1 : 3; if (snm == 6) snm = channel_bitch(chan) ? 4 : 2; if (chan_washalfoptest(victim) || glob_washalfoptest(victim) || snm == 2) { if (!chan_washalfop(m)) { m->flags |= FAKEHALFOP; add_mode(chan, '-', 'h', who); } } else if (!(chan_halfop(victim) || (glob_halfop(victim) && !chan_dehalfop(victim)))) { if (snm == 1 || snm == 4 || (snm == 3 && !chan_washalfop(m))) { add_mode(chan, '-', 'h', who); m->flags |= FAKEHALFOP; } } else if (snm == 4 && !chan_washalfop(m)) { add_mode(chan, '-', 'h', who); m->flags |= FAKEHALFOP; } } } m->flags |= WASHALFOP; if (check_chan) recheck_channel(chan, 1); }