From 2dec8e767a70def4b9b04a96ae4f75e4d1013038 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 18 Jun 2012 05:04:30 -0400 Subject: Allow userless command sources --- modules/commands/bs_assign.cpp | 24 ++++---- modules/commands/bs_badwords.cpp | 24 ++++---- modules/commands/bs_bot.cpp | 13 ++-- modules/commands/bs_botlist.cpp | 3 +- modules/commands/bs_control.cpp | 11 ++-- modules/commands/bs_info.cpp | 21 +++---- modules/commands/bs_kick.cpp | 7 +-- modules/commands/bs_set_dontkickops.cpp | 12 ++-- modules/commands/bs_set_dontkickvoices.cpp | 12 ++-- modules/commands/bs_set_fantasy.cpp | 11 ++-- modules/commands/bs_set_greet.cpp | 11 ++-- modules/commands/bs_set_nobot.cpp | 13 ++-- modules/commands/bs_set_private.cpp | 3 +- modules/commands/cs_access.cpp | 87 +++++++++++--------------- modules/commands/cs_akick.cpp | 46 ++++++-------- modules/commands/cs_appendtopic.cpp | 9 ++- modules/commands/cs_ban.cpp | 14 ++--- modules/commands/cs_clearusers.cpp | 9 ++- modules/commands/cs_clone.cpp | 10 +-- modules/commands/cs_drop.cpp | 13 ++-- modules/commands/cs_enforce.cpp | 3 +- modules/commands/cs_entrymsg.cpp | 19 ++---- modules/commands/cs_fantasy_stats.cpp | 4 +- modules/commands/cs_fantasy_top.cpp | 4 +- modules/commands/cs_flags.cpp | 39 ++++++------ modules/commands/cs_getkey.cpp | 8 +-- modules/commands/cs_info.cpp | 34 +++++------ modules/commands/cs_invite.cpp | 20 +++--- modules/commands/cs_kick.cpp | 12 ++-- modules/commands/cs_list.cpp | 4 +- modules/commands/cs_log.cpp | 13 ++-- modules/commands/cs_mode.cpp | 39 ++++++------ modules/commands/cs_modes.cpp | 16 +++-- modules/commands/cs_register.cpp | 19 +++--- modules/commands/cs_saset_noexpire.cpp | 3 +- modules/commands/cs_seen.cpp | 13 ++-- modules/commands/cs_set_bantype.cpp | 3 +- modules/commands/cs_set_chanstats.cpp | 3 +- modules/commands/cs_set_description.cpp | 3 +- modules/commands/cs_set_founder.cpp | 9 ++- modules/commands/cs_set_keeptopic.cpp | 3 +- modules/commands/cs_set_misc.cpp | 2 +- modules/commands/cs_set_peace.cpp | 3 +- modules/commands/cs_set_persist.cpp | 3 +- modules/commands/cs_set_private.cpp | 3 +- modules/commands/cs_set_restricted.cpp | 3 +- modules/commands/cs_set_secure.cpp | 3 +- modules/commands/cs_set_securefounder.cpp | 3 +- modules/commands/cs_set_secureops.cpp | 3 +- modules/commands/cs_set_signkick.cpp | 3 +- modules/commands/cs_set_successor.cpp | 7 +-- modules/commands/cs_set_topiclock.cpp | 3 +- modules/commands/cs_suspend.cpp | 8 +-- modules/commands/cs_sync.cpp | 3 +- modules/commands/cs_tban.cpp | 2 +- modules/commands/cs_topic.cpp | 9 ++- modules/commands/cs_unban.cpp | 10 ++- modules/commands/cs_updown.cpp | 8 ++- modules/commands/cs_xop.cpp | 44 ++++++-------- modules/commands/gl_global.cpp | 5 +- modules/commands/help.cpp | 9 ++- modules/commands/hs_del.cpp | 6 +- modules/commands/hs_group.cpp | 9 ++- modules/commands/hs_off.cpp | 7 ++- modules/commands/hs_on.cpp | 7 ++- modules/commands/hs_request.cpp | 24 ++++---- modules/commands/hs_set.cpp | 10 ++- modules/commands/ms_cancel.cpp | 3 +- modules/commands/ms_check.cpp | 3 +- modules/commands/ms_del.cpp | 11 ++-- modules/commands/ms_ignore.cpp | 5 +- modules/commands/ms_info.cpp | 25 ++++---- modules/commands/ms_list.cpp | 7 +-- modules/commands/ms_read.cpp | 9 ++- modules/commands/ms_rsend.cpp | 7 +-- modules/commands/ms_send.cpp | 2 +- modules/commands/ms_sendall.cpp | 7 +-- modules/commands/ms_set.cpp | 22 +++---- modules/commands/ms_staff.cpp | 4 +- modules/commands/ns_access.cpp | 9 ++- modules/commands/ns_ajoin.cpp | 14 ++--- modules/commands/ns_alist.cpp | 5 +- modules/commands/ns_cert.cpp | 25 ++++---- modules/commands/ns_drop.cpp | 21 ++----- modules/commands/ns_getemail.cpp | 3 +- modules/commands/ns_getpass.cpp | 3 +- modules/commands/ns_ghost.cpp | 18 +++--- modules/commands/ns_group.cpp | 24 +++++--- modules/commands/ns_identify.cpp | 11 ++-- modules/commands/ns_info.cpp | 29 +++++---- modules/commands/ns_list.cpp | 5 +- modules/commands/ns_logout.cpp | 9 ++- modules/commands/ns_recover.cpp | 20 +++--- modules/commands/ns_register.cpp | 98 +++++++++++++++--------------- modules/commands/ns_release.cpp | 23 ++++--- modules/commands/ns_resetpass.cpp | 18 +++--- modules/commands/ns_saset.cpp | 3 +- modules/commands/ns_sendpass.cpp | 7 +-- modules/commands/ns_set.cpp | 11 ++-- modules/commands/ns_set_autoop.cpp | 2 +- modules/commands/ns_set_chanstats.cpp | 2 +- modules/commands/ns_set_display.cpp | 2 +- modules/commands/ns_set_email.cpp | 28 ++++----- modules/commands/ns_set_greet.cpp | 2 +- modules/commands/ns_set_hide.cpp | 2 +- modules/commands/ns_set_kill.cpp | 2 +- modules/commands/ns_set_language.cpp | 2 +- modules/commands/ns_set_message.cpp | 2 +- modules/commands/ns_set_misc.cpp | 2 +- modules/commands/ns_set_private.cpp | 2 +- modules/commands/ns_set_secure.cpp | 2 +- modules/commands/ns_status.cpp | 3 +- modules/commands/ns_suspend.cpp | 6 +- modules/commands/ns_update.cpp | 15 +++-- modules/commands/os_akill.cpp | 17 +++--- modules/commands/os_chankill.cpp | 7 +-- modules/commands/os_config.cpp | 4 +- modules/commands/os_defcon.cpp | 3 +- modules/commands/os_forbid.cpp | 8 +-- modules/commands/os_ignore.cpp | 2 +- modules/commands/os_jupe.cpp | 5 +- modules/commands/os_kick.cpp | 5 +- modules/commands/os_kill.cpp | 5 +- modules/commands/os_login.cpp | 26 +++++--- modules/commands/os_mode.cpp | 8 +-- modules/commands/os_module.cpp | 17 +++--- modules/commands/os_news.cpp | 2 +- modules/commands/os_noop.cpp | 7 +-- modules/commands/os_oline.cpp | 5 +- modules/commands/os_oper.cpp | 4 +- modules/commands/os_session.cpp | 5 +- modules/commands/os_set.cpp | 31 +++++----- modules/commands/os_shutdown.cpp | 9 +-- modules/commands/os_svsnick.cpp | 3 +- modules/commands/os_sxline.cpp | 30 ++++----- 135 files changed, 712 insertions(+), 847 deletions(-) (limited to 'modules/commands') diff --git a/modules/commands/bs_assign.cpp b/modules/commands/bs_assign.cpp index 5c1691047..874c40015 100644 --- a/modules/commands/bs_assign.cpp +++ b/modules/commands/bs_assign.cpp @@ -27,8 +27,6 @@ class CommandBSAssign : public Command const Anope::string &chan = params[0]; const Anope::string &nick = params[1]; - User *u = source.u; - if (readonly) { source.Reply(BOT_ASSIGN_READONLY); @@ -49,13 +47,14 @@ class CommandBSAssign : public Command return; } - if (ci->botflags.HasFlag(BS_NOBOT) || (!ci->AccessFor(u).HasPriv("ASSIGN") && !u->HasPriv("botserv/administration"))) + AccessGroup access = source.AccessFor(ci); + if (ci->botflags.HasFlag(BS_NOBOT) || (!access.HasPriv("ASSIGN") && !source.HasPriv("botserv/administration"))) { source.Reply(ACCESS_DENIED); return; } - if (bi->HasFlag(BI_PRIVATE) && !u->HasCommand("botserv/assign/private")) + if (bi->HasFlag(BI_PRIVATE) && !source.HasCommand("botserv/assign/private")) { source.Reply(ACCESS_DENIED); return; @@ -67,10 +66,10 @@ class CommandBSAssign : public Command return; } - bool override = !ci->AccessFor(u).HasPriv("ASSIGN"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "for " << bi->nick; + bool override = !access.HasPriv("ASSIGN"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << bi->nick; - bi->Assign(u, ci); + bi->Assign(source.GetUser(), ci); source.Reply(_("Bot \002%s\002 has been assigned to %s."), bi->nick.c_str(), ci->name.c_str()); } @@ -96,8 +95,6 @@ class CommandBSUnassign : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - User *u = source.u; - if (readonly) { source.Reply(BOT_ASSIGN_READONLY); @@ -111,7 +108,8 @@ class CommandBSUnassign : public Command return; } - if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("ASSIGN")) + AccessGroup access = source.AccessFor(ci); + if (!source.HasPriv("botserv/administration") && !access.HasPriv("ASSIGN")) { source.Reply(ACCESS_DENIED); return; @@ -129,10 +127,10 @@ class CommandBSUnassign : public Command return; } - bool override = !ci->AccessFor(u).HasPriv("ASSIGN"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "for " << ci->bi->nick; + bool override = !access.HasPriv("ASSIGN"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << ci->bi->nick; - ci->bi->UnAssign(u, ci); + ci->bi->UnAssign(source.GetUser(), ci); source.Reply(_("There is no bot assigned to %s anymore."), ci->name.c_str()); } diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp index eaf00d347..30de67d29 100644 --- a/modules/commands/bs_badwords.cpp +++ b/modules/commands/bs_badwords.cpp @@ -24,7 +24,7 @@ class BadwordsDelCallback : public NumberList public: BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), Deleted(0), override(false) { - if (!ci->AccessFor(source.u).HasPriv("BADWORDS") && source.u->HasPriv("botserv/administration")) + if (!source.AccessFor(ci).HasPriv("BADWORDS") && source.HasPriv("botserv/administration")) this->override = true; } @@ -43,7 +43,7 @@ class BadwordsDelCallback : public NumberList if (!Number || Number > ci->GetBadWordCount()) return; - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, c, ci) << "DEL " << ci->GetBadWord(Number - 1)->word; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "DEL " << ci->GetBadWord(Number - 1)->word; ++Deleted; ci->EraseBadWord(Number - 1); } @@ -54,8 +54,8 @@ class CommandBSBadwords : public Command private: void DoList(CommandSource &source, ChannelInfo *ci, const Anope::string &word) { - bool override = !ci->AccessFor(source.u).HasPriv("BADWORDS"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "LIST"; + bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "LIST"; ListFormatter list; list.addColumn("Number").addColumn("Word").addColumn("Type"); @@ -163,8 +163,8 @@ class CommandBSBadwords : public Command } } - bool override = !ci->AccessFor(source.u).HasPriv("BADWORDS"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "ADD " << realword; + bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "ADD " << realword; ci->AddBadWord(realword, bwtype); source.Reply(_("\002%s\002 added to %s bad words list."), realword.c_str(), ci->name.c_str()); @@ -199,8 +199,8 @@ class CommandBSBadwords : public Command return; } - bool override = !ci->AccessFor(source.u).HasPriv("BADWORDS"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "DEL " << badword->word; + bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "DEL " << badword->word; source.Reply(_("\002%s\002 deleted from %s bad words list."), badword->word.c_str(), ci->name.c_str()); @@ -212,8 +212,8 @@ class CommandBSBadwords : public Command void DoClear(CommandSource &source, ChannelInfo *ci) { - bool override = !ci->AccessFor(source.u).HasPriv("BADWORDS"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "CLEAR"; + bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "CLEAR"; ci->ClearBadWords(); source.Reply(_("Bad words list is now empty.")); @@ -233,7 +233,6 @@ class CommandBSBadwords : public Command { const Anope::string &cmd = params[1]; const Anope::string &word = params.size() > 2 ? params[2] : ""; - User *u = source.u; bool need_args = cmd.equals_ci("LIST") || cmd.equals_ci("CLEAR"); if (!need_args && word.empty()) @@ -249,8 +248,7 @@ class CommandBSBadwords : public Command return; } - - if (!ci->AccessFor(u).HasPriv("BADWORDS") && (!need_args || !u->HasPriv("botserv/administration"))) + if (!source.AccessFor(ci).HasPriv("BADWORDS") && (!need_args || !source.HasPriv("botserv/administration"))) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index b1f22909f..0b45ee71c 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -94,7 +94,7 @@ class CommandBSBot : public Command BotInfo *bi = new BotInfo(nick, user, host, real); - Log(LOG_ADMIN, source.u, this) << "ADD " << bi->GetMask() << " " << bi->realname; + Log(LOG_ADMIN, source, this) << "ADD " << bi->GetMask() << " " << bi->realname; source.Reply(_("%s!%s@%s (%s) added to the bot list."), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); @@ -253,7 +253,7 @@ class CommandBSBot : public Command } source.Reply(_("Bot \002%s\002 has been changed to %s!%s@%s (%s)"), oldnick.c_str(), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); - Log(LOG_ADMIN, source.u, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname; + Log(LOG_ADMIN, source, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname; FOREACH_MOD(I_OnBotChange, OnBotChange(bi)); return; @@ -284,7 +284,7 @@ class CommandBSBot : public Command FOREACH_MOD(I_OnBotDelete, OnBotDelete(bi)); - Log(LOG_ADMIN, source.u, this) << "DEL " << bi->nick; + Log(LOG_ADMIN, source, this) << "DEL " << bi->nick; source.Reply(_("Bot \002%s\002 has been deleted."), nick.c_str()); bi->destroy(); @@ -302,7 +302,6 @@ class CommandBSBot : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { const Anope::string &cmd = params[0]; - User *u = source.u; if (readonly) { @@ -313,7 +312,7 @@ class CommandBSBot : public Command if (cmd.equals_ci("ADD")) { // ADD nick user host real - 5 - if (!u->HasCommand("botserv/bot/add")) + if (!source.HasCommand("botserv/bot/add")) { source.Reply(ACCESS_DENIED); return; @@ -336,7 +335,7 @@ class CommandBSBot : public Command { // CHANGE oldn newn user host real - 6 // but only oldn and newn are required - if (!u->HasCommand("botserv/bot/change")) + if (!source.HasCommand("botserv/bot/change")) { source.Reply(ACCESS_DENIED); return; @@ -353,7 +352,7 @@ class CommandBSBot : public Command else if (cmd.equals_ci("DEL")) { // DEL nick - if (!u->HasCommand("botserv/bot/del")) + if (!source.HasCommand("botserv/bot/del")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/bs_botlist.cpp b/modules/commands/bs_botlist.cpp index 9fd8b81f7..176040b10 100644 --- a/modules/commands/bs_botlist.cpp +++ b/modules/commands/bs_botlist.cpp @@ -24,7 +24,6 @@ class CommandBSBotList : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - User *u = source.u; unsigned count = 0; ListFormatter list; @@ -34,7 +33,7 @@ class CommandBSBotList : public Command { BotInfo *bi = it->second; - if (u->HasCommand("botserv/botlist") || !bi->HasFlag(BI_PRIVATE)) + if (source.HasCommand("botserv/botlist") || !bi->HasFlag(BI_PRIVATE)) { ++count; ListFormatter::ListEntry entry; diff --git a/modules/commands/bs_control.cpp b/modules/commands/bs_control.cpp index 6ca435b37..6957d0a78 100644 --- a/modules/commands/bs_control.cpp +++ b/modules/commands/bs_control.cpp @@ -26,8 +26,6 @@ class CommandBSSay : public Command { const Anope::string &text = params[1]; - User *u = source.u; - ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -35,7 +33,7 @@ class CommandBSSay : public Command return; } - if (!ci->AccessFor(u).HasPriv("SAY")) + if (!source.AccessFor(ci).HasPriv("SAY")) { source.Reply(ACCESS_DENIED); return; @@ -63,7 +61,7 @@ class CommandBSSay : public Command ci->bi->lastmsg = Anope::CurTime; // XXX need a way to find if someone is overriding this - Log(LOG_COMMAND, u, this, ci) << text; + Log(LOG_COMMAND, source, this, ci) << text; return; } @@ -88,7 +86,6 @@ class CommandBSAct : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - User *u = source.u; Anope::string message = params[1]; ChannelInfo *ci = cs_findchan(params[0]); @@ -98,7 +95,7 @@ class CommandBSAct : public Command return; } - if (!ci->AccessFor(u).HasPriv("SAY")) + if (!source.AccessFor(ci).HasPriv("SAY")) { source.Reply(ACCESS_DENIED); return; @@ -124,7 +121,7 @@ class CommandBSAct : public Command ci->bi->lastmsg = Anope::CurTime; // XXX Need to be able to find if someone is overriding this. - Log(LOG_COMMAND, u, this, ci) << message; + Log(LOG_COMMAND, source, this, ci) << message; return; } diff --git a/modules/commands/bs_info.cpp b/modules/commands/bs_info.cpp index 251bd84df..d5b2693ad 100644 --- a/modules/commands/bs_info.cpp +++ b/modules/commands/bs_info.cpp @@ -59,10 +59,9 @@ class CommandBSInfo : public Command { const Anope::string &query = params[0]; - User *u = source.u; const BotInfo *bi = findbot(query); ChannelInfo *ci; - InfoFormatter info(u); + InfoFormatter info(source.nc); if (bi) { @@ -79,7 +78,7 @@ class CommandBSInfo : public Command for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); - if (u->HasPriv("botserv/administration")) + if (source.HasPriv("botserv/administration")) { std::vector buf; this->send_bot_channels(buf, bi); @@ -90,7 +89,7 @@ class CommandBSInfo : public Command } else if ((ci = cs_findchan(query))) { - if (!ci->AccessFor(u).HasPriv("FOUNDER") && !u->HasPriv("botserv/administration")) + if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("botserv/administration")) { source.Reply(ACCESS_DENIED); return; @@ -99,8 +98,8 @@ class CommandBSInfo : public Command source.Reply(CHAN_INFO_HEADER, ci->name.c_str()); info[_("Bot nick")] = ci->bi ? ci->bi->nick : "not assigned yet"; - Anope::string enabled = translate(u, _("Enabled")); - Anope::string disabled = translate(u, _("Disabled")); + Anope::string enabled = translate(source.nc, _("Enabled")); + Anope::string disabled = translate(source.nc, _("Disabled")); if (ci->botflags.HasFlag(BS_KICK_BADWORDS)) { @@ -203,11 +202,11 @@ class CommandBSInfo : public Command info[_("AMSG kicker")] = disabled; Anope::string flags; - CheckOptStr(flags, BS_DONTKICKOPS, _("Ops protection"), ci->botflags, u->Account()); - CheckOptStr(flags, BS_DONTKICKVOICES, _("Voices protection"), ci->botflags, u->Account()); - CheckOptStr(flags, BS_FANTASY, _("Fantasy"), ci->botflags, u->Account()); - CheckOptStr(flags, BS_GREET, _("Greet"), ci->botflags, u->Account()); - CheckOptStr(flags, BS_NOBOT, _("No bot"), ci->botflags, u->Account()); + CheckOptStr(flags, BS_DONTKICKOPS, _("Ops protection"), ci->botflags, source.nc); + CheckOptStr(flags, BS_DONTKICKVOICES, _("Voices protection"), ci->botflags, source.nc); + CheckOptStr(flags, BS_FANTASY, _("Fantasy"), ci->botflags, source.nc); + CheckOptStr(flags, BS_GREET, _("Greet"), ci->botflags, source.nc); + CheckOptStr(flags, BS_NOBOT, _("No bot"), ci->botflags, source.nc); info[_("Options")] = flags.empty() ? _("None") : flags; diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index 819c5af74..32cfbe952 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -30,7 +30,6 @@ class CommandBSKick : public Command const Anope::string &value = params[2]; const Anope::string &ttb = params.size() > 3 ? params[3] : ""; - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (readonly) @@ -41,14 +40,14 @@ class CommandBSKick : public Command this->OnSyntaxError(source, ""); else if (!value.equals_ci("ON") && !value.equals_ci("OFF")) this->OnSyntaxError(source, ""); - else if (!ci->AccessFor(u).HasPriv("SET") && !u->HasPriv("botserv/administration")) + else if (!source.AccessFor(ci).HasPriv("SET") && !source.HasPriv("botserv/administration")) source.Reply(ACCESS_DENIED); else if (!ci->bi) source.Reply(BOT_NOT_ASSIGNED); else { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << option << " " << value; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << option << " " << value; if (option.equals_ci("BADWORDS")) { diff --git a/modules/commands/bs_set_dontkickops.cpp b/modules/commands/bs_set_dontkickops.cpp index f05cb1a2c..598dfdcea 100644 --- a/modules/commands/bs_set_dontkickops.cpp +++ b/modules/commands/bs_set_dontkickops.cpp @@ -24,7 +24,6 @@ class CommandBSSetDontKickOps : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,8 @@ class CommandBSSetDontKickOps : public Command return; } - if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET")) + AccessGroup access = source.AccessFor(ci); + if (!source.HasPriv("botserv/administration") && !access.HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; @@ -46,16 +46,16 @@ class CommandBSSetDontKickOps : public Command if (params[1].equals_ci("ON")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to enable dontkickops"; + bool override = !access.HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable dontkickops"; ci->botflags.SetFlag(BS_DONTKICKOPS); source.Reply(_("Bot \002won't kick ops\002 on channel %s."), ci->name.c_str()); } else if (params[1].equals_ci("OFF")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable dontkickops"; + bool override = !access.HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable dontkickops"; ci->botflags.UnsetFlag(BS_DONTKICKOPS); source.Reply(_("Bot \002will kick ops\002 on channel %s."), ci->name.c_str()); diff --git a/modules/commands/bs_set_dontkickvoices.cpp b/modules/commands/bs_set_dontkickvoices.cpp index 2b477bbfe..05453296b 100644 --- a/modules/commands/bs_set_dontkickvoices.cpp +++ b/modules/commands/bs_set_dontkickvoices.cpp @@ -24,7 +24,6 @@ class CommandBSSetDontKickVoices : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -32,7 +31,8 @@ class CommandBSSetDontKickVoices : public Command return; } - if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET")) + AccessGroup access = source.AccessFor(ci); + if (!source.HasPriv("botserv/administration") && !access.HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; @@ -46,16 +46,16 @@ class CommandBSSetDontKickVoices : public Command if (params[1].equals_ci("ON")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to enable dontkickvoices"; + bool override = !access.HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable dontkickvoices"; ci->botflags.SetFlag(BS_DONTKICKVOICES); source.Reply(_("Bot \002won't kick voices\002 on channel %s."), ci->name.c_str()); } else if (params[1].equals_ci("OFF")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable dontkickvoices"; + bool override = !access.HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable dontkickvoices"; ci->botflags.UnsetFlag(BS_DONTKICKVOICES); source.Reply(_("Bot \002will kick voices\002 on channel %s."), ci->name.c_str()); diff --git a/modules/commands/bs_set_fantasy.cpp b/modules/commands/bs_set_fantasy.cpp index 06df20fbc..03bd40c70 100644 --- a/modules/commands/bs_set_fantasy.cpp +++ b/modules/commands/bs_set_fantasy.cpp @@ -24,7 +24,6 @@ class CommandBSSetFantasy : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); const Anope::string &value = params[1]; @@ -34,7 +33,7 @@ class CommandBSSetFantasy : public Command return; } - if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET")) + if (!source.HasPriv("botserv/administration") && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; @@ -48,16 +47,16 @@ class CommandBSSetFantasy : public Command if (value.equals_ci("ON")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to enable fantasy"; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable fantasy"; ci->botflags.SetFlag(BS_FANTASY); source.Reply(_("Fantasy mode is now \002on\002 on channel %s."), ci->name.c_str()); } else if (value.equals_ci("OFF")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable fantasy"; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable fantasy"; ci->botflags.UnsetFlag(BS_FANTASY); source.Reply(_("Fantasy mode is now \002off\002 on channel %s."), ci->name.c_str()); diff --git a/modules/commands/bs_set_greet.cpp b/modules/commands/bs_set_greet.cpp index 806f62f29..b74b0e5dd 100644 --- a/modules/commands/bs_set_greet.cpp +++ b/modules/commands/bs_set_greet.cpp @@ -24,7 +24,6 @@ class CommandBSSetGreet : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); const Anope::string &value = params[1]; @@ -34,7 +33,7 @@ class CommandBSSetGreet : public Command return; } - if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET")) + if (!source.HasPriv("botserv/administration") && !source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; @@ -48,16 +47,16 @@ class CommandBSSetGreet : public Command if (value.equals_ci("ON")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to enable greets"; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable greets"; ci->botflags.SetFlag(BS_GREET); source.Reply(_("Greet mode is now \002on\002 on channel %s."), ci->name.c_str()); } else if (value.equals_ci("OFF")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable greets"; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable greets"; ci->botflags.UnsetFlag(BS_GREET); source.Reply(_("Greet mode is now \002off\002 on channel %s."), ci->name.c_str()); diff --git a/modules/commands/bs_set_nobot.cpp b/modules/commands/bs_set_nobot.cpp index 75c3a8286..246864953 100644 --- a/modules/commands/bs_set_nobot.cpp +++ b/modules/commands/bs_set_nobot.cpp @@ -24,7 +24,6 @@ class CommandBSSetNoBot : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); const Anope::string &value = params[1]; @@ -34,7 +33,7 @@ class CommandBSSetNoBot : public Command return; } - if (!u->HasCommand("botserv/set/nobot")) + if (!source.HasCommand("botserv/set/nobot")) { source.Reply(ACCESS_DENIED); return; @@ -42,18 +41,18 @@ class CommandBSSetNoBot : public Command if (value.equals_ci("ON")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to enable nobot"; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_ADMIN : LOG_COMMAND, source, this, ci) << "to enable nobot"; ci->botflags.SetFlag(BS_NOBOT); if (ci->bi) - ci->bi->UnAssign(u, ci); + ci->bi->UnAssign(source.GetUser(), ci); source.Reply(_("No Bot mode is now \002on\002 on channel %s."), ci->name.c_str()); } else if (value.equals_ci("OFF")) { - bool override = !ci->AccessFor(u).HasPriv("SET"); - Log(override ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << "to disable nobot"; + bool override = !source.AccessFor(ci).HasPriv("SET"); + Log(override ? LOG_ADMIN : LOG_COMMAND, source, this, ci) << "to disable nobot"; ci->botflags.UnsetFlag(BS_NOBOT); source.Reply(_("No Bot mode is now \002off\002 on channel %s."), ci->name.c_str()); diff --git a/modules/commands/bs_set_private.cpp b/modules/commands/bs_set_private.cpp index 5a1be8d45..0cd055d00 100644 --- a/modules/commands/bs_set_private.cpp +++ b/modules/commands/bs_set_private.cpp @@ -24,7 +24,6 @@ class CommandBSSetPrivate : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - User *u = source.u; BotInfo *bi = findbot(params[0]); const Anope::string &value = params[1]; @@ -34,7 +33,7 @@ class CommandBSSetPrivate : public Command return; } - if (!u->HasCommand("botserv/set/private")) + if (!source.HasCommand("botserv/set/private")) { source.Reply(ACCESS_DENIED); return; diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index ff0ee067e..c482e3c66 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -90,8 +90,6 @@ class CommandCSAccess : public Command { void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector ¶ms) { - User *u = source.u; - Anope::string mask = params[2]; int level = ACCESS_INVALID; @@ -112,7 +110,7 @@ class CommandCSAccess : public Command return; } - AccessGroup u_access = ci->AccessFor(u); + AccessGroup u_access = source.AccessFor(ci); const ChanAccess *highest = u_access.Highest(); AccessChanAccess tmp_access(NULL); @@ -123,7 +121,7 @@ class CommandCSAccess : public Command if ((!highest || *highest <= tmp_access) && !u_access.Founder) { - if (u->HasPriv("chanserv/access/modify")) + if (source.HasPriv("chanserv/access/modify")) override = true; else { @@ -150,7 +148,7 @@ class CommandCSAccess : public Command if (mask.equals_ci(access->mask)) { /* Don't allow lowering from a level >= u_level */ - if ((!highest || *access >= *highest) && !u_access.Founder && !u->HasPriv("chanserv/access/modify")) + if ((!highest || *access >= *highest) && !u_access.Founder && !source.HasPriv("chanserv/access/modify")) { source.Reply(ACCESS_DENIED); return; @@ -172,15 +170,15 @@ class CommandCSAccess : public Command AccessChanAccess *access = anope_dynamic_static_cast(provider->Create()); access->ci = ci; access->mask = mask; - access->creator = u->nick; + access->creator = source.GetNick(); access->level = level; access->last_seen = 0; access->created = Anope::CurTime; ci->AddAccess(access); - FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, u, access)); + FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, source, access)); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to add " << mask << " with level " << level; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << " with level " << level; source.Reply(_("\002%s\002 added to %s access list at level \002%d\002."), access->mask.c_str(), ci->name.c_str(), level); return; @@ -188,8 +186,6 @@ class CommandCSAccess : public Command void DoDel(CommandSource &source, ChannelInfo *ci, const std::vector ¶ms) { - User *u = source.u; - const Anope::string &mask = params[2]; if (!ci->GetAccessCount()) @@ -208,7 +204,7 @@ class CommandCSAccess : public Command public: AccessDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), Deleted(0), Denied(false), override(false) { - if (!ci->AccessFor(source.u).HasPriv("ACCESS_CHANGE") && source.u->HasPriv("chanserv/access/modify")) + if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/access/modify")) this->override = true; } @@ -220,7 +216,7 @@ class CommandCSAccess : public Command source.Reply(_("No matching entries on %s access list."), ci->name.c_str()); else { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, c, ci) << "to delete " << Nicks; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << Nicks; if (Deleted == 1) source.Reply(_("Deleted 1 entry from %s access list."), ci->name.c_str()); @@ -234,14 +230,12 @@ class CommandCSAccess : public Command if (!Number || Number > ci->GetAccessCount()) return; - User *user = source.u; - ChanAccess *access = ci->GetAccess(Number - 1); - AccessGroup u_access = ci->AccessFor(user); + AccessGroup u_access = source.AccessFor(ci); const ChanAccess *u_highest = u_access.Highest(); - if ((!u_highest || *u_highest <= *access) && !u_access.Founder && !this->override && !access->mask.equals_ci(user->Account()->display)) + if ((!u_highest || *u_highest <= *access) && !u_access.Founder && !this->override && !access->mask.equals_ci(source.nc->display)) { Denied = true; return; @@ -253,7 +247,7 @@ class CommandCSAccess : public Command else Nicks = access->mask; - FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, user, access)); + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, access)); ci->EraseAccess(Number - 1); } @@ -263,7 +257,7 @@ class CommandCSAccess : public Command } else { - AccessGroup u_access = ci->AccessFor(u); + AccessGroup u_access = source.AccessFor(ci); const ChanAccess *highest = u_access.Highest(); for (unsigned i = ci->GetAccessCount(); i > 0; --i) @@ -271,15 +265,15 @@ class CommandCSAccess : public Command ChanAccess *access = ci->GetAccess(i - 1); if (mask.equals_ci(access->mask)) { - if (!access->mask.equals_ci(u->Account()->display) && !u_access.Founder && (!highest || *highest <= *access) && !u->HasPriv("chanserv/access/modify")) + if (!access->mask.equals_ci(source.nc->display) && !u_access.Founder && (!highest || *highest <= *access) && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); else { source.Reply(_("\002%s\002 deleted from %s access list."), access->mask.c_str(), ci->name.c_str()); - bool override = !u_access.Founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->mask.equals_ci(u->Account()->display); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to delete " << access->mask; + bool override = !u_access.Founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->mask.equals_ci(source.nc->display); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->mask; - FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, access)); + FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, access)); ci->EraseAccess(access); } return; @@ -420,20 +414,18 @@ class CommandCSAccess : public Command void DoClear(CommandSource &source, ChannelInfo *ci) { - User *u = source.u; - - if (!IsFounder(u, ci) && !u->HasPriv("chanserv/access/modify")) + if (!source.IsFounder(ci) && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); else { - FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, u)); + FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, source)); ci->ClearAccess(); source.Reply(_("Channel %s access list has been cleared."), ci->name.c_str()); - bool override = !IsFounder(u, ci); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to clear the access list"; + bool override = !source.IsFounder(ci); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the access list"; } return; @@ -456,7 +448,6 @@ class CommandCSAccess : public Command const Anope::string &nick = params.size() > 2 ? params[2] : ""; const Anope::string &s = params.size() > 3 ? params[3] : ""; - User *u = source.u; ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -469,16 +460,16 @@ class CommandCSAccess : public Command bool is_del = cmd.equals_ci("DEL"); bool has_access = false; - if (u->HasPriv("chanserv/access/modify")) + if (source.HasPriv("chanserv/access/modify")) has_access = true; - else if (is_list && ci->AccessFor(u).HasPriv("ACCESS_LIST")) + else if (is_list && source.AccessFor(ci).HasPriv("ACCESS_LIST")) has_access = true; - else if (ci->AccessFor(u).HasPriv("ACCESS_CHANGE")) + else if (source.AccessFor(ci).HasPriv("ACCESS_CHANGE")) has_access = true; else if (is_del) { const NickAlias *na = findnick(nick); - if (na && na->nc == u->Account()) + if (na && na->nc == source.nc) has_access = true; } @@ -575,8 +566,6 @@ class CommandCSLevels : public Command { void DoSet(CommandSource &source, ChannelInfo *ci, const std::vector ¶ms) { - User *u = source.u; - const Anope::string &what = params[2]; const Anope::string &lev = params[3]; @@ -607,10 +596,10 @@ class CommandCSLevels : public Command else { ci->SetLevel(p->name, level); - FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, p->name, level)); + FOREACH_MOD(I_OnLevelChange, OnLevelChange(source, ci, p->name, level)); - bool override = !ci->AccessFor(u).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to set " << p->name << " to level " << level; + bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to set " << p->name << " to level " << level; if (level == ACCESS_FOUNDER) source.Reply(_("Level for %s on channel %s changed to founder only."), p->name.c_str(), ci->name.c_str()); @@ -622,8 +611,6 @@ class CommandCSLevels : public Command void DoDisable(CommandSource &source, ChannelInfo *ci, const std::vector ¶ms) { - User *u = source.u; - const Anope::string &what = params[2]; /* Don't allow disabling of the founder level. It would be hard to change it back if you dont have access to use this command */ @@ -633,10 +620,10 @@ class CommandCSLevels : public Command if (p != NULL) { ci->SetLevel(p->name, ACCESS_INVALID); - FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, p->name, ACCESS_INVALID)); + FOREACH_MOD(I_OnLevelChange, OnLevelChange(source, ci, p->name, ACCESS_INVALID)); - bool override = !ci->AccessFor(u).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable " << p->name; + bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable " << p->name; source.Reply(_("\002%s\002 disabled on channel %s."), p->name.c_str(), ci->name.c_str()); return; @@ -684,13 +671,11 @@ class CommandCSLevels : public Command void DoReset(CommandSource &source, ChannelInfo *ci) { - User *u = source.u; - reset_levels(ci); - FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, "ALL", 0)); + FOREACH_MOD(I_OnLevelChange, OnLevelChange(source, ci, "ALL", 0)); - bool override = !ci->AccessFor(u).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to reset all levels"; + bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to reset all levels"; source.Reply(_("Access levels for \002%s\002 reset to defaults."), ci->name.c_str()); return; @@ -712,8 +697,6 @@ class CommandCSLevels : public Command const Anope::string &what = params.size() > 2 ? params[2] : ""; const Anope::string &s = params.size() > 3 ? params[3] : ""; - User *u = source.u; - ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -726,7 +709,7 @@ class CommandCSLevels : public Command */ if (cmd.equals_ci("SET") ? s.empty() : (cmd.substr(0, 3).equals_ci("DIS") ? (what.empty() || !s.empty()) : !what.empty())) this->OnSyntaxError(source, cmd); - else if (!ci->AccessFor(u).HasPriv("FOUNDER") && !u->HasPriv("chanserv/access/modify")) + else if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); else if (cmd.equals_ci("SET")) this->DoSet(source, ci, params); @@ -757,7 +740,7 @@ class CommandCSLevels : public Command const Privilege &p = privs[i]; ListFormatter::ListEntry entry; entry["Name"] = p.name; - entry["Description"] = translate(source.u, p.desc.c_str()); + entry["Description"] = translate(source.nc, p.desc.c_str()); list.addEntry(entry); } diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index 107f97584..1ff67215c 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -50,8 +50,6 @@ class CommandCSAKick : public Command { void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector ¶ms) { - User *u = source.u; - Anope::string mask = params[2]; Anope::string reason = params.size() > 3 ? params[3] : ""; const NickAlias *na = findnick(mask); @@ -86,7 +84,7 @@ class CommandCSAKick : public Command * or whether the mask matches a user with higher/equal access - Viper */ if (ci->HasFlag(CI_PEACE) && nc) { - AccessGroup nc_access = ci->AccessFor(nc), u_access = ci->AccessFor(u); + AccessGroup nc_access = ci->AccessFor(nc), u_access = source.AccessFor(ci); if (nc == ci->GetFounder() || nc_access >= u_access) { source.Reply(ACCESS_DENIED); @@ -101,7 +99,7 @@ class CommandCSAKick : public Command { User *u2 = it->second; - AccessGroup nc_access = ci->AccessFor(nc), u_access = ci->AccessFor(u); + AccessGroup nc_access = ci->AccessFor(nc), u_access = source.AccessFor(ci); Entry entry_mask(CMODE_BEGIN, mask); if ((ci->AccessFor(u2).HasPriv("FOUNDER") || nc_access >= u_access) && entry_mask.Matches(u2)) @@ -117,7 +115,7 @@ class CommandCSAKick : public Command { na = it->second; - AccessGroup nc_access = ci->AccessFor(na->nc), u_access = ci->AccessFor(u); + AccessGroup nc_access = ci->AccessFor(na->nc), u_access = source.AccessFor(ci); if (na->nc && (na->nc == ci->GetFounder() || nc_access >= u_access)) { Anope::string buf = na->nick + "!" + na->last_usermask; @@ -147,14 +145,14 @@ class CommandCSAKick : public Command } if (nc) - akick = ci->AddAkick(u->nick, nc, reason); + akick = ci->AddAkick(source.GetNick(), nc, reason); else - akick = ci->AddAkick(u->nick, mask, reason); + akick = ci->AddAkick(source.GetNick(), mask, reason); - bool override = !ci->AccessFor(u).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to add " << mask << (reason == "" ? "" : ": ") << reason; + bool override = !source.AccessFor(ci).HasPriv("AKICK"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << (reason == "" ? "" : ": ") << reason; - FOREACH_MOD(I_OnAkickAdd, OnAkickAdd(u, ci, akick)); + FOREACH_MOD(I_OnAkickAdd, OnAkickAdd(source, ci, akick)); source.Reply(_("\002%s\002 added to %s autokick list."), mask.c_str(), ci->name.c_str()); @@ -163,8 +161,6 @@ class CommandCSAKick : public Command void DoDel(CommandSource &source, ChannelInfo *ci, const std::vector ¶ms) { - User *u = source.u; - const Anope::string &mask = params[2]; unsigned i, end; @@ -190,8 +186,8 @@ class CommandCSAKick : public Command ~AkickDelCallback() { - bool override = !ci->AccessFor(source.u).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, c, ci) << "to delete " << Deleted << (Deleted == 1 ? " entry" : " entries"); + bool override = !source.AccessFor(ci).HasPriv("AKICK"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << Deleted << (Deleted == 1 ? " entry" : " entries"); if (!Deleted) source.Reply(_("No matching entries on %s autokick list."), ci->name.c_str()); @@ -206,7 +202,7 @@ class CommandCSAKick : public Command if (!Number || Number > ci->GetAkickCount()) return; - FOREACH_MOD(I_OnAkickDel, OnAkickDel(source.u, ci, ci->GetAkick(Number - 1))); + FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(Number - 1))); ++Deleted; ci->EraseAkick(Number - 1); @@ -234,10 +230,10 @@ class CommandCSAKick : public Command return; } - bool override = !ci->AccessFor(u).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to delete " << mask; + bool override = !source.AccessFor(ci).HasPriv("AKICK"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask; - FOREACH_MOD(I_OnAkickDel, OnAkickDel(u, ci, ci->GetAkick(i))); + FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(i))); ci->EraseAkick(i); @@ -370,7 +366,6 @@ class CommandCSAKick : public Command void DoEnforce(CommandSource &source, ChannelInfo *ci) { - User *u = source.u; Channel *c = ci->c; int count = 0; @@ -388,17 +383,16 @@ class CommandCSAKick : public Command ++count; } - bool override = !ci->AccessFor(u).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ENFORCE, affects " << count << " users"; + bool override = !source.AccessFor(ci).HasPriv("AKICK"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "ENFORCE, affects " << count << " users"; source.Reply(_("AKICK ENFORCE for \002%s\002 complete; \002%d\002 users were affected."), ci->name.c_str(), count); } void DoClear(CommandSource &source, ChannelInfo *ci) { - User *u = source.u; - bool override = !ci->AccessFor(u).HasPriv("AKICK"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to clear the akick list"; + bool override = !source.AccessFor(ci).HasPriv("AKICK"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the akick list"; ci->ClearAkick(); source.Reply(_("Channel %s akick list has been cleared."), ci->name.c_str()); @@ -422,8 +416,6 @@ class CommandCSAKick : public Command Anope::string cmd = params[1]; Anope::string mask = params.size() > 2 ? params[2] : ""; - User *u = source.u; - ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -433,7 +425,7 @@ class CommandCSAKick : public Command if (mask.empty() && (cmd.equals_ci("ADD") || cmd.equals_ci("DEL"))) this->OnSyntaxError(source, cmd); - else if (!ci->AccessFor(u).HasPriv("AKICK") && !u->HasPriv("chanserv/access/modify")) + else if (!source.AccessFor(ci).HasPriv("AKICK") && !source.HasPriv("chanserv/access/modify")) source.Reply(ACCESS_DENIED); else if (!cmd.equals_ci("LIST") && !cmd.equals_ci("VIEW") && !cmd.equals_ci("ENFORCE") && readonly) source.Reply(_("Sorry, channel autokick list modification is temporarily disabled.")); diff --git a/modules/commands/cs_appendtopic.cpp b/modules/commands/cs_appendtopic.cpp index fe1633b8a..70cde7b7b 100644 --- a/modules/commands/cs_appendtopic.cpp +++ b/modules/commands/cs_appendtopic.cpp @@ -52,14 +52,13 @@ class CommandCSAppendTopic : public Command { const Anope::string &newtopic = params[1]; - User *u = source.u; Channel *c = findchan(params[0]);; if (!c) source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); else if (!c->ci) source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str()); - else if (!c->ci->AccessFor(u).HasPriv("TOPIC") && !u->HasCommand("chanserv/topic")) + else if (!source.AccessFor(c->ci).HasPriv("TOPIC") && !source.HasCommand("chanserv/topic")) source.Reply(ACCESS_DENIED); else { @@ -74,12 +73,12 @@ class CommandCSAppendTopic : public Command bool has_topiclock = c->ci->HasFlag(CI_TOPICLOCK); c->ci->UnsetFlag(CI_TOPICLOCK); - c->ChangeTopic(u->nick, topic, Anope::CurTime); + c->ChangeTopic(source.GetNick(), topic, Anope::CurTime); if (has_topiclock) c->ci->SetFlag(CI_TOPICLOCK); - bool override = !c->ci->AccessFor(u).HasPriv("TOPIC"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, c->ci) << "to append: " << topic; + bool override = !source.AccessFor(c->ci).HasPriv("TOPIC"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to append: " << topic; } return; } diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp index 867d654c5..063d98ab5 100644 --- a/modules/commands/cs_ban.cpp +++ b/modules/commands/cs_ban.cpp @@ -36,11 +36,11 @@ class CommandCSBan : public Command return; } - User *u = source.u; Channel *c = ci->c; + User *u = source.GetUser(); User *u2 = finduser(target); - AccessGroup u_access = ci->AccessFor(u); + AccessGroup u_access = source.AccessFor(ci); if (!c) source.Reply(CHAN_X_NOT_IN_USE, chan.c_str()); @@ -66,7 +66,7 @@ class CommandCSBan : public Command get_idealban(ci, u2, mask); // XXX need a way to detect if someone is overriding - Log(LOG_COMMAND, u, this, ci) << "for " << mask; + Log(LOG_COMMAND, source, this, ci) << "for " << mask; c->SetMode(NULL, CMODE_BAN, mask); @@ -74,15 +74,15 @@ class CommandCSBan : public Command if (!c->FindUser(u2)) return; - if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !ci->AccessFor(u).HasPriv("SIGNKICK"))) - c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), u->nick.c_str()); + if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !source.AccessFor(ci).HasPriv("SIGNKICK"))) + c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), source.GetNick().c_str()); else c->Kick(ci->WhoSends(), u2, "%s", reason.c_str()); } } else if (u_access.HasPriv("FOUNDER")) { - Log(LOG_COMMAND, u, this, ci) << "for " << target; + Log(LOG_COMMAND, source, this, ci) << "for " << target; c->SetMode(NULL, CMODE_BAN, target); @@ -106,7 +106,7 @@ class CommandCSBan : public Command ++kicked; if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !u_access.HasPriv("SIGNKICK"))) - c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s) (%s)", reason.c_str(), target.c_str(), u->nick.c_str()); + c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s) (%s)", reason.c_str(), target.c_str(), source.GetNick().c_str()); else c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s)", reason.c_str(), target.c_str()); } diff --git a/modules/commands/cs_clearusers.cpp b/modules/commands/cs_clearusers.cpp index 58de57f5a..1c26fe382 100644 --- a/modules/commands/cs_clearusers.cpp +++ b/modules/commands/cs_clearusers.cpp @@ -26,7 +26,6 @@ class CommandCSClearUsers : public Command { const Anope::string &chan = params[0]; - User *u = source.u; Channel *c = findchan(chan); Anope::string modebuf; @@ -40,13 +39,13 @@ class CommandCSClearUsers : public Command source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str()); return; } - else if (!c->ci->AccessFor(u).HasPriv("FOUNDER") && !u->HasCommand("chanserv/clearusers")) + else if (!source.AccessFor(c->ci).HasPriv("FOUNDER") && !source.HasCommand("chanserv/clearusers")) { source.Reply(ACCESS_DENIED); return; } - Anope::string buf = "CLEARUSERS command from " + u->nick + " (" + u->Account()->display + ")"; + Anope::string buf = "CLEARUSERS command from " + source.GetNick() + " (" + source.nc->display + ")"; for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) { @@ -55,8 +54,8 @@ class CommandCSClearUsers : public Command c->Kick(NULL, uc->user, "%s", buf.c_str()); } - bool override = !c->ci->AccessFor(u).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, c->ci); + bool override = !source.AccessFor(c->ci).HasPriv("FOUNDER"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci); source.Reply(_("All users have been kicked from \002%s\002."), chan.c_str()); diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp index be6907b81..99c635c8f 100644 --- a/modules/commands/cs_clone.cpp +++ b/modules/commands/cs_clone.cpp @@ -28,7 +28,7 @@ public: const Anope::string &target = params[1]; Anope::string what = params.size() > 2 ? params[2] : ""; - User *u = source.u; + User *u = source.GetUser(); ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -36,7 +36,7 @@ public: return; } - if (!ci->AccessFor(u).HasPriv("SET")) + if (!source.AccessFor(ci).HasPriv("SET")) { source.Reply(ACCESS_DENIED); return; @@ -48,7 +48,7 @@ public: source.Reply(CHAN_X_NOT_REGISTERED, target.c_str()); return; } - if (!IsFounder(u, ci) || !IsFounder(u, target_ci)) + if (!source.IsFounder(ci) || !source.IsFounder(target_ci)) { source.Reply(ACCESS_DENIED); return; @@ -71,7 +71,7 @@ public: target_ci->c->CheckModes(); ChannelMode *cm; - if (u->FindChannel(target_ci->c) != NULL) + if (u && u->FindChannel(target_ci->c) != NULL) { /* On most ircds you do not receive the admin/owner mode till its registered */ if ((cm = ModeManager::FindChannelModeByName(CMODE_OWNER))) @@ -155,7 +155,7 @@ public: return; } - Log(LOG_COMMAND, u, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->name; + Log(LOG_COMMAND, source, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->name; return; } diff --git a/modules/commands/cs_drop.cpp b/modules/commands/cs_drop.cpp index fb9da23b8..cf8c5040e 100644 --- a/modules/commands/cs_drop.cpp +++ b/modules/commands/cs_drop.cpp @@ -26,8 +26,6 @@ class CommandCSDrop : public Command { const Anope::string &chan = params[0]; - User *u = source.u; - if (readonly) { source.Reply(_("Sorry, channel de-registration is temporarily disabled.")); // XXX: READ_ONLY_MODE? @@ -41,20 +39,20 @@ class CommandCSDrop : public Command return; } - if (ci->HasFlag(CI_SUSPENDED) && !u->HasCommand("chanserv/drop")) + if (ci->HasFlag(CI_SUSPENDED) && !source.HasCommand("chanserv/drop")) { source.Reply(CHAN_X_SUSPENDED, chan.c_str()); return; } - if ((ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->AccessFor(u).HasPriv("FOUNDER")) && !u->HasCommand("chanserv/drop")) + if ((ci->HasFlag(CI_SECUREFOUNDER) ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && !source.HasCommand("chanserv/drop")) { source.Reply(ACCESS_DENIED); return; } - bool override = (ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->AccessFor(u).HasPriv("FOUNDER")); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "(founder was: " << (ci->GetFounder() ? ci->GetFounder()->display : "none") << ")"; + bool override = (ci->HasFlag(CI_SECUREFOUNDER) ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "(founder was: " << (ci->GetFounder() ? ci->GetFounder()->display : "none") << ")"; FOREACH_MOD(I_OnChanDrop, OnChanDrop(ci)); @@ -71,10 +69,9 @@ class CommandCSDrop : public Command bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override { - User *u = source.u; this->SendSyntax(source); source.Reply(" "); - if (u->IsServicesOper()) + if (source.IsServicesOper()) source.Reply(_("Unregisters the named channel. Only \002Services Operators\002\n" "can drop a channel for which they have not identified.")); else diff --git a/modules/commands/cs_enforce.cpp b/modules/commands/cs_enforce.cpp index 62c8e0c6d..96031a96f 100644 --- a/modules/commands/cs_enforce.cpp +++ b/modules/commands/cs_enforce.cpp @@ -122,14 +122,13 @@ class CommandCSEnforce : public Command { const Anope::string &what = params.size() > 1 ? params[1] : ""; - User *u = source.u; Channel *c = findchan(params[0]); if (!c) source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str()); else if (!c->ci) source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str()); - else if (!c->ci->AccessFor(u).HasPriv("AKICK")) + else if (!source.AccessFor(c->ci).HasPriv("AKICK")) source.Reply(ACCESS_DENIED); else { diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index 9fbcc624f..e5b8d2221 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -22,7 +22,6 @@ struct EntryMsg : Serializable EntryMsg(ChannelInfo *c, const Anope::string &cname, const Anope::string &cmessage, time_t ct = Anope::CurTime) { - this->ci = c; this->creator = cname; this->message = cmessage; @@ -128,8 +127,6 @@ class CommandEntryMessage : public Command void DoAdd(CommandSource &source, ChannelInfo *ci, const Anope::string &message) { - User *u = source.u; - EntryMessageList *messages = ci->GetExt("cs_entrymsg"); if (messages == NULL) { @@ -141,16 +138,14 @@ class CommandEntryMessage : public Command source.Reply(_("The entry message list for \002%s\002 is full."), ci->name.c_str()); else { - (*messages)->push_back(new EntryMsg(ci, source.u->nick, message)); - Log(IsFounder(u, ci) ? LOG_COMMAND : LOG_OVERRIDE, u, this, ci) << "to add a message"; + (*messages)->push_back(new EntryMsg(ci, source.GetNick(), message)); + Log(source.IsFounder(ci) ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to add a message"; source.Reply(_("Entry message added to \002%s\002"), ci->name.c_str()); } } void DoDel(CommandSource &source, ChannelInfo *ci, const Anope::string &message) { - User *u = source.u; - EntryMessageList *messages = ci->GetExt("cs_entrymsg"); if (messages == NULL) { @@ -173,7 +168,7 @@ class CommandEntryMessage : public Command (*messages)->erase((*messages)->begin() + i - 1); if ((*messages)->empty()) ci->Shrink("cs_entrymsg"); - Log(IsFounder(u, ci) ? LOG_COMMAND : LOG_OVERRIDE, u, this, ci) << "to remove a message"; + Log(source.IsFounder(ci) ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove a message"; source.Reply(_("Entry message \002%i\002 for \002%s\002 deleted."), i, ci->name.c_str()); } else @@ -188,8 +183,6 @@ class CommandEntryMessage : public Command void DoClear(CommandSource &source, ChannelInfo *ci) { - User *u = source.u; - EntryMessageList *messages = ci->GetExt("cs_entrymsg"); if (messages != NULL) { @@ -199,7 +192,7 @@ class CommandEntryMessage : public Command ci->Shrink("cs_entrymsg"); } - Log(IsFounder(u, ci) ? LOG_COMMAND : LOG_OVERRIDE, u, this, ci) << "to remove all messages"; + Log(source.IsFounder(ci) ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove all messages"; source.Reply(_("Entry messages for \002%s\002 have been cleared."), ci->name.c_str()); } @@ -215,8 +208,6 @@ class CommandEntryMessage : public Command void Execute(CommandSource &source, const std::vector ¶ms) anope_override { - User *u = source.u; - ChannelInfo *ci = cs_findchan(params[0]); if (ci == NULL) { @@ -224,7 +215,7 @@ class CommandEntryMessage : public Command return; } - if (IsFounder(u, ci) || u->HasCommand("chanserv/set")) + if (source.IsFounder(ci) || source.HasCommand("chanserv/set")) { if (params[1].equals_ci("LIST")) this->DoList(source, ci); diff --git a/modules/commands/cs_fantasy_stats.cpp b/modules/commands/cs_fantasy_stats.cpp index a8f6fe2fc..7c79593a2 100644 --- a/modules/commands/cs_fantasy_stats.cpp +++ b/modules/commands/cs_fantasy_stats.cpp @@ -102,12 +102,12 @@ class CSStats : public Module void DoStats(CommandSource &source, const bool is_global, const std::vector ¶ms) { - if (!source.u || !source.c) + if (!source.c) return; Anope::string display; if (params.empty()) - display = source.u->Account()->display; + display = source.nc->display; else if (const NickAlias *na = findnick(params[0])) display = na->nc->display; else diff --git a/modules/commands/cs_fantasy_top.cpp b/modules/commands/cs_fantasy_top.cpp index b85849ed5..587b4c525 100644 --- a/modules/commands/cs_fantasy_top.cpp +++ b/modules/commands/cs_fantasy_top.cpp @@ -131,7 +131,7 @@ class CSTop : public Module void DoTop(CommandSource &source, const std::vector ¶ms, bool is_global, int limit = 1) { - if (!source.u || !source.c || !source.c->ci) + if (!source.c || !source.c->ci) return; Anope::string channel; @@ -204,4 +204,4 @@ void CommandCSGTop10::Execute(CommandSource &source, const std::vector ¶ms) { - User *u = source.u; - Anope::string mask = params.size() > 2 ? params[2] : ""; Anope::string flags = params.size() > 3 ? params[3] : ""; @@ -86,7 +84,7 @@ class CommandCSFlags : public Command return; } - AccessGroup u_access = ci->AccessFor(u); + AccessGroup u_access = source.AccessFor(ci); if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask)) { @@ -141,7 +139,7 @@ class CommandCSFlags : public Command { if (!u_access.HasPriv(it->first)) {