diff options
| author | Adam <Adam@anope.org> | 2017-02-06 14:23:18 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2017-02-06 14:23:18 -0500 |
| commit | 8b694bc392c36551e428b84454efb81cdbc8bcd3 (patch) | |
| tree | ca3d1ca8aadac280c149518134de4208f91dad84 /modules/chanserv | |
| parent | 9ad06f49bbb3824139b0c0ee0a74898a18c8f735 (diff) | |
Track override in CommandSource and use it in the logger
Diffstat (limited to 'modules/chanserv')
| -rw-r--r-- | modules/chanserv/access.cpp | 206 | ||||
| -rw-r--r-- | modules/chanserv/akick.cpp | 21 | ||||
| -rw-r--r-- | modules/chanserv/ban.cpp | 16 | ||||
| -rw-r--r-- | modules/chanserv/clone.cpp | 9 | ||||
| -rw-r--r-- | modules/chanserv/drop.cpp | 5 | ||||
| -rw-r--r-- | modules/chanserv/enforce.cpp | 20 | ||||
| -rw-r--r-- | modules/chanserv/entrymsg.cpp | 8 | ||||
| -rw-r--r-- | modules/chanserv/flags.cpp | 22 | ||||
| -rw-r--r-- | modules/chanserv/getkey.cpp | 5 | ||||
| -rw-r--r-- | modules/chanserv/invite.cpp | 8 | ||||
| -rw-r--r-- | modules/chanserv/kick.cpp | 40 | ||||
| -rw-r--r-- | modules/chanserv/list.cpp | 6 | ||||
| -rw-r--r-- | modules/chanserv/log.cpp | 8 | ||||
| -rw-r--r-- | modules/chanserv/mode.cpp | 52 | ||||
| -rw-r--r-- | modules/chanserv/set.cpp | 78 | ||||
| -rw-r--r-- | modules/chanserv/set_misc.cpp | 6 | ||||
| -rw-r--r-- | modules/chanserv/suspend.cpp | 4 | ||||
| -rw-r--r-- | modules/chanserv/sync.cpp | 5 | ||||
| -rw-r--r-- | modules/chanserv/topic.cpp | 13 | ||||
| -rw-r--r-- | modules/chanserv/unban.cpp | 5 | ||||
| -rw-r--r-- | modules/chanserv/updown.cpp | 26 | ||||
| -rw-r--r-- | modules/chanserv/xop.cpp | 21 |
22 files changed, 258 insertions, 326 deletions
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; return; @@ -274,7 +276,7 @@ class CommandCSAccess : public Command nicks = access->Mask(); EventManager::Get()->Dispatch(&Event::AccessDel::OnAccessDel, ci, source, access); - delete access; + access->Delete(); }, [&]() { @@ -284,7 +286,7 @@ class CommandCSAccess : public Command source.Reply(_("There are no entries matching \002{0}\002 on the access list of \002{1}\002."), mask, ci->GetName()); else { - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), mask); + logger.Command(source, ci, _("{source} used {command} on {channel} to delete {0}"), mask); if (deleted == 1) source.Reply(_("Deleted \0021\002 entry from the access list of \002{0}\002."), ci->GetName()); @@ -303,16 +305,17 @@ class CommandCSAccess : public Command ChanServ::ChanAccess *access = ci->GetAccess(i - 1); if (mask.equals_ci(access->Mask())) { - if (access->GetObj() != source.nc && !u_access.founder && (!highest || *highest <= *access) && !source.HasPriv("chanserv/access/modify")) + if (access->GetObj() != source.nc && !u_access.founder && (!highest || *highest <= *access) && !source.HasOverridePriv("chanserv/access/modify")) + { source.Reply(_("Access denied. You do not have enough privileges on \002{0}\002 to remove the access of \002{1}\002."), ci->GetName(), access->Mask()); + } else { source.Reply(_("\002{0}\002 deleted from the access list of \002{1}\002."), access->Mask(), ci->GetName()); - bool override = !u_access.founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->Mask().equals_ci(source.nc->GetDisplay()); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {3}"), access->Mask()); + logger.Command(source, ci, _("{source} used {command} on {channel} to delete {3}"), access->Mask()); EventManager::Get()->Dispatch(&Event::AccessDel::OnAccessDel, ci, source, access); - delete access; + access->Delete(); } return; } @@ -322,10 +325,8 @@ class CommandCSAccess : public Command } } - void ProcessList(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms, ListFormatter &list) + void ProcessList(CommandSource &source, ChanServ::Channel *ci, const Anope::string &nick, ListFormatter &list) { - const Anope::string &nick = params.size() > 2 ? params[2] : ""; - if (!ci->GetAccessCount()) { source.Reply(_("The access list for \002{0}\002 is empty."), ci->GetName()); @@ -418,7 +419,7 @@ class CommandCSAccess : public Command source.Reply(_("End of access list.")); } - void DoList(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) + void DoList(CommandSource &source, ChanServ::Channel *ci, const Anope::string &nick) { if (!ci->GetAccessCount()) { @@ -428,10 +429,10 @@ class CommandCSAccess : public Command ListFormatter list(source.GetAccount()); list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask")); - this->ProcessList(source, ci, params, list); + this->ProcessList(source, ci, nick, list); } - void DoView(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) + void DoView(CommandSource &source, ChanServ::Channel *ci, const Anope::string &nick) { if (!ci->GetAccessCount()) { @@ -441,12 +442,12 @@ class CommandCSAccess : public Command ListFormatter list(source.GetAccount()); list.AddColumn(_("Number")).AddColumn(_("Level")).AddColumn(_("Mask")).AddColumn(_("By")).AddColumn(_("Last seen")); - this->ProcessList(source, ci, params, list); + this->ProcessList(source, ci, nick, list); } void DoClear(CommandSource &source, ChanServ::Channel *ci) { - if (!source.IsFounder(ci) && !source.HasPriv("chanserv/access/modify")) + if (!source.IsFounder(ci) && !source.HasOverridePriv("chanserv/access/modify")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->GetName()); return; @@ -459,7 +460,7 @@ class CommandCSAccess : public Command source.Reply(_("The access list of \002{0}\002 has been cleared."), ci->GetName()); bool override = !source.IsFounder(ci); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clear the access list")); + logger.Command(source, ci, _("{source} used {command} on {channel} to clear the access list")); } public: @@ -478,10 +479,10 @@ class CommandCSAccess : public Command const Anope::string &chan = params[0]; const Anope::string &cmd = params[1]; const Anope::string &nick = params.size() > 2 ? params[2] : ""; - const Anope::string &s = params.size() > 3 ? params[3] : ""; + const Anope::string &level = params.size() > 3 ? params[3] : ""; ChanServ::Channel *ci = ChanServ::Find(chan); - if (ci == NULL) + if (ci == nullptr) { source.Reply(_("Channel \002{0}\002 isn't registered."), chan); return; @@ -494,14 +495,14 @@ class CommandCSAccess : public Command ChanServ::AccessGroup access = source.AccessFor(ci); bool has_access = false; - if (source.HasPriv("chanserv/access/modify")) - has_access = true; - else if (is_list && source.HasPriv("chanserv/access/list")) + if (access.HasPriv("ACCESS_CHANGE")) + { has_access = true; + } else if (is_list && access.HasPriv("ACCESS_LIST")) + { has_access = true; - else if (access.HasPriv("ACCESS_CHANGE")) - has_access = true; + } else if (is_del) { NickServ::Nick *na = NickServ::FindNick(nick); @@ -509,13 +510,12 @@ class CommandCSAccess : public Command has_access = true; } - /* If LIST, we don't *require* any parameters, but we can take any. - * If DEL, we require a nick and no level. - * Else (ADD), we require a level (which implies a nick). */ - if (is_list || is_clear ? 0 : (cmd.equals_ci("DEL") ? (nick.empty() || !s.empty()) : s.empty())) + if (!has_access) { - this->OnSyntaxError(source, cmd); - return; + if (source.HasOverridePriv("chanserv/access/modify")) + has_access = true; + else if (is_list && source.HasOverridePriv("chanserv/access/list")) + has_access = true; } if (!has_access) @@ -531,13 +531,13 @@ class CommandCSAccess : public Command } if (cmd.equals_ci("ADD")) - this->DoAdd(source, ci, params); + this->DoAdd(source, ci, nick, level); else if (cmd.equals_ci("DEL")) - this->DoDel(source, ci, params); + this->DoDel(source, ci, nick); else if (cmd.equals_ci("LIST")) - this->DoList(source, ci, params); + this->DoList(source, ci, nick); else if (cmd.equals_ci("VIEW")) - this->DoView(source, ci, params); + this->DoView(source, ci, nick); else if (cmd.equals_ci("CLEAR")) this->DoClear(source, ci); else @@ -634,20 +634,25 @@ class CommandCSAccess : public Command class CommandCSLevels : public Command { - void DoSet(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) + void DoSet(CommandSource &source, ChanServ::Channel *ci, const Anope::string &privilege, const Anope::string &levelstr) { - const Anope::string &what = params[2]; - const Anope::string &lev = params[3]; - int level; - if (lev.equals_ci("FOUNDER")) + if (levelstr.empty()) + { + this->OnSyntaxError(source, "SET"); + return; + } + + if (levelstr.equals_ci("FOUNDER")) + { level = ChanServ::ACCESS_FOUNDER; + } else { try { - level = convertTo<int>(lev); + level = convertTo<int>(levelstr); } catch (const ConvertException &) { @@ -662,57 +667,58 @@ class CommandCSLevels : public Command return; } - ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(what) : nullptr; + ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(privilege) : nullptr; if (p == NULL) { CommandInfo *help = source.service->FindCommand("generic/help"); if (help) source.Reply(_("There is no such privilege \002{0}\002. See \002{0}{1} {2} {3}\002 for a list of valid settings."), - what, Config->StrictPrivmsg, source.service->nick, help->cname, source.GetCommand()); + privilege, Config->StrictPrivmsg, source.service->nick, help->cname, source.GetCommand()); + return; } - else - { - bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to set {0} to level {1}"), p->name, level); - ci->SetLevel(p->name, level); - EventManager::Get()->Dispatch(&Event::LevelChange::OnLevelChange, source, ci, p->name, level); + logger.Command(source, ci, _("{source} used {command} on {channel} to set {0} to level {1}"), p->name, level); - if (level == ChanServ::ACCESS_FOUNDER) - source.Reply(_("Level for privilege \002{0}\002 on channel \002{1}\002 changed to \002founder only\002."), p->name, ci->GetName()); - else - source.Reply(_("Level for privilege \002{0}\002 on channel \002{1}\002 changed to \002{3}\002."), p->name, ci->GetName(), level); - } + ci->SetLevel(p->name, level); + EventManager::Get()->Dispatch(&Event::LevelChange::OnLevelChange, source, ci, p->name, level); + + if (level == ChanServ::ACCESS_FOUNDER) + source.Reply(_("Level for privilege \002{0}\002 on channel \002{1}\002 changed to \002founder only\002."), p->name, ci->GetName()); + else + source.Reply(_("Level for privilege \002{0}\002 on channel \002{1}\002 changed to \002{3}\002."), p->name, ci->GetName(), level); } - void DoDisable(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) + void DoDisable(CommandSource &source, ChanServ::Channel *ci, const Anope::string &privilege) { - const Anope::string &what = params[2]; + if (privilege.empty()) + { + this->OnSyntaxError(source, "DISABLE"); + return; + } /* Don't allow disabling of the founder level. It would be hard to change it back if you don't have access to use this command */ - if (what.equals_ci("FOUNDER")) + if (privilege.equals_ci("FOUNDER")) { source.Reply(_("You can not disable the founder privilege because it would be impossible to reenable it at a later time.")); return; } - ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(what) : nullptr; - if (p != NULL) + ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(privilege) : nullptr; + if (p == nullptr) { - bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable {0}"), p->name); - - ci->SetLevel(p->name, ChanServ::ACCESS_INVALID); - EventManager::Get()->Dispatch(&Event::LevelChange::OnLevelChange, source, ci, p->name, ChanServ::ACCESS_INVALID); - - source.Reply(_("Privileged \002{0}\002 disabled on channel \002{1}\002."), p->name, ci->GetName()); + CommandInfo *help = source.service->FindCommand("generic/help"); + if (help) + source.Reply(_("There is no such privilege \002{0}\002. See \002{0}{1} {2} {3}\002 for a list of valid settings."), + privilege, Config->StrictPrivmsg, source.service->nick, help->cname, source.GetCommand()); return; } - CommandInfo *help = source.service->FindCommand("generic/help"); - if (help) - source.Reply(_("There is no such privilege \002{0}\002. See \002{0}{1} {2} {3}\002 for a list of valid settings."), - what, Config->StrictPrivmsg, source.service->nick, help->cname, source.GetCommand()); + logger.Command(source, ci, _("{source} used {command} on {channel} to disable {0}"), p->name); + + ci->SetLevel(p->name, ChanServ::ACCESS_INVALID); + EventManager::Get()->Dispatch(&Event::LevelChange::OnLevelChange, source, ci, p->name, ChanServ::ACCESS_INVALID); + + source.Reply(_("Privilege \002{0}\002 disabled on channel \002{1}\002."), p->name, ci->GetName()); } void DoList(CommandSource &source, ChanServ::Channel *ci) @@ -754,8 +760,7 @@ class CommandCSLevels : public Command void DoReset(CommandSource &source, ChanServ::Channel *ci) { - bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to reset all levels")); + logger.Command(source, ci, _("{source} used {command} on {channel} to reset all levels")); ci->ClearLevels(); EventManager::Get()->Dispatch(&Event::LevelChange::OnLevelChange, source, ci, "ALL", 0); @@ -777,33 +782,24 @@ class CommandCSLevels : public Command { const Anope::string &chan = params[0]; const Anope::string &cmd = params[1]; - const Anope::string &what = params.size() > 2 ? params[2] : ""; - const Anope::string &s = params.size() > 3 ? params[3] : ""; + const Anope::string &privilege = params.size() > 2 ? params[2] : ""; + const Anope::string &level = params.size() > 3 ? params[3] : ""; ChanServ::Channel *ci = ChanServ::Find(chan); - if (ci == NULL) + if (ci == nullptr) { source.Reply(_("Channel \002{0}\002 isn't registered."), chan); return; } bool has_access = false; - if (source.HasPriv("chanserv/access/modify")) + if (source.AccessFor(ci).HasPriv("FOUNDER")) has_access = true; - else if (cmd.equals_ci("LIST") && source.HasPriv("chanserv/access/list")) + else if (source.HasOverridePriv("chanserv/access/modify")) has_access = true; - else if (source.AccessFor(ci).HasPriv("FOUNDER")) + else if (cmd.equals_ci("LIST") && source.HasOverridePriv("chanserv/access/list")) has_access = true; - /* If SET, we want two extra parameters; if DIS[ABLE] or FOUNDER, we want only - * one; else, we want none. - */ - if (cmd.equals_ci("SET") ? s.empty() : (cmd.substr(0, 3).equals_ci("DIS") ? (what.empty() || !s.empty()) : !what.empty())) - { - this->OnSyntaxError(source, cmd); - return; - } - if (!has_access) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->GetName()); @@ -817,9 +813,9 @@ class CommandCSLevels : public Command } if (cmd.equals_ci("SET")) - this->DoSet(source, ci, params); + this->DoSet(source, ci, privilege, level); else if (cmd.equals_ci("DIS") || cmd.equals_ci("DISABLE")) - this->DoDisable(source, ci, params); + this->DoDisable(source, ci, privilege); else if (cmd.equals_ci("LIST")) this->DoList(source, ci); else if (cmd.equals_ci("RESET")) diff --git a/modules/chanserv/akick.cpp b/modules/chanserv/akick.cpp index 60d6530e4..d5564e6bf 100644 --- a/modules/chanserv/akick.cpp +++ b/modules/chanserv/akick.cpp @@ -222,9 +222,8 @@ class CommandCSAKick : public Command } } - bool override = !source.AccessFor(ci).HasPriv("AKICK"); /* Opers overriding get to bypass PEACE */ - if (override) + if (source.IsOverride()) ; /* These peace checks are only for masks */ else if (IRCD->IsChannelValid(mask)) @@ -303,9 +302,9 @@ class CommandCSAKick : public Command ak = ci->AddAkick(source.GetNick(), mask, reason); if (reason.empty()) - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0}"), mask); + logger.Command(source, ci, _("{source} used {command} on {channel} to add {0}"), mask); else - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0} ({1})"), mask, reason); + logger.Command(source, ci, _("{source} used {command} on {channel} to add {0} ({1})"), mask, reason); EventManager::Get()->Dispatch(&Event::Akick::OnAkickAdd, source, ci, ak); @@ -317,7 +316,6 @@ class CommandCSAKick : public Command void DoDel(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) { const Anope::string &mask = params[2]; - bool override = !source.AccessFor(ci).HasPriv("AKICK"); if (!ci->GetAkickCount()) { @@ -340,7 +338,7 @@ class CommandCSAKick : public Command EventManager::Get()->Dispatch(&Event::Akick::OnAkickDel, source, ci, ak); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), + logger.Command(source, ci, _("{source} used {command} on {channel} to delete {0}"), ak->GetAccount() ? ak->GetAccount()->GetDisplay() : ak->GetMask()); ++deleted; @@ -380,7 +378,7 @@ class CommandCSAKick : public Command return; } - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), + logger.Command(source, ci, _("{source} used {command} on {channel} to delete {0}"), match->GetAccount() ? match->GetAccount()->GetDisplay() : match->GetMask()); EventManager::Get()->Dispatch(&Event::Akick::OnAkickDel, source, ci, match); @@ -530,17 +528,14 @@ class CommandCSAKick : public Command ++count; } - bool override = !source.AccessFor(ci).HasPriv("AKICK"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, - _("{source} used {command} on {channel} to enforce the akick list, affects {0} users"), count); + logger.Command(source, ci, _("{source} used {command} on {channel} to enforce the akick list, affects {0} users"), count); source.Reply(_("Autokick enforce for \002{0}\002 complete; \002{1}\002 users were affected."), ci->GetName(), count); } void DoClear(CommandSource &source, ChanServ::Channel *ci) { - bool override = !source.AccessFor(ci).HasPriv("AKICK"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clear the akick list")); + logger.Command(source, ci, _("{source} used {command} on {channel} to clear the akick list")); ci->ClearAkick(); source.Reply(_("The autokick list of \002{0}\002 has been cleared."), ci->GetName()); @@ -579,7 +574,7 @@ class CommandCSAKick : public Command return; } - if (!source.AccessFor(ci).HasPriv("AKICK") && !source.HasPriv("chanserv/access/modify") && (!is_list || source.HasPriv("chanserv/access/list"))) + if (!source.AccessFor(ci).HasPriv("AKICK") && !source.HasOverridePriv("chanserv/access/modify") && (!is_list || source.HasOverridePriv("chanserv/access/list"))) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "AKICK", ci->GetName()); return; diff --git a/modules/chanserv/ban.cpp b/modules/chanserv/ban.cpp index d79afe071..d9105cc49 100644 --- a/modules/chanserv/ban.cpp +++ b/modules/chanserv/ban.cpp @@ -70,7 +70,7 @@ class CommandCSBan : public Command if (IRCD->GetMaxListFor(c) && c->HasMode(mode) >= IRCD->GetMaxListFor(c)) { - source.Reply(_("The %s list for %s is full."), mode.lower().c_str(), c->name.c_str()); + source.Reply(_("The {0} list for {1} is full."), mode.lower(), c->name); return; } @@ -117,7 +117,7 @@ class CommandCSBan : public Command ChanServ::AccessGroup u_access = source.AccessFor(ci); - if (!u_access.HasPriv("BAN") && !source.HasPriv("chanserv/kick")) + if (!u_access.HasPriv("BAN") && !source.HasOverridePriv("chanserv/kick")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "BAN", ci->GetName()); return; @@ -127,7 +127,7 @@ class CommandCSBan : public Command { ChanServ::AccessGroup u2_access = ci->AccessFor(u2); - if (u != u2 && ci->IsPeace() && u2_access >= u_access && !source.HasPriv("chanserv/kick")) + if (u != u2 && ci->IsPeace() && u2_access >= u_access && !source.HasOverridePriv("chanserv/kick")) { source.Reply(_("Access denied. \002{0}\002 has the same or more privileges than you on \002{1}\002."), u2->nick, ci->GetName()); return; @@ -151,8 +151,7 @@ class CommandCSBan : public Command Anope::string mask = ci->GetIdealBan(u2); - bool override = !u_access.HasPriv("BAN") || (u != u2 && ci->IsPeace() && u2_access >= u_access); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} for {0}"), mask); + logger.Command(source, ci, _("{source} used {command} on {channel} for {0}"), mask); if (!c->HasMode(mode, mask)) { @@ -183,12 +182,9 @@ class CommandCSBan : public Command } else { - bool founder = u_access.HasPriv("FOUNDER"); - bool override = !founder && !u_access.HasPriv("BAN"); - Anope::string mask = IRCD->NormalizeMask(target); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} for {0}"), mask); + logger.Command(source, ci, _("{source} used {command} on {channel} for {0}"), mask); if (!c->HasMode(mode, mask)) { @@ -213,7 +209,7 @@ class CommandCSBan : public Command ChanServ::AccessGroup u2_access = ci->AccessFor(uc->user); - if (matched > 1 && !founder) + if (matched > 1 && !u_access.HasPriv("FOUNDER")) continue; if (u != uc->user && ci->IsPeace() && u2_access >= u_access) continue; diff --git a/modules/chanserv/clone.cpp b/modules/chanserv/clone.cpp index 343e6c5b2..a63f33313 100644 --- a/modules/chanserv/clone.cpp +++ b/modules/chanserv/clone.cpp @@ -61,7 +61,6 @@ public: User *u = source.GetUser(); ChanServ::Channel *ci = ChanServ::Find(channel); - bool override = false; if (ci == NULL) { @@ -84,15 +83,11 @@ public: if (!source.IsFounder(ci) || !source.IsFounder(target_ci)) { - if (!source.HasPriv("chanserv/administration")) + if (!source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have the privilege \002{0}\002 on \002{1}\002 and \002{2}\002."), "FOUNDER", ci->GetName(), target_ci->GetName()); return; } - else - { - override = true; - } } if (what.equals_ci("ALL")) @@ -209,7 +204,7 @@ public: return; } - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clone {0} to {1}"), + logger.Command(source, ci, _("{source} used {command} on {channel} to clone {0} to {1}"), what.empty() ? "everything from it" : what, target_ci->GetName()); } diff --git a/modules/chanserv/drop.cpp b/modules/chanserv/drop.cpp index 122ac96b8..8ef29eebf 100644 --- a/modules/chanserv/drop.cpp +++ b/modules/chanserv/drop.cpp @@ -52,7 +52,7 @@ class CommandCSDrop : public Command return; } - if ((ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && !source.HasCommand("chanserv/drop")) + if ((ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && !source.HasOverrideCommand("chanserv/drop")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->GetName()); return; @@ -62,8 +62,7 @@ class CommandCSDrop : public Command if (MOD_RESULT == EVENT_STOP) return; - bool override = (ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} (founder was: {0})"), + logger.Command(source, ci, _("{source} used {command} on {channel} (founder was: {0})"), ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "none"); Reference<Channel> c = ci->c; diff --git a/modules/chanserv/enforce.cpp b/modules/chanserv/enforce.cpp index 8d41c7af3..a3b99ef67 100644 --- a/modules/chanserv/enforce.cpp +++ b/modules/chanserv/enforce.cpp @@ -24,8 +24,7 @@ class CommandCSEnforce : public Command private: void DoSecureOps(CommandSource &source, ChanServ::Channel *ci) { - bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce secureops")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enforce secureops")); /* Dirty hack to allow Channel::SetCorrectModes to work ok. * We pretend like SECUREOPS is on so it doesn't ignore that @@ -50,8 +49,7 @@ class CommandCSEnforce : public Command void DoRestricted(CommandSource &source, ChanServ::Channel *ci) { - bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce restricted")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enforce restricted")); std::vector<User *> users; for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) @@ -81,8 +79,7 @@ class CommandCSEnforce : public Command void DoRegOnly(CommandSource &source, ChanServ::Channel *ci) { - bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce registered only")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enforce registered only")); std::vector<User *> users; for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) @@ -113,8 +110,7 @@ class CommandCSEnforce : public Command void DoSSLOnly(CommandSource &source, ChanServ::Channel *ci) { - bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce SSL only")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enforce SSL only")); std::vector<User *> users; for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) @@ -145,8 +141,7 @@ class CommandCSEnforce : public Command void DoBans(CommandSource &source, ChanServ::Channel *ci) { - bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce bans")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enforce bans")); std::vector<User *> users; for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) @@ -174,8 +169,7 @@ class CommandCSEnforce : public Command void DoLimit(CommandSource &source, ChanServ::Channel *ci) { - bool override = !source.AccessFor(ci).HasPriv("AKICK") && source.HasPriv("chanserv/access/modify"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enforce limit")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enforce limit")); Anope::string l_str; if (!ci->c->GetParam("LIMIT", l_str)) @@ -252,7 +246,7 @@ class CommandCSEnforce : public Command return; } - if (!source.AccessFor(ci).HasPriv("AKICK") && !source.HasPriv("chanserv/access/modify")) + if (!source.AccessFor(ci).HasPriv("AKICK") && !source.HasOverridePriv("chanserv/access/modify")) { source.Reply("Access denied. You do not have the \002{0}\002 privilege on \002{1}\002.", "AKICK", ci->GetName()); return; diff --git a/modules/chanserv/entrymsg.cpp b/modules/chanserv/entrymsg.cpp index 8867fe6ab..660aacad2 100644 --- a/modules/chanserv/entrymsg.cpp +++ b/modules/chanserv/entrymsg.cpp @@ -152,7 +152,7 @@ class CommandEntryMessage : public Command msg->SetCreator(source.GetNick()); msg->SetMessage(message); - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to add a message")); + logger.Command(source, ci, _("{source} used {command} on {channel} to add a message")); source.Reply(_("Entry message added to \002{0}\002"), ci->GetName()); } @@ -180,7 +180,7 @@ class CommandEntryMessage : public Command { messages[i - 1]->Delete(); - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to remove a message")); + logger.Command(source, ci, _("{source} used {command} on {channel} to remove a message")); source.Reply(_("Entry message \002{0}\002 for \002{1]\002 deleted."), i, ci->GetName()); } @@ -198,7 +198,7 @@ class CommandEntryMessage : public Command for (EntryMsg *e : ci->GetRefs<EntryMsg *>()) e->Delete(); - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to remove all messages")); + logger.Command(source, ci, _("{source} used {command} on {channel} to remove all messages")); source.Reply(_("Entry messages for \002{0}\002 have been cleared."), ci->GetName()); } @@ -230,7 +230,7 @@ class CommandEntryMessage : public Command return; } - if (!source.AccessFor(ci).HasPriv("SET") && !source.HasPriv("chanserv/administration")) + if (!source.AccessFor(ci).HasPriv("SET") && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->GetName()); return; diff --git a/modules/chanserv/flags.cpp b/modules/chanserv/flags.cpp index d30d02b4a..6ec65d104 100644 --- a/modules/chanserv/flags.cpp +++ b/modules/chanserv/flags.cpp @@ -160,7 +160,6 @@ class CommandCSFlags : public Command ChanServ::ChanAccess *current = NULL; unsigned current_idx; std::set<char> current_flags; - bool override = false; for (current_idx = ci->GetAccessCount(); current_idx > 0; --current_idx) { ChanServ::ChanAccess *access = ci->GetAccess(current_idx - 1); @@ -172,9 +171,7 @@ class CommandCSFlags : public Command // operator<= on the non-me entry! if (*highest <= *access) { - 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 modify the access of \002{1}\002."), ci->GetName(), access->Mask()); return; @@ -219,9 +216,7 @@ class CommandCSFlags : public Command if (!u_access.HasPriv(it->first) && !u_access.founder) { - if (source.HasPriv("chanserv/access/modify")) - override = true; - else + if (!source.HasOverridePriv("chanserv/access/modify")) continue; } @@ -245,9 +240,7 @@ class CommandCSFlags : public Command continue; else if (!u_access.HasPriv(it->first) && !u_access.founder) { - if (source.HasPriv("chanserv/access/modify")) - override = true; - else + if (!source.HasOverridePriv("chanserv/access/modify")) { source.Reply(_("You can not set the \002{0}\002 flag."), f); break; @@ -267,7 +260,7 @@ class CommandCSFlags : public Command { EventManager::Get()->Dispatch(&Event::AccessDel::OnAccessDel, ci, source, current); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), current->Mask()); + logger.Command(source, ci, _("{source} used {command} on {channel} to delete {0}"), current->Mask()); source.Reply(_("\002{0}\002 removed from the access list of \002{1}\002."), current->Mask(), ci->GetName()); @@ -297,7 +290,7 @@ class CommandCSFlags : 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 modify flags of {0} to {1}"), access->Mask(), access->AccessSerialize()); + logger.Command(source, ci, _("{source} used {command} on {channel} to modify flags of {0} to {1}"), access->Mask(), access->AccessSerialize()); if (p != NULL) { @@ -376,7 +369,7 @@ class CommandCSFlags : public Command void DoClear(CommandSource &source, ChanServ::Channel *ci) { - if (!source.IsFounder(ci) && !source.HasPriv("chanserv/access/modify")) + if (!source.IsFounder(ci) && !source.HasOverridePriv("chanserv/access/modify")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->GetName()); return; @@ -388,8 +381,7 @@ class CommandCSFlags : public Command source.Reply(_("The access list of \002{0}\002 has been cleared."), ci->GetName()); - bool override = !source.IsFounder(ci); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clear the access list")); + logger.Command(source, ci, _("{source} used {command} on {channel} to clear the access list")); } public: diff --git a/modules/chanserv/getkey.cpp b/modules/chanserv/getkey.cpp index 2e6835672..309c6f52d 100644 --- a/modules/chanserv/getkey.cpp +++ b/modules/chanserv/getkey.cpp @@ -39,7 +39,7 @@ class CommandCSGetKey : public Command return; } - if (!source.AccessFor(ci).HasPriv("GETKEY") && !source.HasCommand("chanserv/getkey")) + if (!source.AccessFor(ci).HasPriv("GETKEY") && !source.HasOverrideCommand("chanserv/getkey")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "GETKEY", ci->GetName()); return; @@ -52,8 +52,7 @@ class CommandCSGetKey : public Command return; } - bool override = !source.AccessFor(ci).HasPriv("GETKEY"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel}")); + logger.Command(source, ci, _("{source} used {command} on {channel}")); source.Reply(_("Key for channel \002{0}\002 is \002{1}\002."), ci->GetName(), key); } diff --git a/modules/chanserv/invite.cpp b/modules/chanserv/invite.cpp index ae6cee04d..6e996dfb7 100644 --- a/modules/chanserv/invite.cpp +++ b/modules/chanserv/invite.cpp @@ -48,7 +48,7 @@ class CommandCSInvite : public Command return; } - if (!source.AccessFor(ci).HasPriv("INVITE") && !source.HasCommand("chanserv/invite")) + if (!source.AccessFor(ci).HasPriv("INVITE") && !source.HasOverrideCommand("chanserv/invite")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "INVITE", ci->GetName()); return; @@ -76,19 +76,17 @@ class CommandCSInvite : public Command return; } - bool override = !source.AccessFor(ci).HasPriv("INVITE"); - IRCD->Send<messages::Invite>(ci->WhoSends(), c, u2); if (u2 != u) { source.Reply(_("\002{0}\002 has been invited to \002{1}\002."), u2->nick, c->name); u2->SendMessage(ci->WhoSends(), _("You have been invited to \002{0}\002 by \002{1}\002."), c->name, source.GetNick()); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to invite {0}"), u2->nick); + logger.Command(source, ci, _("{source} used {command} on {channel} to invite {0}"), u2->nick); } else { u2->SendMessage(ci->WhoSends(), _("You have been invited to \002{0}\002."), c->name); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel}")); + logger.Command(source, ci, _("{source} used {command} on {channel}")); } } diff --git a/modules/chanserv/kick.cpp b/modules/chanserv/kick.cpp index fad7b9158..0c1333796 100644 --- a/modules/chanserv/kick.cpp +++ b/modules/chanserv/kick.cpp @@ -61,7 +61,7 @@ class CommandCSKick : public Command Anope::string signkickformat = Config->GetModule("chanserv/main")->Get<Anope::string>("signkickformat", "%m (%n)"); signkickformat = signkickformat.replace_all_cs("%n", source.GetNick()); - if (!u_access.HasPriv("KICK") && !source.HasPriv("chanserv/kick")) + if (!u_access.HasPriv("KICK") && !source.HasOverridePriv("chanserv/kick")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "KICK", ci->GetName()); return; @@ -70,26 +70,34 @@ class CommandCSKick : public Command if (u2) { ChanServ::AccessGroup u2_access = ci->AccessFor(u2); - if (u != u2 && ci->IsPeace() && u2_access >= u_access && !source.HasPriv("chanserv/kick")) + if (u != u2 && ci->IsPeace() && u2_access >= u_access && !source.HasOverridePriv("chanserv/kick")) + { source.Reply(_("Access denied. \002{0}\002 has the same or more privileges than you on \002{1}\002."), u2->nick, ci->GetName()); - else if (u2->IsProtected()) + return; + } + + if (u2->IsProtected()) + { source.Reply(_("Access denied. \002{0}\002 is protected and can not be kicked."), u2->nick); - else if (!c->FindUser(u2)) + return; + } + + if (!c->FindUser(u2)) + { source.Reply(_("User \002{0}\002 is not on channel \002{1}\002."), u2->nick, c->name); + return; + } + + logger.Command(source, ci, _("{source} used {command} on {channel} for {0}"), u2->nick); + + if (ci->IsSignKick() || (ci->IsSignKickLevel() && !u_access.HasPriv("SIGNKICK"))) + { + signkickformat = signkickformat.replace_all_cs("%m", reason); + c->Kick(ci->WhoSends(), u2, signkickformat); + } else { - bool override = !u_access.HasPriv("KICK") || (u != u2 && ci->IsPeace() && u2_access >= u_access); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} for {0}"), u2->nick); - - if (ci->IsSignKick() || (ci->IsSignKickLevel() && !u_access.HasPriv("SIGNKICK"))) - { - signkickformat = signkickformat.replace_all_cs("%m", reason); - c->Kick(ci->WhoSends(), u2, signkickformat); - } - else - { - c->Kick(ci->WhoSends(), u2, reason); - } + c->Kick(ci->WhoSends(), u2, reason); } } else if (u_access.HasPriv("FOUNDER")) diff --git a/modules/chanserv/list.cpp b/modules/chanserv/list.cpp index 4c6712b67..b0675b51e 100644 --- a/modules/chanserv/list.cpp +++ b/modules/chanserv/list.cpp @@ -207,7 +207,7 @@ class CommandCSSetPrivate : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -215,14 +215,14 @@ class CommandCSSetPrivate : public Command if (params[1].equals_ci("ON")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to enable private")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable private")); ci->SetPrivate(true); source.Reply(_("Private option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (params[1].equals_ci("OFF")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to disable private")); + logger.Command(source, ci, _("{source} used {command} on {channel} to disable private")); ci->SetPrivate(false); source.Reply(_("Private option for \002{0}\002 is now \002off\002."), ci->GetName()); diff --git a/modules/chanserv/log.cpp b/modules/chanserv/log.cpp index 7e7fb084a..1f67f4029 100644 --- a/modules/chanserv/log.cpp +++ b/modules/chanserv/log.cpp @@ -178,7 +178,7 @@ public: return; } - if (!source.AccessFor(ci).HasPriv("SET") && !source.HasPriv("chanserv/administration")) + if (!source.AccessFor(ci).HasPriv("SET") && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -285,7 +285,7 @@ public: { if (log->GetExtra() == extra) { - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to remove logging for {0} with method {1}"), + logger.Command(source, ci, _("{source} used {command} on {channel} to remove logging for {0} with method {1}"), command, method + (extra.empty() ? "" : (" " + extra))); source.Reply(_("Logging for command \002{0}\002 on \002{1}\002 with log method \002{2}{3}{4}\002 has been removed."), @@ -297,7 +297,7 @@ public: { log->SetExtra(extra); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to change logging for {0} to method {1}"), + logger.Command(source, ci, _("{source} used {command} on {channel} to change logging for {0} to method {1}"), command, method + (extra.empty() ? "" : (" " + extra))); source.Reply(_("Logging changed for command \002{0}\002 on \002{1}\002, now using log method \002{2}{3}{4]\002."), @@ -319,7 +319,7 @@ public: log->SetCreated(Anope::CurTime); log->SetCreator(source.GetNick()); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, + logger.Command(source, ci, _("{source} used {command} on {channel} to log {0} to method {1}"), command, method + (extra.empty() ? "" : (" " + extra))); source.Reply(_("Logging is now active for command \002{0}\002 on \002{1}\002, using log method \002{2}{3}{4}\002."), diff --git a/modules/chanserv/mode.cpp b/modules/chanserv/mode.cpp index c828e19ae..f0acd8456 100644 --- a/modules/chanserv/mode.cpp +++ b/modules/chanserv/mode.cpp @@ -276,8 +276,6 @@ class CommandCSMode : public Command const Anope::string &subcommand = params[2]; const Anope::string ¶m = params.size() > 3 ? params[3] : ""; - bool override = !source.AccessFor(ci).HasPriv("MODE"); - if (Anope::ReadOnly && !subcommand.equals_ci("LIST")) { source.Reply(_("Services are in read-only mode.")); @@ -375,7 +373,7 @@ class CommandCSMode : public Command { source.Reply(_("\002{0}\002 locked on \002{1}\002."), reply, ci->GetName()); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to lock {0}"), reply); + logger.Command(source, ci, _("{source} used {command} on {channel} to lock {0}"), reply); } else if (needreply) { @@ -432,7 +430,7 @@ class CommandCSMode : public Command mode_param = " " + mode_param; source.Reply(_("\002{0}{1}{2}\002 has been unlocked from \002{3}\002."), adding == 1 ? '+' : '-', cm->mchar, mode_param, ci->GetName()); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to unlock {0}"), + logger.Command(source, ci, _("{source} used {command} on {channel} to unlock {0}"), (adding ? '+' : '-') + cm->mchar + mode_param); } else @@ -489,14 +487,12 @@ class CommandCSMode : public Command { User *u = source.GetUser(); - bool has_access = source.AccessFor(ci).HasPriv("MODE") || source.HasPriv("chanserv/administration"); - bool can_override = source.HasPriv("chanserv/administration"); + bool has_access = source.AccessFor(ci).HasPriv("MODE") || source.HasOverridePriv("chanserv/administration"); spacesepstream sep(params.size() > 3 ? params[3] : ""); Anope::string modes = params[2], param; - bool override = !source.AccessFor(ci).HasPriv("MODE") && source.HasPriv("chanserv/administration"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to set {3}"), + logger.Command(source, ci, _("{source} used {command} on {channel} to set {3}"), params[2] + (params.size() > 3 ? " " + params[3] : "")); int adding = -1; @@ -517,7 +513,7 @@ class CommandCSMode : public Command { ChannelMode *cm = ModeManager::GetChannelModes()[j]; - if (!u || cm->CanSet(u) || can_override) + if (!u || cm->CanSet(u) || source.IsOverride()) { if (cm->type == MODE_REGULAR || (!adding && cm->type == MODE_PARAM)) { @@ -533,7 +529,7 @@ class CommandCSMode : public Command if (adding == -1) break; ChannelMode *cm = ModeManager::FindChannelModeByChar(modes[i]); - if (!cm || (u && !cm->CanSet(u) && !can_override)) + if (!cm || (u && !cm->CanSet(u) && !source.IsOverride())) continue; switch (cm->type) { @@ -564,7 +560,7 @@ class CommandCSMode : public Command if (param.find_first_of("*?") != Anope::string::npos) { - if (!this->CanSet(source, ci, cm, false) && !can_override) + if (!this->CanSet(source, ci, cm, false) && !source.IsOverride()) { source.Reply(_("You do not have access to set mode \002{0}\002."), cm->mchar); break; @@ -577,7 +573,7 @@ class CommandCSMode : public Command ChanServ::AccessGroup targ_access = ci->AccessFor(uc->user); - if (uc->user->IsProtected() || (ci->IsPeace() && targ_access >= u_access && !can_override)) + if (uc->user->IsProtected() || (ci->IsPeace() && targ_access >= u_access && !source.IsOverride())) { source.Reply(_("You do not have the access to change the modes of \002{0}\002."), uc->user->nick.c_str()); continue; @@ -601,7 +597,7 @@ class CommandCSMode : public Command break; } - if (!this->CanSet(source, ci, cm, source.GetUser() == target) && !can_override) + if (!this->CanSet(source, ci, cm, source.GetUser() == target) && !source.IsOverride()) { source.Reply(_("You do not have access to set mode \002{0}\002."), cm->mchar); break; @@ -610,7 +606,7 @@ class CommandCSMode : public Command if (source.GetUser() != target) { ChanServ::AccessGroup targ_access = ci->AccessFor(target); - if (ci->IsPeace() && targ_access >= u_access && !can_override) + if (ci->IsPeace() && targ_access >= u_access && !source.IsOverride()) { source.Reply(_("You do not have the access to change the modes of \002{0}\002"), target->nick); break; @@ -720,10 +716,13 @@ class CommandCSMode : public Command if (subcommand.equals_ci("LOCK") && params.size() > 2) { - if (!source.AccessFor(ci).HasPriv("MODE") && !source.HasPriv("chanserv/administration")) + if (!source.AccessFor(ci).HasPriv("MODE") && !source.HasOverridePriv("chanserv/administration")) + { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "MODE", ci->GetName()); - else - this->DoLock(source, ci, params); + return; + } + + this->DoLock(source, ci, params); } else if (!ci->c) { @@ -810,37 +809,26 @@ class CommandCSModes : public Command ChanServ::AccessGroup u_access = source.AccessFor(ci), targ_access = ci->AccessFor(targ); const std::pair<bool, Anope::string> &m = modes[source.GetCommand()]; - bool can_override = source.HasPriv("chanserv/administration"); - bool override = false; - if (m.second.empty()) return; // Configuration issue const Anope::string &want = u == targ ? m.second + "ME" : m.second; if (!u_access.HasPriv(want)) { - if (!can_override) + if (!source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), want, ci->GetName()); return; } - else - { - override = true; - } } - if (!override && !m.first && u != targ && (targ->IsProtected() || (ci->IsPeace() && targ_access >= u_access))) + if (!m.first && u != targ && (targ->IsProtected() || (ci->IsPeace() && targ_access >= u_access))) { - if (!can_override) + if (!source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. \002{0}\002 has the same or more privileges than you on \002{1}\002."), targ->nick, ci->GetName()); return; } - else - { - override = true; - } } if (!ci->c->FindUser(targ)) @@ -854,7 +842,7 @@ class CommandCSModes : public Command else ci->c->RemoveMode(NULL, m.second, targ->GetUID()); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} on {3}"), targ->nick); + logger.Command(source, ci, _("{source} used {command} on {channel} on {3}"), targ->nick); } const Anope::string GetDesc(CommandSource &source) const override diff --git a/modules/chanserv/set.cpp b/modules/chanserv/set.cpp index 1584052f3..7c7233b79 100644 --- a/modules/chanserv/set.cpp +++ b/modules/chanserv/set.cpp @@ -109,7 +109,7 @@ class CommandCSSetAutoOp : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -117,14 +117,14 @@ class CommandCSSetAutoOp : public Command if (params[1].equals_ci("ON")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable autoop")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable autoop")); ci->SetNoAutoop(false); source.Reply(_("Services will now automatically give modes to users in \002{0}\002."), ci->GetName()); } else if (params[1].equals_ci("OFF")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable autoop")); + logger.Command(source, ci, _("{source} used {command} on {channel} to disable autoop")); ci->SetNoAutoop(true); source.Reply(_("Services will no longer automatically give modes to users in \002{0}\002."), ci->GetName()); @@ -173,7 +173,7 @@ class CommandCSSetBanType : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -185,7 +185,7 @@ class CommandCSSetBanType : public Command if (new_type < 0 || new_type > 3) throw ConvertException("Invalid range"); - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to change the ban type to {0}"), new_type); + logger.Command(source, ci, _("{source} used {command} on {channel} to change the ban type to {0}"), new_type); ci->SetBanType(new_type); source.Reply(_("Ban type for channel \002{0}\002 is now \002#{1}\002."), ci->GetName(), new_type); @@ -242,7 +242,7 @@ class CommandCSSetDescription : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -251,13 +251,13 @@ class CommandCSSetDescription : public Command ci->SetDesc(param); if (!param.empty()) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to change the description to {0}"), ci->GetDesc()); + logger.Command(source, ci, _("{source} used {command} on {channel} to change the description to {0}"), ci->GetDesc()); source.Reply(_("Description of \002{0}\002 changed to \002{1}\002."), ci->GetName(), ci->GetDesc()); } else { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to unset the description")); + logger.Command(source, ci, _("{source} used {command} on {channel} to unset the description")); source.Reply(_("Description of \002{0}\002 unset."), ci->GetName()); } @@ -302,7 +302,7 @@ class CommandCSSetFounder : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && (ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && (ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->GetName()); return; @@ -323,7 +323,7 @@ class CommandCSSetFounder : public Command return; } - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to change the founder from {0} to {1}"), + logger.Command(source, ci, _("{source} used {command} on {channel} to change the founder from {0} to {1}"), ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "(none)", nc->GetDisplay()); ci->SetFounder(nc); @@ -372,7 +372,7 @@ class CommandCSSetKeepModes : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -380,7 +380,7 @@ class CommandCSSetKeepModes : public Command if (param.equals_ci("ON")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable keep modes")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable keep modes")); ci->SetKeepModes(true); source.Reply(_("Keep modes for \002{0}\002 is now \002on\002."), ci->GetName()); @@ -395,7 +395,7 @@ class CommandCSSetKeepModes : public Command } else if (param.equals_ci("OFF")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable keep modes")); + logger.Command(source, ci, _("{source} used {command} on {channel} to disable keep modes")); ci->SetKeepModes(false); source.Reply(_("Keep modes for \002{0}\002 is now \002off\002."), ci->GetName()); @@ -447,7 +447,7 @@ class CommandCSSetPeace : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -455,14 +455,14 @@ class CommandCSSetPeace : public Command if (param.equals_ci("ON")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable peace")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable peace")); ci->SetPeace(true); source.Reply(_("Peace option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable peace")); + logger.Command(source, ci, _("{source} used {command} on {channel} to disable peace")); ci->SetPeace(false); source.Reply(_("Peace option for \002{0}\002 is now \002off\002."), ci->GetName()); @@ -523,7 +523,7 @@ class CommandCSSetPersist : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -581,7 +581,7 @@ class CommandCSSetPersist : public Command } } - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable persist")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable persist")); source.Reply(_("Channel \002{0}\002 is now persistent."), ci->GetName()); } @@ -619,7 +619,7 @@ class CommandCSSetPersist : public Command } } - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable persist")); + logger.Command(source, ci, _("{source} used {command} on {channel} to disable persist")); source.Reply(_("Channel \002{0}\002 is no longer persistent."), ci->GetName()); } @@ -669,7 +669,7 @@ class CommandCSSetRestricted : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -677,14 +677,14 @@ class CommandCSSetRestricted : public Command if (param.equals_ci("ON")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable restricted")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable restricted")); ci->SetRestricted(true); source.Reply(_("Restricted access option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disabled restricted")); + logger.Command(source, ci, _("{source} used {command} on {channel} to disabled restricted")); ci->SetRestricted(false); source.Reply(_("Restricted access option for \002{0}\002 is now \002off\002."), ci->GetName()); @@ -734,7 +734,7 @@ class CommandCSSetSecure : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -742,14 +742,14 @@ class CommandCSSetSecure : public Command if (param.equals_ci("ON")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable secure")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable secure")); ci->SetSecure(true); source.Reply(_("Secure option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable secure")); + logger.Command(source, ci, _("{source} used {command} on {channel} to disable secure")); ci->SetSecure(false); source.Reply(_("Secure option for \002{0}\002 is now \002off\002."), ci->GetName()); @@ -801,7 +801,7 @@ class CommandCSSetSecureFounder : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && (ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && (ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->GetName()); return; @@ -809,14 +809,14 @@ class CommandCSSetSecureFounder : public Command if (param.equals_ci("ON")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable secure founder")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable secure founder")); ci->SetSecureFounder(true); source.Reply(_("Secure founder option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable secure founder")); + logger.Command(source, ci, _("{source} used {command} on {channel} to disable secure founder")); ci->SetSecureFounder(false); source.Reply(_("Secure founder option for \002{0}\002 is now \002off\002."), ci->GetName()); @@ -871,7 +871,7 @@ class CommandCSSetSecureOps : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -879,14 +879,14 @@ class CommandCSSetSecureOps : public Command if (param.equals_ci("ON")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable secure ops")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable secure ops")); ci->SetSecureOps(true); source.Reply(_("Secure ops option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable secure ops")); + logger.Command(source, ci, _("{source} used {command} on {channel} to disable secure ops")); ci->SetSecureOps(false); source.Reply(_("Secure ops option for \002{0}\002 is now \002off\002."), ci->GetName()); @@ -937,7 +937,7 @@ class CommandCSSetSignKick : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -949,7 +949,7 @@ class CommandCSSetSignKick : public Command ci->SetSignKickLevel(false); source.Reply(_("Signed kick option for \002{0}\002 is now \002on\002."), ci->GetName()); - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable sign kick")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable sign kick")); } else if (param.equals_ci("LEVEL")) { @@ -957,7 +957,7 @@ class CommandCSSetSignKick : public Command ci->SetSignKickLevel(true); source.Reply(_("Signed kick option for \002{0}\002 is now \002on\002, but depends of the privileges of the user that is using the command."), ci->GetName()); - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to enable sign kick level")); + logger.Command(source, ci, _("{source} used {command} on {channel} to enable sign kick level")); } else if (param.equals_ci("OFF")) { @@ -965,7 +965,7 @@ class CommandCSSetSignKick : public Command ci->SetSignKickLevel(false); source.Reply(_("Signed kick option for \002{0}\002 is now \002off\002."), ci->GetName()); - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to disable sign kick")); + logger.Command(source, ci, _("{source} used {command} on {channel} to disable sign kick")); } else { @@ -1015,7 +1015,7 @@ class CommandCSSetSuccessor : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && (ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && (ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->GetName()); return; @@ -1042,7 +1042,7 @@ class CommandCSSetSuccessor : public Command nc = na->GetAccount(); } - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to change the successor from {0} to {1}"), + logger.Command(source, ci, _("{source} used {command} on {channel} to change the successor from {0} to {1}"), ci->GetSuccessor() ? ci->GetSuccessor()->GetDisplay() : "(none)", nc ? nc->GetDisplay() : "(none)"); ci->SetSuccessor(nc); @@ -1097,14 +1097,14 @@ class CommandCSSetNoexpire : public Command if (param.equals_ci("ON")) { - logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} to enable noexpire")); + logger.Admin(source, ci, _("{source} used {command} on {channel} to enable noexpire")); ci->SetNoExpire(true); source.Reply(_("Channel \002{0} will not\002 expire."), ci->GetName()); } else if (param.equals_ci("OFF")) { - logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} to disable noexpire")); + logger.Admin(source, ci, _("{source} used {command} on {channel} to disable noexpire")); ci->SetNoExpire(false); source.Reply(_("Channel \002{0} will\002 expire."), ci->GetName()); diff --git a/modules/chanserv/set_misc.cpp b/modules/chanserv/set_misc.cpp index 144010d2b..9c16d227a 100644 --- a/modules/chanserv/set_misc.cpp +++ b/modules/chanserv/set_misc.cpp @@ -128,7 +128,7 @@ class CommandCSSetMisc : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -151,7 +151,7 @@ class CommandCSSetMisc : public Command data->SetName(scommand); data->SetData(param); - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, + logger.Command(source, ci, _("{source} used {command} on {channel} to change it to {0}"), param); @@ -159,7 +159,7 @@ class CommandCSSetMisc : public Command } else { - logger.Command(source.AccessFor(ci).HasPriv("SET") ? LogType::COMMAND : LogType::OVERRIDE, source, ci, _("{source} used {command} on {channel} to unset it")); + logger.Command(source, ci, _("{source} used {command} on {channel} to unset it")); source.Reply(_("\002{0}\002 for \002{1}\002 unset."), scommand, ci->GetName()); } diff --git a/modules/chanserv/suspend.cpp b/modules/chanserv/suspend.cpp index c686ffdb7..b796b1dc9 100644 --- a/modules/chanserv/suspend.cpp +++ b/modules/chanserv/suspend.cpp @@ -189,7 +189,7 @@ class CommandCSSuspend : public Command ci->c->Kick(NULL, users[i], !reason.empty() ? reason : Language::Translate(users[i], _("This channel has been suspended."))); } - logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} ({0}), expires on {1}"), + logger.Admin(source, ci, _("{source} used {command} on {channel} ({0}), expires on {1}"), !reason.empty() ? reason : "No reason", expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); source.Reply(_("Channel \002{0}\002 is now suspended."), ci->GetName()); @@ -236,7 +236,7 @@ class CommandCSUnSuspend : public Command return; } - logger.Command(LogType::ADMIN, source, ci, _("{source} used {command} on {channel} which was suspended by {0} for: {1}"), + logger.Admin(source, ci, _("{source} used {command} on {channel} which was suspended by {0} for: {1}"), si->GetBy(), !si->GetReason().empty() ? si->GetReason() : "No reason"); si->Delete(); diff --git a/modules/chanserv/sync.cpp b/modules/chanserv/sync.cpp index c532d4fad..20cc95b0a 100644 --- a/modules/chanserv/sync.cpp +++ b/modules/chanserv/sync.cpp @@ -45,14 +45,13 @@ class CommandCSSync : public Command return; } - if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && !source.HasPriv("chanserv/administration")) + if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "ACCESS_CHANGE", ci->GetName()); return; } - bool override = !source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/administration"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel}")); + logger.Command(source, ci, _("{source} used {command} on {channel}")); for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) ci->c->SetCorrectModes(it->second->user, true); diff --git a/modules/chanserv/topic.cpp b/modules/chanserv/topic.cpp index 3b4251b58..d3546562e 100644 --- a/modules/chanserv/topic.cpp +++ b/modules/chanserv/topic.cpp @@ -54,7 +54,7 @@ class CommandCSSetKeepTopic : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.GetPermission().empty() && !source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "SET", ci->GetName()); return; @@ -62,14 +62,14 @@ class CommandCSSetKeepTopic : public Command if (param.equals_ci("ON")) { - logger.Command(!source.AccessFor(ci).HasPriv("SET") ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to enable keeptopic")); + logger.Command(source, _("{source} used {command} on {channel} to enable keeptopic")); ci->SetKeepTopic(true); source.Reply(_("Topic retention option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { - logger.Command(!source.AccessFor(ci).HasPriv("SET") ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to disable keeptopic")); + logger.Command(source, _("{source} used {command} on {channel} to disable keeptopic")); ci->SetKeepTopic(false); source.Reply(_("Topic retention option for \002{0}\002 is now \002off\002."), ci->GetName()); @@ -133,11 +133,10 @@ class CommandCSTopic : public Command if (has_topiclock) ci->SetTopicLock(true); - bool override = !source.AccessFor(ci).HasPriv("TOPIC"); if (!topic.empty()) - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to change the topic to: {0}"), topic); + logger.Command(source, _("{source} used {command} on {channel} to change the topic to: {0}"), topic); else - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to unset the topic")); + logger.Command(source, _("{source} used {command} on {channel} to unset the topic")); } void Append(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) @@ -179,7 +178,7 @@ class CommandCSTopic : public Command return; } - if (!source.AccessFor(ci).HasPriv("TOPIC") && !source.HasCommand("chanserv/topic")) + if (!source.AccessFor(ci).HasPriv("TOPIC") && !source.HasOverrideCommand("chanserv/topic")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "TOPIC", ci->GetName()); return; diff --git a/modules/chanserv/unban.cpp b/modules/chanserv/unban.cpp index ac7c08fdf..d519b4e50 100644 --- a/modules/chanserv/unban.cpp +++ b/modules/chanserv/unban.cpp @@ -74,7 +74,7 @@ class CommandCSUnban : public Command return; } - if (!source.AccessFor(ci).HasPriv("UNBAN") && !source.HasPriv("chanserv/kick")) + if (!source.AccessFor(ci).HasPriv("UNBAN") && !source.HasOverridePriv("chanserv/kick")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "UNBAN", ci->GetName()); return; @@ -91,8 +91,7 @@ class CommandCSUnban : public Command return; } - bool override = !source.AccessFor(ci).HasPriv("UNBAN") && source.HasPriv("chanserv/kick"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, _("{source} used {command} on {channel} to unban {0}"), u2->nick); + logger.Command(source, _("{source} used {command} on {channel} to unban {0}"), u2->nick); for (unsigned i = 0; i < modes.size(); ++i) ci->c->Unban(u2, modes[i]->name, source.GetUser() == u2); diff --git a/modules/chanserv/updown.cpp b/modules/chanserv/updown.cpp index d3ceb617a..398726569 100644 --- a/modules/chanserv/updown.cpp +++ b/modules/chanserv/updown.cpp @@ -92,7 +92,6 @@ class CommandCSUp : public Command User *u = User::Find(nick, true); User *srcu = source.GetUser(); Channel *c = ci->c; - bool override = false; if (u == NULL) { @@ -102,12 +101,6 @@ class CommandCSUp : public Command if (srcu && !srcu->FindChannel(c)) { - source.Reply(_("You must be in \002%s\002 to use this command."), c->name.c_str()); - return; - } - - if (!u->FindChannel(c)) - { source.Reply(_("You must be on channel \002{0}\002 to use this command."), c->name); return; } @@ -122,9 +115,7 @@ class CommandCSUp : public Command { if (c->ci->AccessFor(u) >= c->ci->AccessFor(source.GetUser())) { - if (source.HasPriv("chanserv/administration")) - override = true; - else + if (!source.HasOverridePriv("chanserv/administration")) { source.Reply(_("Access denied. \002{0}\002 has more privileges than you on \002{1}\002."), u->nick, ci->GetName()); return; @@ -132,7 +123,7 @@ class CommandCSUp : public Command } } - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to update the status modes of {0}"), u->nick); + logger.Command(source, ci, _("{source} used {command} on {channel} to update the status modes of {0}"), u->nick); SetModes(u, c); } @@ -198,7 +189,6 @@ class CommandCSDown : public Command Channel *c = ci->c; User *srcu = source.GetUser(); - bool override = false; if (u == NULL) { @@ -212,12 +202,6 @@ class CommandCSDown : public Command return; } - if (srcu && !srcu->FindChannel(c)) - { - source.Reply(_("You must be in \002%s\002 to use this command."), c->name.c_str()); - return; - } - if (!u->FindChannel(c)) { source.Reply(_("\002%s\002 is not on channel %s."), u->nick, c->name); @@ -228,9 +212,7 @@ class CommandCSDown : public Command { if (c->ci->AccessFor(u) >= c->ci->AccessFor(source.GetUser())) { - if (source.HasPriv("chanserv/administration")) - override = true; - else + if (!source.HasPriv("chanserv/administration")) { source.Reply(_("Access denied. \002{0}\002 has more privileges than you on \002{1}\002."), u->nick, ci->GetName()); return; @@ -238,7 +220,7 @@ class CommandCSDown : public Command } } - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to remove the status modes from {0}"), u->nick); + logger.Command(source, ci, _("{source} used {command} on {channel} to remove the status modes from {0}"), u->nick); RemoveAll(u, c); } diff --git a/modules/chanserv/xop.cpp b/modules/chanserv/xop.cpp index 4dd5f8b3e..91fc7e4f1 100644 --- a/modules/chanserv/xop.cpp +++ b/modules/chanserv/xop.cpp @@ -140,16 +140,13 @@ class CommandCSXOP : public Command ChanServ::AccessGroup access = source.AccessFor(ci); ChanServ::ChanAccess *highest = access.Highest(); - bool override = false; std::vector<Anope::string>::iterator cmd_it = std::find(order.begin(), order.end(), source.GetCommand().upper()), access_it = highest ? std::find(order.begin(), order.end(), XOPChanAccessImpl::DetermineLevel(highest)) : order.end(); if (!access.founder && (!access.HasPriv("ACCESS_CHANGE") || cmd_it <= access_it)) { - if (source.HasPriv("chanserv/access/modify")) - override = true; - else + if (!source.HasPriv("chanserv/access/modify")) { source.Reply(_("Access denied. You do not have the \002{0}\002 privilege on \002{1}\002."), "ACCESS_CHANGE", ci->GetName()); return; @@ -244,7 +241,7 @@ class CommandCSXOP : public Command acc->SetLastSeen(0); acc->SetCreated(Anope::CurTime); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to add {0}"), mask); + logger.Command(source, ci, _("{source} used {command} on {channel} to add {0}"), mask); EventManager::Get()->Dispatch(&Event::AccessAdd::OnAccessAdd, ci, source, acc); source.Reply(_("\002{0}\002 added to {1} {2} list."), acc->Mask(), ci->GetName(), source.GetCommand()); @@ -275,7 +272,6 @@ class CommandCSXOP : public Command ChanServ::AccessGroup access = source.AccessFor(ci); ChanServ::ChanAccess *highest = access.Highest(); - bool override = false; if (!isdigit(mask[0]) && mask.find_first_of("#!*@") == Anope::string::npos && !NickServ::FindNick(mask)) { @@ -294,9 +290,7 @@ class CommandCSXOP : public Command if (!mask.equals_ci(nc->GetDisplay()) && !access.founder && (!access.HasPriv("ACCESS_CHANGE") || cmd_it <= access_it)) { - if (source.HasPriv("chanserv/access/modify")) - override = true; - else + if (!source.HasPriv("chanserv/access/modify")) { source.Reply(_("Access denied. You do not have the \002{0}\002 privilege on \002{1}\002."), "ACCESS_CHANGE", ci->GetName()); return; @@ -335,7 +329,7 @@ class CommandCSXOP : public Command source.Reply(_("No matching entries on {0} {1} list."), ci->GetName(), source.GetCommand()); else { - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), nicks); + logger.Command(source, ci, _("{source} used {command} on {channel} to delete {0}"), nicks); if (deleted == 1) source.Reply(_("Deleted one entry from {0} {1} list."), ci->GetName(), source.GetCommand()); @@ -355,7 +349,7 @@ class CommandCSXOP : public Command if (a->Mask().equals_ci(mask)) { - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to delete {0}"), a->GetMask()); + logger.Command(source, ci, _("{source} used {command} on {channel} to delete {0}"), a->GetMask()); source.Reply(_("\002{0}\002 deleted from {1} {2} list."), a->Mask(), ci->GetName(), source.GetCommand()); @@ -459,14 +453,13 @@ class CommandCSXOP : public Command return; } - if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("chanserv/access/modify")) + if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasOverridePriv("chanserv/access/modify")) { source.Reply(_("Access denied. You do not have the \002{0}\002 privilege on \002{1}\002."), "FOUNDER", ci->GetName()); return; } - bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); - logger.Command(override ? LogType::OVERRIDE : LogType::COMMAND, source, ci, _("{source} used {command} on {channel} to clear the access list")); + logger.Command(source, ci, _("{source} used {command} on {channel} to clear the access list")); for (unsigned i = ci->GetAccessCount(); i > 0; --i) { |
