diff options
Diffstat (limited to 'modules')
67 files changed, 393 insertions, 479 deletions
diff --git a/modules/botserv/assign.cpp b/modules/botserv/assign.cpp index bb2d35879..b743564b0 100644 --- a/modules/botserv/assign.cpp +++ b/modules/botserv/assign.cpp @@ -55,7 +55,7 @@ class CommandBSAssign : public Command } ChanServ::AccessGroup access = source.AccessFor(ci); - if (!access.HasPriv("ASSIGN") && !source.HasPriv("botserv/administration")) + if (!access.HasPriv("ASSIGN") && !source.HasOverridePriv("botserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "ASSIGN", ci->GetName()); return; @@ -79,8 +79,7 @@ class CommandBSAssign : public Command return; } - bool override = !access.HasPriv("ASSIGN"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to assign {0}"), bi->nick); + logger.Command(source, ci, _("{source} used {command} on {channel} to assign {0}"), bi->nick); bi->Assign(source.GetUser(), ci); source.Reply(_("Bot \002{0}\002 has been assigned to \002{1}\002."), bi->nick, ci->GetName()); @@ -128,7 +127,7 @@ class CommandBSUnassign : public Command } ChanServ::AccessGroup access = source.AccessFor(ci); - if (!source.HasPriv("botserv/administration") && !access.HasPriv("ASSIGN")) + if (!access.HasPriv("ASSIGN") && !source.HasOverridePriv("botserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "ASSIGN", ci->GetName()); return; @@ -146,8 +145,7 @@ class CommandBSUnassign : public Command return; } - bool override = !access.HasPriv("ASSIGN"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to unassign {0}"), ci->GetBot()->nick); + logger.Command(source, ci, _("{source} used {command} on {channel} to unassign {0}"), ci->GetBot()->nick); ServiceBot *bi = ci->GetBot(); bi->UnAssign(source.GetUser(), ci); @@ -192,7 +190,7 @@ class CommandBSSetNoBot : public Command if (value.equals_ci("ON")) { - logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} to enable nobot")); + logger.Admin(source, ci, _("{source} used {command} on {channel} to enable nobot")); ci->SetS<bool>("BS_NOBOT", true); if (ci->GetBot()) @@ -201,7 +199,7 @@ class CommandBSSetNoBot : public Command } else if (value.equals_ci("OFF")) { - logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} to disable nobot")); + logger.Admin(source, ci, _("{source} used {command} on {channel} to disable nobot")); ci->UnsetS<bool>("BS_NOBOT"); source.Reply(_("No-bot mode is now \002off\002 for \002{0}\002."), ci->GetName()); diff --git a/modules/botserv/badwords.cpp b/modules/botserv/badwords.cpp index 3de381d34..5fb7fa342 100644 --- a/modules/botserv/badwords.cpp +++ b/modules/botserv/badwords.cpp @@ -143,8 +143,7 @@ class CommandBSBadwords : public Command void DoList(CommandSource &source, ChanServ::Channel *ci, const Anope::string &word) { - bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to list badwords")); + logger.Command(source, ci, _("{source} used {command} on {channel} to list badwords")); ListFormatter list(source.GetAccount()); list.AddColumn(_("Number")).AddColumn(_("Word")).AddColumn(_("Type")); @@ -243,8 +242,7 @@ class CommandBSBadwords : public Command return; } - bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0}"), realword); + logger.Command(source, ci, _("{source} used {command} on {channel} to add {0}"), realword); badwords->AddBadWord(ci, realword, bwtype); source.Reply(_("\002{0}\002 added to \002{1}\002 bad words list."), realword, ci->GetName()); @@ -271,7 +269,7 @@ class CommandBSBadwords : public Command if (!num || num > badwords->GetBadWordCount(ci)) return; - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to remove {0}"), badwords->GetBadWord(ci, num - 1)->GetWord()); + logger.Command(source, ci, _("{source} used {command} on {channel} to remove {0}"), badwords->GetBadWord(ci, num - 1)->GetWord()); ++deleted; badwords->EraseBadWord(ci, num - 1); @@ -305,7 +303,7 @@ class CommandBSBadwords : public Command return; } - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to remove {3}"), bw->GetWord()); + logger.Command(source, ci, _("{source} used {command} on {channel} to remove {3}"), bw->GetWord()); source.Reply(_("\002{0}\002 deleted from \002{1}\002 bad words list."), bw->GetWord(), ci->GetName()); @@ -315,8 +313,7 @@ class CommandBSBadwords : public Command void DoClear(CommandSource &source, ChanServ::Channel *ci) { - bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clear the badwords list")); + logger.Command(source, ci, _("{source} used {command} on {channel} to clear the badwords list")); badwords->ClearBadWords(ci); source.Reply(_("Bad words list is now empty.")); @@ -352,7 +349,7 @@ class CommandBSBadwords : public Command return; } - if (!source.AccessFor(ci).HasPriv("BADWORDS") && (!need_args || !source.HasPriv("botserv/administration"))) + if (!source.AccessFor(ci).HasPriv("BADWORDS") && !source.HasOverridePriv("botserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "BADWORDS", ci->GetName()); return; diff --git a/modules/botserv/bot.cpp b/modules/botserv/bot.cpp index ab48dc82e..2e632a805 100644 --- a/modules/botserv/bot.cpp +++ b/modules/botserv/bot.cpp @@ -103,7 +103,7 @@ class CommandBSBot : public Command bi->bi = botinfo; botinfo->bot = bi; - logger.Command(LogType::ADMIN, source, _("{source} used {command} to add bot {0} {1}"), bi->GetMask(), bi->realname); + logger.Admin(source, _("{source} used {command} to add bot {0} {1}"), bi->GetMask(), bi->realname); source.Reply(_("\002{0}!{1}@{2}\002 (\002{3}\002) added to the bot list."), bi->nick, bi->GetIdent(), bi->host, bi->realname); @@ -266,7 +266,7 @@ class CommandBSBot : public Command if (!user.empty()) bi->OnKill(); - logger.Command(LogType::ADMIN, source, _("{source} used {command} to change bot {0} to {1} {2}"), + logger.Admin(source, _("{source} used {command} to change bot {0} to {1} {2}"), oldnick, bi->GetMask(), bi->realname); source.Reply(_("Bot \002{0}\002 has been changed to \002{1}!{2}@{3}\002 (\002{4}\002)."), oldnick, bi->nick, bi->GetIdent(), bi->host, bi->realname); @@ -299,7 +299,7 @@ class CommandBSBot : public Command EventManager::Get()->Dispatch(&Event::BotDelete::OnBotDelete, bi); - logger.Command(LogType::ADMIN, source, _("{source} used {command} to delete bot {0}"), bi->nick); + logger.Admin(source, _("{source} used {command} to delete bot {0}"), bi->nick); source.Reply(_("Bot \002{0}\002 has been deleted."), bi->nick); delete bi; diff --git a/modules/botserv/control.cpp b/modules/botserv/control.cpp index 6a8edc200..ce2b0d6e6 100644 --- a/modules/botserv/control.cpp +++ b/modules/botserv/control.cpp @@ -40,7 +40,7 @@ class CommandBSSay : public Command return; } - if (!source.AccessFor(ci).HasPriv("SAY") && !source.HasPriv("botserv/administration")) + if (!source.AccessFor(ci).HasPriv("SAY") && !source.HasOverridePriv("botserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SAY", ci->GetName()); return; @@ -74,8 +74,7 @@ class CommandBSSay : public Command IRCD->SendPrivmsg(ci->GetBot(), ci->GetName(), text); ci->GetBot()->lastmsg = Anope::CurTime; - bool override = !source.AccessFor(ci).HasPriv("SAY"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to say: {0}"), text); + logger.Command(source, ci, _("{source} used {command} on {channel} to say: {0}"), text); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -112,7 +111,7 @@ class CommandBSAct : public Command return; } - if (!source.AccessFor(ci).HasPriv("SAY") && !source.HasPriv("botserv/administration")) + if (!source.AccessFor(ci).HasPriv("SAY") && !source.HasOverridePriv("botserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SAY", ci->GetName()); return; @@ -144,8 +143,7 @@ class CommandBSAct : public Command IRCD->SendAction(ci->GetBot(), ci->GetName(), message); ci->GetBot()->lastmsg = Anope::CurTime; - bool override = !source.AccessFor(ci).HasPriv("SAY"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} to say: {0}"), message); + logger.Command(source, ci, _("{source} used {command} to say: {0}"), message); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/botserv/kick.cpp b/modules/botserv/kick.cpp index 84939c963..3146483e9 100644 --- a/modules/botserv/kick.cpp +++ b/modules/botserv/kick.cpp @@ -586,7 +586,7 @@ class CommandBSKickBase : public Command this->OnSyntaxError(source, ""); else if (!option.equals_ci("ON") && !option.equals_ci("OFF")) this->OnSyntaxError(source, ""); - else if (!source.AccessFor(ci).HasPriv("SET") && !source.HasPriv("botserv/administration")) + else if (!source.AccessFor(ci).HasPriv("SET") && !source.HasOverridePriv("botserv/administration")) source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); else if (!ci->GetBot()) source.Reply(_("There is no bot assigned to \002{0}\002."), ci->GetName()); @@ -636,13 +636,11 @@ class CommandBSKickBase : public Command else source.Reply(_("Bot will now kick for \002{0}\002."), optname); - bool override = !source.AccessFor(ci).HasPriv("SET"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enable the {0} kicker"), optname); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable the {0} kicker"), optname); } else if (param.equals_ci("OFF")) { - bool override = !source.AccessFor(ci).HasPriv("SET"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable the {0} kicker"), optname); + logger.Command(source, ci, _("{source} used {command} on {channel} to disable the {0} kicker"), optname); (kd->*setter)(false); (kd->*ttbsetter)(0); @@ -1082,7 +1080,7 @@ class CommandBSSetDontKickOps : public Command } ChanServ::AccessGroup access = source.AccessFor(ci); - if (!source.HasPriv("botserv/administration") && !access.HasPriv("SET")) + if (!access.HasPriv("SET") && !source.HasOverridePriv("botserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -1098,16 +1096,14 @@ class CommandBSSetDontKickOps : public Command if (params[1].equals_ci("ON")) { - bool override = !access.HasPriv("SET"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enable dontkickops")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable dontkickops")); kd->SetDontKickOps(true); source.Reply(_("Bot \002won't kick ops\002 on channel \002{0}\002."), ci->GetName()); } else if (params[1].equals_ci("OFF")) { - bool override = !access.HasPriv("SET"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable dontkickops")); + logger.Command(source, ci, _("{source} used {command} on {channel} to disable dontkickops")); kd->SetDontKickOps(false); source.Reply(_("Bot \002will kick ops\002 on channel \002{0}\002."), ci->GetName()); @@ -1148,7 +1144,7 @@ class CommandBSSetDontKickVoices : public Command } ChanServ::AccessGroup access = source.AccessFor(ci); - if (!source.HasPriv("botserv/administration") && !access.HasPriv("SET")) + if (!access.HasPriv("SET") && !source.HasOverridePriv("botserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -1164,19 +1160,17 @@ class CommandBSSetDontKickVoices : public Command if (params[1].equals_ci("ON")) { - bool override = !access.HasPriv("SET"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enable dontkickvoices")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable dontkickvoices")); kd->SetDontKickVoices(true); - source.Reply(_("Bot \002won't kick voices\002 on channel %s."), ci->GetName().c_str()); + source.Reply(_("Bot \002won't kick voices\002 on channel \002{0}\002."), ci->GetName()); } else if (params[1].equals_ci("OFF")) { - bool override = !access.HasPriv("SET"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable dontkickvoices")); + logger.Command(source, ci, _("{source} used {command} on {channel} to disable dontkickvoices")); kd->SetDontKickVoices(false); - source.Reply(_("Bot \002will kick voices\002 on channel %s."), ci->GetName().c_str()); + source.Reply(_("Bot \002will kick voices\002 on channel \002{0}\002."), ci->GetName()); } else { diff --git a/modules/botserv/set.cpp b/modules/botserv/set.cpp index da3b42f92..559453085 100644 --- a/modules/botserv/set.cpp +++ b/modules/botserv/set.cpp @@ -111,7 +111,7 @@ class CommandBSSetBanExpire : public Command } ChanServ::AccessGroup access = source.AccessFor(ci); - if (!source.HasPriv("botserv/administration") && !access.HasPriv("SET")) + if (!access.HasPriv("SET") && !source.HasOverridePriv("botserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -139,8 +139,7 @@ class CommandBSSetBanExpire : public Command ci->SetBanExpire(t); - bool override = !access.HasPriv("SET"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to change banexpire to {0}"), arg); + logger.Command(source, ci, _("{source} used {command} on {channel} to change banexpire to {0}"), arg); if (!t) source.Reply(_("Bot bans will no longer automatically expire.")); diff --git a/modules/chanserv/access.cpp b/modules/chanserv/access.cpp index 36307c52f..44d21734e 100644 --- a/modules/chanserv/access.cpp +++ b/modules/chanserv/access.cpp @@ -101,19 +101,24 @@ void AccessChanAccessImpl::SetLevel(const int &i) class CommandCSAccess : public Command { - void DoAdd(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) + void DoAdd(CommandSource &source, ChanServ::Channel *ci, Anope::string mask, const Anope::string &levelstr) { - Anope::string mask = params[2]; ChanServ::Privilege *p = NULL; int level = ChanServ::ACCESS_INVALID; + if (levelstr.empty()) + { + this->OnSyntaxError(source, "ADD"); + return; + } + try { - level = convertTo<int>(params[3]); + level = convertTo<int>(levelstr); } catch (const ConvertException &) { - p = ChanServ::service ? ChanServ::service->FindPrivilege(params[3]) : nullptr; + p = ChanServ::service ? ChanServ::service->FindPrivilege(levelstr) : nullptr; if (p != NULL && p->level) level = p->level; } @@ -137,15 +142,9 @@ class CommandCSAccess : public Command access->SetChannel(ci); access->SetLevel(level); - bool override = false; - if ((!highest || *highest <= *access) && !u_access.founder) { - if (source.HasPriv("chanserv/access/modify")) - { - override = true; - } - else + if (!source.HasOverridePriv("chanserv/access/modify")) { source.Reply(_("Access denied. You do not have enough privileges on \002{0}\002 to add someone at level \002{1}\002."), ci->GetName(), level); access->Delete(); @@ -184,12 +183,12 @@ 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 && !source.HasPriv("chanserv/access/modify")) + if ((!highest || *access >= *highest) && !u_access.founder && !source.HasOverridePriv("chanserv/access/modify")) { source.Reply(_("Access denied. You do not have enough privileges on \002{0}\002 to lower the access of \002{1}\002."), ci->GetName(), access->Mask()); return; } - delete access; + access->Delete(); break; } } @@ -197,7 +196,7 @@ class CommandCSAccess : public Command unsigned access_max = Config->GetModule("chanserv/main")->Get<unsigned>("accessmax", "1024"); if (access_max && ci->GetAccessCount() >= access_max) { - source.Reply(_("Sorry, you can only have %d access entries on a channel, including access entries from other channels."), access_max); + source.Reply(_("Sorry, you can only have {0} access entries on a channel, including access entries from other channels."), access_max); return; } @@ -213,7 +212,7 @@ class CommandCSAccess : public Command EventManager::Get()->Dispatch(&Event::AccessAdd::OnAccessAdd, ci, source, access); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0} with level {1}"), mask, level); + logger.Command(source, ci, _("{source} used {command} on {channel} to add {0} with level {1}"), mask, level); if (p != NULL) source.Reply(_("\002{0}\002 added to the access list of \002{1}\002 with privilege \002{2}\002 (level \002{3}\002)."), access->Mask(), ci->GetName(), p->name, level); @@ -221,9 +220,13 @@ class CommandCSAccess : public Command source.Reply(_("\002{0}\002 added to the access list of \002{1}\002 at level \002{2}\002."), access->Mask(), ci->GetName(), level); } - void DoDel(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) + void DoDel(CommandSource &source, ChanServ::Channel *ci, Anope::string mask) { - Anope::string mask = params[2]; + if (mask.empty()) + { + this->OnSyntaxError(source, "DEL"); + return; + } if (!ci->GetAccessCount()) { @@ -245,7 +248,6 @@ class CommandCSAccess : public Command if (isdigit(mask[0]) && mask.find_first_not_of("1234567890,-") == Anope::string::npos) { - bool override = !source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/access/modify"); Anope::string nicks; bool denied = false; unsigned int deleted = 0; @@ -261,7 +263,7 @@ class CommandCSAccess : public Command ChanServ::AccessGroup ag = source.AccessFor(ci); ChanServ::ChanAccess *u_highest = ag.Highest(); - if ((!u_highest || *u_highest <= *access) && !ag.founder && !override && access->GetObj() != source.nc) + if ((!u_highest || *u_highest <= *access) && !ag.founder && !source.IsOverride() && access->GetObj() != source.nc) { denied = true; |
