diff options
Diffstat (limited to 'modules/commands')
30 files changed, 233 insertions, 144 deletions
diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index 2413e6b6d..f4beba6e6 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -202,7 +202,10 @@ class CommandBSBot : public Command } if (!user.empty()) + { IRCD->SendQuit(bi, "Quit: Be right back"); + bi->introduced = false; + } else IRCD->SendNickChange(bi, nick); @@ -217,18 +220,7 @@ class CommandBSBot : public Command bi->realname = real; if (!user.empty()) - { - IRCD->SendClientIntroduction(bi); - unsigned minusers = Config->GetBlock("botserv")->Get<unsigned>("minusers"); - const std::set<ChanServ::Channel *> &channels = bi->GetChannels(); - for (std::set<ChanServ::Channel *>::const_iterator it = channels.begin(), it_end = channels.end(); it != it_end; ++it) - { - const ChanServ::Channel *ci = *it; - - if (ci->c && ci->c->users.size() >= minusers) - bi->Join(ci->c); - } - } + bi->OnKill(); 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); Log(LOG_ADMIN, source, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname; diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index c0ea685c5..b263b3988 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -322,7 +322,7 @@ class CommandBSKickBolds : public CommandBSKickBase public: CommandBSKickBolds(Module *creator) : CommandBSKickBase(creator, "botserv/kick/bolds", 2, 3) { - this->SetDesc(_("Configures badwords kicker")); + this->SetDesc(_("Configures bolds kicker")); this->SetSyntax(_("\037channel\037 {\037ON|OFF\037} [\037ttb\037]")); } diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index c9dfe08cb..a1153cac6 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -185,12 +185,12 @@ class CommandCSAccess : public Command for (unsigned i = ci->GetAccessCount(); i > 0; --i) { const ChanServ::ChanAccess *access = ci->GetAccess(i - 1); - if (mask.equals_ci(access->mask)) + 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")) { - source.Reply(_("Access denied. You do not have enough privileges on \002{0}\002 to lower the access of \002{1}\002."), ci->name, access->mask); + source.Reply(_("Access denied. You do not have enough privileges on \002{0}\002 to lower the access of \002{1}\002."), ci->name, access->Mask()); return; } delete ci->EraseAccess(i - 1); @@ -209,8 +209,7 @@ class CommandCSAccess : public Command if (!provider) return; AccessChanAccess *access = anope_dynamic_static_cast<AccessChanAccess *>(provider->Create()); - access->ci = ci; - access->mask = mask; + access->SetMask(mask, ci); access->creator = source.GetNick(); access->level = level; access->last_seen = 0; @@ -221,9 +220,9 @@ class CommandCSAccess : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << " with level " << 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->name, p->name, level); + 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->name, p->name, level); else - source.Reply(_("\002{0}\002 added to the access list of \002{1}\002 at level \002{2}\002."), access->mask, ci->name, level); + source.Reply(_("\002{0}\002 added to the access list of \002{1}\002 at level \002{2}\002."), access->Mask(), ci->name, level); } void DoDel(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) @@ -294,7 +293,7 @@ class CommandCSAccess : public Command ChanServ::AccessGroup ag = source.AccessFor(ci); const ChanServ::ChanAccess *u_highest = ag.Highest(); - if ((!u_highest || *u_highest <= *access) && !ag.founder && !this->override && !access->mask.equals_ci(source.nc->display)) + if ((!u_highest || *u_highest <= *access) && !ag.founder && !this->override && access->GetAccount() != source.nc) { denied = true; return; @@ -302,9 +301,9 @@ class CommandCSAccess : public Command ++deleted; if (!Nicks.empty()) - Nicks += ", " + access->mask; + Nicks += ", " + access->Mask(); else - Nicks = access->mask; + Nicks = access->Mask(); ci->EraseAccess(Number - 1); @@ -323,15 +322,15 @@ class CommandCSAccess : public Command for (unsigned i = ci->GetAccessCount(); i > 0; --i) { ChanServ::ChanAccess *access = ci->GetAccess(i - 1); - if (mask.equals_ci(access->mask)) + if (mask.equals_ci(access->Mask())) { - if (!access->mask.equals_ci(source.nc->display) && !u_access.founder && (!highest || *highest <= *access) && !source.HasPriv("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->name, access->mask); + if (access->GetAccount() != source.nc && !u_access.founder && (!highest || *highest <= *access) && !source.HasPriv("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->name, access->Mask()); else { - source.Reply(_("\002{0}\002 deleted from the access list of \002{1}\002."), access->mask, ci->name); - bool override = !u_access.founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->mask.equals_ci(source.nc->display); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->mask; + source.Reply(_("\002{0}\002 deleted from the access list of \002{1}\002."), access->Mask(), ci->name); + bool override = !u_access.founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->Mask().equals_ci(source.nc->display); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->Mask(); ci->EraseAccess(i - 1); Event::OnAccessDel(&Event::AccessDel::OnAccessDel, ci, source, access); @@ -393,7 +392,7 @@ class CommandCSAccess : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(number); entry["Level"] = access->AccessSerialize(); - entry["Mask"] = access->mask; + entry["Mask"] = access->Mask(); entry["By"] = access->creator; entry["Last seen"] = timebuf; this->list.AddEntry(entry); @@ -408,7 +407,7 @@ class CommandCSAccess : public Command { const ChanServ::ChanAccess *access = ci->GetAccess(i); - if (!nick.empty() && !Anope::Match(access->mask, nick)) + if (!nick.empty() && !Anope::Match(access->Mask(), nick)) continue; Anope::string timebuf; @@ -430,7 +429,7 @@ class CommandCSAccess : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(i + 1); entry["Level"] = access->AccessSerialize(); - entry["Mask"] = access->mask; + entry["Mask"] = access->Mask(); entry["By"] = access->creator; entry["Last seen"] = timebuf; list.AddEntry(entry); diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp index 3571ccdf3..e8674600d 100644 --- a/modules/commands/cs_ban.cpp +++ b/modules/commands/cs_ban.cpp @@ -19,15 +19,16 @@ class TempBan : public Timer private: Anope::string channel; Anope::string mask; + Anope::string mode; public: - TempBan(time_t seconds, Channel *c, const Anope::string &banmask) : Timer(me, seconds), channel(c->name), mask(banmask) { } + TempBan(time_t seconds, Channel *c, const Anope::string &banmask, const Anope::string &mod) : Timer(me, seconds), channel(c->name), mask(banmask), mode(mod) { } void Tick(time_t ctime) override { Channel *c = Channel::Find(this->channel); if (c) - c->RemoveMode(NULL, "BAN", this->mask); + c->RemoveMode(NULL, mode, this->mask); } }; @@ -43,6 +44,8 @@ class CommandCSBan : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { const Anope::string &chan = params[0]; + Configuration::Block *block = Config->GetCommand(source); + const Anope::string &mode = block->Get<Anope::string>("mode", "BAN"); ChanServ::Channel *ci = ChanServ::Find(chan); if (ci == NULL) @@ -58,9 +61,9 @@ class CommandCSBan : public Command return; } - if (IRCD->GetMaxListFor(c) && c->HasMode("BAN") >= IRCD->GetMaxListFor(c)) + if (IRCD->GetMaxListFor(c) && c->HasMode(mode) >= IRCD->GetMaxListFor(c)) { - source.Reply(_("The ban list for %s is full."), c->name.c_str()); + source.Reply(_("The %s list for %s is full."), mode.lower().c_str(), c->name.c_str()); return; } @@ -141,12 +144,12 @@ class CommandCSBan : public Command bool override = !u_access.HasPriv("BAN") || (u != u2 && ci->HasExt("PEACE") && u2_access >= u_access); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << mask; - if (!c->HasMode("BAN", mask)) + if (!c->HasMode(mode, mask)) { - c->SetMode(NULL, "BAN", mask); + c->SetMode(NULL, mode, mask); if (ban_time) { - new TempBan(ban_time, c, mask); + new TempBan(ban_time, c, mask, mode); source.Reply(_("Ban on \002{0}\002 expires in \002{1}\002."), mask, Anope::Duration(ban_time, source.GetAccount())); } } @@ -155,10 +158,13 @@ class CommandCSBan : public Command if (!c->FindUser(u2)) return; - if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !source.AccessFor(ci).HasPriv("SIGNKICK"))) - c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), source.GetNick().c_str()); - else - c->Kick(ci->WhoSends(), u2, "%s", reason.c_str()); + if (block->Get<bool>("kick", "yes")) + { + if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !source.AccessFor(ci).HasPriv("SIGNKICK"))) + c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), source.GetNick().c_str()); + else + c->Kick(ci->WhoSends(), u2, "%s", reason.c_str()); + } } else { @@ -166,12 +172,12 @@ class CommandCSBan : public Command bool override = !founder && !u_access.HasPriv("BAN"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << target; - if (!c->HasMode("BAN", target)) + if (!c->HasMode(mode, target)) { - c->SetMode(NULL, "BAN", target); + c->SetMode(NULL, mode, target); if (ban_time) { - new TempBan(ban_time, c, target); + new TempBan(ban_time, c, target, mode); source.Reply(_("Ban on \002{0}\002 expires in \002{1}\002."), target, Anope::Duration(ban_time, source.GetAccount())); } } @@ -197,11 +203,14 @@ class CommandCSBan : public Command else if (uc->user->IsProtected()) continue; - ++kicked; - if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !u_access.HasPriv("SIGNKICK"))) - c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s) (%s)", reason.c_str(), target.c_str(), source.GetNick().c_str()); - else - c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s)", reason.c_str(), target.c_str()); + if (block->Get<bool>("kick", "yes")) + { + ++kicked; + if (ci->HasExt("SIGNKICK") || (ci->HasExt("SIGNKICK_LEVEL") && !u_access.HasPriv("SIGNKICK"))) + c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s) (%s)", reason.c_str(), target.c_str(), source.GetNick().c_str()); + else + c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s)", reason.c_str(), target.c_str()); + } } } diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp index a32320131..25ed88c96 100644 --- a/modules/commands/cs_clone.cpp +++ b/modules/commands/cs_clone.cpp @@ -113,7 +113,7 @@ public: unsigned count = 0; for (unsigned i = 0; i < target_ci->GetAccessCount(); ++i) - masks.insert(target_ci->GetAccess(i)->mask); + masks.insert(target_ci->GetAccess(i)->Mask()); for (unsigned i = 0; i < ci->GetAccessCount(); ++i) { @@ -123,13 +123,12 @@ public: if (access_max && target_ci->GetDeepAccessCount() >= access_max) break; - if (masks.count(taccess->mask)) + if (masks.count(taccess->Mask())) continue; - masks.insert(taccess->mask); + masks.insert(taccess->Mask()); ChanServ::ChanAccess *newaccess = provider->Create(); - newaccess->ci = target_ci; - newaccess->mask = taccess->mask; + newaccess->SetMask(taccess->Mask(), target_ci); newaccess->creator = taccess->creator; newaccess->last_seen = taccess->last_seen; newaccess->created = taccess->created; diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index c7953f0c9..7e17a1b47 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -142,7 +142,7 @@ class CommandCSFlags : public Command for (current_idx = ci->GetAccessCount(); current_idx > 0; --current_idx) { ChanServ::ChanAccess *access = ci->GetAccess(current_idx - 1); - if (mask.equals_ci(access->mask)) + if (mask.equals_ci(access->Mask())) { // Flags allows removing others that have the same access as you, // but no other access system does. @@ -154,7 +154,7 @@ class CommandCSFlags : public Command override = true; else { - source.Reply(_("Access denied. You do not have enough privileges on \002{0}\002 to modify the access of \002{1}\002."), ci->name, access->mask); + source.Reply(_("Access denied. You do not have enough privileges on \002{0}\002 to modify the access of \002{1}\002."), ci->name, access->Mask()); return; } } @@ -260,8 +260,7 @@ class CommandCSFlags : public Command if (!provider) return; FlagsChanAccess *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create()); - access->ci = ci; - access->mask = mask; + access->SetMask(mask, ci); access->creator = source.GetNick(); access->last_seen = current ? current->last_seen : 0; access->created = Anope::CurTime; @@ -278,12 +277,12 @@ class CommandCSFlags : public Command if (p != NULL) { if (add) - source.Reply(_("Privilege \002{0}\002 added to \002{1}\002 on \002{2}\002, new flags are +\002{3}\002"), p->name, access->mask, ci->name, access->AccessSerialize()); + source.Reply(_("Privilege \002{0}\002 added to \002{1}\002 on \002{2}\002, new flags are +\002{3}\002"), p->name, access->Mask(), ci->name, access->AccessSerialize()); else - source.Reply(_("Privilege \002{0}\002 removed from \002{1}\002 on \002{2}\002, new flags are +\002{3}\002"), p->name, access->mask, ci->name, access->AccessSerialize()); + source.Reply(_("Privilege \002{0}\002 removed from \002{1}\002 on \002{2}\002, new flags are +\002{3}\002"), p->name, access->Mask(), ci->name, access->AccessSerialize()); } else - source.Reply(_("Flags for \002{0}\002 on \002{1}\002 set to +\002{2}\002"), access->mask, ci->name, access->AccessSerialize()); + source.Reply(_("Flags for \002{0}\002 on \002{1}\002 set to +\002{2}\002"), access->Mask(), ci->name, access->AccessSerialize()); } void DoList(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) @@ -317,14 +316,14 @@ class CommandCSFlags : public Command if (pass == false) continue; } - else if (!Anope::Match(access->mask, arg)) + else if (!Anope::Match(access->Mask(), arg)) continue; } ListFormatter::ListEntry entry; ++count; entry["Number"] = stringify(i + 1); - entry["Mask"] = access->mask; + entry["Mask"] = access->Mask(); entry["Flags"] = flags; entry["Creator"] = access->creator; entry["Created"] = Anope::strftime(access->created, source.nc, true); diff --git a/modules/commands/cs_list.cpp b/modules/commands/cs_list.cpp index c8901fa03..ba3c95aa3 100644 --- a/modules/commands/cs_list.cpp +++ b/modules/commands/cs_list.cpp @@ -12,6 +12,7 @@ #include "module.h" #include "modules/cs_info.h" #include "modules/cs_set.h" +#include "modules/cs_mode.h" class CommandCSList : public Command { @@ -89,6 +90,11 @@ class CommandCSList : public Command continue; if (ci->c && ci->c->HasMode("SECRET")) continue; + + ModeLocks *ml = ci->GetExt<ModeLocks>("modelocks"); + const ModeLock *secret = ml ? ml->GetMLock("SECRET") : NULL; + if (secret && secret->set) + continue; } if (suspended && !ci->HasExt("CS_SUSPENDED")) @@ -97,7 +103,7 @@ class CommandCSList : public Command if (channoexpire && !ci->HasExt("CS_NO_EXPIRE")) continue; - if (pattern.equals_ci(ci->name) || ci->name.equals_ci(spattern) || Anope::Match(ci->name, pattern, false, true) || Anope::Match(ci->name, spattern, false, true)) + if (pattern.equals_ci(ci->name) || ci->name.equals_ci(spattern) || Anope::Match(ci->name, pattern, false, true) || Anope::Match(ci->name, spattern, false, true) || Anope::Match(ci->desc, pattern, false, true) || Anope::Match(ci->last_topic, pattern, false, true)) { if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nchans <= listmax) { diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index 696d0214f..d197102c7 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -491,8 +491,7 @@ class CommandCSMode : public Command for (unsigned j = 0; j < ModeManager::GetChannelModes().size(); ++j) { ChannelMode *cm = ModeManager::GetChannelModes()[j]; - if (!cm) - continue; + if (!u || cm->CanSet(u) || can_override) { if (cm->type == MODE_REGULAR || (!adding && cm->type == MODE_PARAM)) @@ -861,7 +860,7 @@ class CommandCSModes : public Command class CSMode : public Module , public EventHook<Event::CheckModes> - , public EventHook<Event::CreateChan> + , public EventHook<Event::ChanRegistered> , public EventHook<Event::ChanInfo> { CommandCSMode commandcsmode; @@ -874,7 +873,7 @@ class CSMode : public Module public: CSMode(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) , EventHook<Event::CheckModes>("OnCheckModes") - , EventHook<Event::CreateChan>("OnCreateChan") + , EventHook<Event::ChanRegistered>("OnChanRegistered") , EventHook<Event::ChanInfo>("OnChanInfo") , commandcsmode(this) , commandcsmodes(this) @@ -958,7 +957,7 @@ class CSMode : public Module } } - void OnCreateChan(ChanServ::Channel *ci) override + void OnChanRegistered(ChanServ::Channel *ci) override { ModeLocks *ml = modelocks.Require(ci); Anope::string mlock; diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index 8ae9814a1..8bec55967 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -239,7 +239,7 @@ class CommandSeen : public Command { ChanServ::ChanAccess *a = ag[i]; - if (*a->nc == na->nc && a->last_seen > last) + if (a->GetAccount() == na->nc && a->last_seen > last) last = a->last_seen; } diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index b057b1398..4b1a07e4a 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -15,7 +15,7 @@ static Module *me; -static std::map<Anope::string, Anope::string> descriptions; +static Anope::map<Anope::string> descriptions; struct CSMiscData; static Anope::map<ExtensibleItem<CSMiscData> *> items; diff --git a/modules/commands/cs_status.cpp b/modules/commands/cs_status.cpp index e559f7749..aa8eb701d 100644 --- a/modules/commands/cs_status.cpp +++ b/modules/commands/cs_status.cpp @@ -68,7 +68,7 @@ public: { ChanServ::ChanAccess *acc = ag[i]; - source.Reply(_("\002{0}\002 matches access entry \002{1}\002, which has privilege \002{2}\002."), nick, acc->mask, acc->AccessSerialize()); + source.Reply(_("\002{0}\002 matches access entry \002{1}\002, which has privilege \002{2}\002."), nick, acc->Mask(), acc->AccessSerialize()); } } diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index b97760bd9..d389783b0 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -201,6 +201,20 @@ class CSSuspend : public Module Serialize::Type suspend_type; EventHandlers<Event::ChanSuspend> onchansuspend; EventHandlers<Event::ChanUnsuspend> onchanunsuspend; + std::vector<Anope::string> show; + + struct trim + { + Anope::string operator()(Anope::string s) const + { + return s.trim(); + } + }; + + bool Show(CommandSource &source, const Anope::string &what) const + { + return source.IsOper() || std::find(show.begin(), show.end(), what) != show.end(); + } public: CSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) @@ -220,18 +234,19 @@ class CSSuspend : public Module void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool show_hidden) override { CSSuspendInfo *si = suspend.Get(ci); - if (si) - { + if (!si) + return; + + if (show_hidden || Show(source, "suspended")) info[_("Suspended")] = _("This channel is \002suspended\002."); - if (!si->by.empty()) - info[_("Suspended by")] = si->by; - if (!si->reason.empty()) - info[_("Suspend reason")] = si->reason; - if (si->when) - info[_("Suspended on")] = Anope::strftime(si->when, source.GetAccount(), true); - if (si->expires) - info[_("Suspension expires")] = Anope::strftime(si->expires, source.GetAccount(), true); - } + if (!si->by.empty() && (show_hidden || Show(source, "by"))) + info[_("Suspended by")] = si->by; + if (!si->reason.empty() && (show_hidden || Show(source, "reason"))) + info[_("Suspend reason")] = si->reason; + if (si->when && (show_hidden || Show(source, "on"))) + info[_("Suspended on")] = Anope::strftime(si->when, source.GetAccount(), true); + if (si->expires && (show_hidden || Show(source, "expires"))) + info[_("Suspension expires")] = Anope::strftime(si->expires, source.GetAccount(), true); } void OnPreChanExpire(ChanServ::Channel *ci, bool &expire) override diff --git a/modules/commands/cs_unban.cpp b/modules/commands/cs_unban.cpp index cf06b82f9..8937b8142 100644 --- a/modules/commands/cs_unban.cpp +++ b/modules/commands/cs_unban.cpp @@ -22,6 +22,13 @@ class CommandCSUnban : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { + ChannelMode *cm = ModeManager::FindChannelModeByName("BAN"); + if (!cm) + return; + + std::vector<ChannelMode *> modes = cm->listeners; + modes.push_back(cm); + if (params.empty()) { if (!source.GetUser()) @@ -38,8 +45,9 @@ class CommandCSUnban : public Command if (!ci->c || !source.AccessFor(ci).HasPriv("UNBAN")) continue; - if (ci->c->Unban(source.GetUser(), true)) - ++count; + for (unsigned j = 0; j < modes.size(); ++j) + if (ci->c->Unban(source.GetUser(), modes[j]->name, true)) + ++count; } Log(LOG_COMMAND, source, this, NULL) << "on all channels"; @@ -82,7 +90,8 @@ class CommandCSUnban : public Command bool override = !source.AccessFor(ci).HasPriv("UNBAN") && source.HasPriv("chanserv/kick"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unban " << u2->nick; - ci->c->Unban(u2, source.GetUser() == u2); + for (unsigned i = 0; i < modes.size(); ++i) + ci->c->Unban(u2, modes[i]->name, source.GetUser() == u2); if (u2 == source.GetUser()) source.Reply(_("You have been unbanned from \002{0}\002."), ci->c->name); else diff --git a/modules/commands/cs_updown.cpp b/modules/commands/cs_updown.cpp index 7468331aa..0e487ff6c 100644 --- a/modules/commands/cs_updown.cpp +++ b/modules/commands/cs_updown.cpp @@ -81,8 +81,8 @@ class CommandCSUp : public Command } User *u = User::Find(nick, true); - Channel *c = ci->c; User *srcu = source.GetUser(); + Channel *c = ci->c; bool override = false; if (u == NULL) @@ -90,9 +90,13 @@ class CommandCSUp : public Command source.Reply(_("User \002{0}\002 isn't currently online."), nick); return; } - if (srcu && !srcu->FindChannel(c)) { + source.Reply(_("You must be in \002%s\002 to use this command."), c->name.c_str()); + return; + } + else if (!u->FindChannel(c)) + { source.Reply(_("You must be on channel \002{0}\002 to use this command."), c->name); return; } @@ -182,6 +186,7 @@ class CommandCSDown : public Command User *u = User::Find(nick, true); Channel *c = ci->c; + User *srcu = source.GetUser(); bool override = false; @@ -196,8 +201,12 @@ class CommandCSDown : public Command source.Reply(_("You must be on channel \002{0}\002 to use this command."), c->name); return; } - - if (!u->FindChannel(c)) + if (srcu && !srcu->FindChannel(c)) + { + source.Reply(_("You must be in \002%s\002 to use this command."), c->name.c_str()); + return; + } + else if (!u->FindChannel(c)) { source.Reply(_("\002%s\002 is not on channel %s."), u->nick, c->name); return; diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index 53730cb57..c3b43cd3e 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -182,11 +182,11 @@ class CommandCSXOP : public Command { const ChanServ::ChanAccess *a = ci->GetAccess(i); - if (a->mask.equals_ci(mask)) + if (a->Mask().equals_ci(mask)) { if ((!highest || *a >= *highest) && !access.founder && !source.HasPriv("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->name, a->mask); + source.Reply(_("Access denied. You do not have enough privileges on \002{0}\002 to lower the access of \002{1}\002."), ci->name, a->Mask()); return; } @@ -206,8 +206,7 @@ class CommandCSXOP : public Command if (!provider) return; XOPChanAccess *acc = anope_dynamic_static_cast<XOPChanAccess *>(provider->Create()); - acc->ci = ci; - acc->mask = mask; + acc->SetMask(mask, ci); acc->creator = source.GetNick(); acc->type = source.command.upper(); acc->last_seen = 0; @@ -217,7 +216,7 @@ class CommandCSXOP : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask; Event::OnAccessAdd(&Event::AccessAdd::OnAccessAdd, ci, source, acc); - source.Reply(_("\002%s\002 added to %s %s list."), acc->mask.c_str(), ci->name.c_str(), source.command.c_str()); + source.Reply(_("\002%s\002 added to %s %s list."), acc->Mask(), ci->name.c_str(), source.command.c_str()); } void DoDel(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) @@ -320,9 +319,9 @@ class CommandCSXOP : public Command ++deleted; if (!nicks.empty()) - nicks += ", " + caccess->mask; + nicks += ", " + caccess->Mask(); else - nicks = caccess->mask; + nicks = caccess->Mask(); ci->EraseAccess(number - 1); Event::OnAccessDel(&Event::AccessDel::OnAccessDel, ci, source, caccess); @@ -341,11 +340,11 @@ class CommandCSXOP : public Command if (a->provider->name != "access/xop" || source.command.upper() != a->AccessSerialize()) continue; - if (a->mask.equals_ci(mask)) + if (a->Mask().equals_ci(mask)) { - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << a->mask; + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << a->Mask(); - source.Reply(_("\002%s\002 deleted from %s %s list."), a->mask.c_str(), ci->name.c_str(), source.command.c_str()); |
