diff options
| author | Adam <Adam@anope.org> | 2016-10-22 16:43:18 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2016-10-22 16:52:29 -0400 |
| commit | fce6169f4e134a99dbb19997337b1bb250889147 (patch) | |
| tree | b6f2f6c1bc7094a32b5dc6bb1df97fc4b675e9e0 /modules/chanserv | |
| parent | 06f40cabcb167e2764c03092f6ec3f7383983f95 (diff) | |
Various codestyle cleanup in most of the core modules
Diffstat (limited to 'modules/chanserv')
| -rw-r--r-- | modules/chanserv/access.cpp | 39 | ||||
| -rw-r--r-- | modules/chanserv/akick.cpp | 2 | ||||
| -rw-r--r-- | modules/chanserv/clone.cpp | 2 | ||||
| -rw-r--r-- | modules/chanserv/entrymsg.cpp | 37 | ||||
| -rw-r--r-- | modules/chanserv/flags.cpp | 4 | ||||
| -rw-r--r-- | modules/chanserv/kick.cpp | 2 | ||||
| -rw-r--r-- | modules/chanserv/list.cpp | 2 | ||||
| -rw-r--r-- | modules/chanserv/log.cpp | 4 | ||||
| -rw-r--r-- | modules/chanserv/main/chanserv.cpp | 2 | ||||
| -rw-r--r-- | modules/chanserv/mode.cpp | 86 | ||||
| -rw-r--r-- | modules/chanserv/register.cpp | 2 | ||||
| -rw-r--r-- | modules/chanserv/set.cpp | 24 | ||||
| -rw-r--r-- | modules/chanserv/status.cpp | 8 | ||||
| -rw-r--r-- | modules/chanserv/statusupdate.cpp | 63 | ||||
| -rw-r--r-- | modules/chanserv/topic.cpp | 25 | ||||
| -rw-r--r-- | modules/chanserv/unban.cpp | 1 | ||||
| -rw-r--r-- | modules/chanserv/updown.cpp | 201 | ||||
| -rw-r--r-- | modules/chanserv/xop.cpp | 2 |
18 files changed, 301 insertions, 205 deletions
diff --git a/modules/chanserv/access.cpp b/modules/chanserv/access.cpp index ba9f2b5fb..82a11831f 100644 --- a/modules/chanserv/access.cpp +++ b/modules/chanserv/access.cpp @@ -656,30 +656,31 @@ class CommandCSLevels : public Command } if (level <= ChanServ::ACCESS_INVALID || level > ChanServ::ACCESS_FOUNDER) + { source.Reply(_("Level must be between \002{0}\002 and \002{1}\002 inclusive."), ChanServ::ACCESS_INVALID + 1, ChanServ::ACCESS_FOUNDER - 1); + return; + } + + ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(what) : 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.command); + } else { - ChanServ::Privilege *p = ChanServ::service ? ChanServ::service->FindPrivilege(what) : 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.command); - } - else - { - bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to set " << p->name << " to level " << level; + bool override = !source.AccessFor(ci).HasPriv("FOUNDER"); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to set " << p->name << " to level " << level; - ci->SetLevel(p->name, level); - EventManager::Get()->Dispatch(&Event::LevelChange::OnLevelChange, source, ci, p->name, 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); - } + 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); } } diff --git a/modules/chanserv/akick.cpp b/modules/chanserv/akick.cpp index ff7fb5b69..d253d6fb5 100644 --- a/modules/chanserv/akick.cpp +++ b/modules/chanserv/akick.cpp @@ -205,7 +205,9 @@ class CommandCSAKick : public Command mask += "#" + e.real; } else + { nc = na->GetAccount(); + } /* Check excepts BEFORE we get this far */ if (ci->c) diff --git a/modules/chanserv/clone.cpp b/modules/chanserv/clone.cpp index 96aa89bf4..8d0c1ce3a 100644 --- a/modules/chanserv/clone.cpp +++ b/modules/chanserv/clone.cpp @@ -90,7 +90,9 @@ public: return; } else + { override = true; + } } if (what.equals_ci("ALL")) diff --git a/modules/chanserv/entrymsg.cpp b/modules/chanserv/entrymsg.cpp index b607ba399..4f74834bd 100644 --- a/modules/chanserv/entrymsg.cpp +++ b/modules/chanserv/entrymsg.cpp @@ -161,27 +161,32 @@ class CommandEntryMessage : public Command std::vector<EntryMsg *> messages = ci->GetRefs<EntryMsg *>(); if (!message.is_pos_number_only()) + { source.Reply(("Entry message \002{0}\002 not found on channel \002{1}\002."), message, ci->GetName()); - else if (messages.empty()) + return; + } + + if (messages.empty()) + { source.Reply(_("Entry message list for \002{0}\002 is empty."), ci->GetName()); - else + return; + } + + try { - try + unsigned i = convertTo<unsigned>(message); + if (i > 0 && i <= messages.size()) { - unsigned i = convertTo<unsigned>(message); - if (i > 0 && i <= messages.size()) - { - messages[i - 1]->Delete(); - Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove a message"; - source.Reply(_("Entry message \002{0}\002 for \002{1]\002 deleted."), i, ci->GetName()); - } - else - throw ConvertException(); - } - catch (const ConvertException &) - { - source.Reply(_("Entry message \002{0}\002 not found on channel \002{1}\002."), message, ci->GetName()); + messages[i - 1]->Delete(); + Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove a message"; + source.Reply(_("Entry message \002{0}\002 for \002{1]\002 deleted."), i, ci->GetName()); } + else + throw ConvertException(); + } + catch (const ConvertException &) + { + source.Reply(_("Entry message \002{0}\002 not found on channel \002{1}\002."), message, ci->GetName()); } } diff --git a/modules/chanserv/flags.cpp b/modules/chanserv/flags.cpp index 732e3aa8a..446eeddd0 100644 --- a/modules/chanserv/flags.cpp +++ b/modules/chanserv/flags.cpp @@ -431,9 +431,13 @@ class CommandCSFlags : public Command } if (is_list) + { this->DoList(source, ci, params); + } else if (cmd.equals_ci("CLEAR")) + { this->DoClear(source, ci); + } else { Anope::string mask, flags; diff --git a/modules/chanserv/kick.cpp b/modules/chanserv/kick.cpp index 0fd8979d4..4752d5940 100644 --- a/modules/chanserv/kick.cpp +++ b/modules/chanserv/kick.cpp @@ -132,7 +132,9 @@ class CommandCSKick : public Command source.Reply(_("No users on\002{0}\002 match \002{1}\002."), c->name, mask); } else + { source.Reply(_("\002{0}\002 isn't currently in use."), target); + } } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/chanserv/list.cpp b/modules/chanserv/list.cpp index 75ffdb67c..c76d8661c 100644 --- a/modules/chanserv/list.cpp +++ b/modules/chanserv/list.cpp @@ -227,7 +227,9 @@ class CommandCSSetPrivate : public Command source.Reply(_("Private option for \002{0}\002 is now \002off\002."), ci->GetName()); } else + { this->OnSyntaxError(source, "PRIVATE"); + } } bool OnHelp(CommandSource &source, const Anope::string &) override diff --git a/modules/chanserv/log.cpp b/modules/chanserv/log.cpp index b20427bc0..32025e6b0 100644 --- a/modules/chanserv/log.cpp +++ b/modules/chanserv/log.cpp @@ -316,7 +316,9 @@ public: source.Reply(_("Logging is now active for command \002{0}\002 on \002{1}\002, using log method \002{2}{3}{4}\002."), !command_name.empty() ? command_name : service_name, bi ? bi->nick : "any service", method, extra.empty() ? "" : " ", extra); } else + { this->OnSyntaxError(source, ""); + } } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -406,7 +408,9 @@ class CSLog : public Module log->SetCommandName(d.command); } else + { log->SetServiceName(d.command); + } spacesepstream sep(d.method); Anope::string method, extra; diff --git a/modules/chanserv/main/chanserv.cpp b/modules/chanserv/main/chanserv.cpp index dc44173a0..59181e806 100644 --- a/modules/chanserv/main/chanserv.cpp +++ b/modules/chanserv/main/chanserv.cpp @@ -256,7 +256,9 @@ class ChanServCore : public Module defaults.push_back("SIGNKICK"); } else if (defaults[0].equals_ci("none")) + { defaults.clear(); + } always_lower = conf->GetModule(this)->Get<bool>("always_lower_ts"); } diff --git a/modules/chanserv/mode.cpp b/modules/chanserv/mode.cpp index 4ff1ce1d3..7a9fd38d6 100644 --- a/modules/chanserv/mode.cpp +++ b/modules/chanserv/mode.cpp @@ -323,7 +323,8 @@ class CommandCSMode : public Command source.Reply(_("Unknown mode character \002{0}\002 ignored."), modes[i]); break; } - else if (u && !cm->CanSet(u)) + + if (u && !cm->CanSet(u)) { source.Reply(_("You may not (un)lock mode \002{0}\002."), modes[i]); break; @@ -331,27 +332,36 @@ class CommandCSMode : public Command Anope::string mode_param; if (((cm->type == MODE_STATUS || cm->type == MODE_LIST) && !sep.GetToken(mode_param)) || (cm->type == MODE_PARAM && adding && !sep.GetToken(mode_param))) + { source.Reply(_("Missing parameter for mode \002{0}\002."), cm->mchar); - else if (cm->type == MODE_LIST && ci->c && IRCD->GetMaxListFor(ci->c) && ci->c->HasMode(cm->name) >= IRCD->GetMaxListFor(ci->c)) + break; + } + + if (cm->type == MODE_LIST && ci->c && IRCD->GetMaxListFor(ci->c) && ci->c->HasMode(cm->name) >= IRCD->GetMaxListFor(ci->c)) + { source.Reply(_("List for mode \002{0}\002 is full."), cm->mchar); - else if (ci->GetRefs<ModeLock *>().size() >= Config->GetModule(this->GetOwner())->Get<unsigned>("max", "32")) + break; + } + + if (ci->GetRefs<ModeLock *>().size() >= Config->GetModule(this->GetOwner())->Get<unsigned>("max", "32")) + { source.Reply(_("The mode lock list of \002{0}\002 is full."), ci->GetName()); + break; + } + + mlocks->SetMLock(ci, cm, adding, mode_param, source.GetNick()); + + if (adding) + { + pos += cm->mchar; + if (!mode_param.empty()) + pos_params += " " + mode_param; + } else { - mlocks->SetMLock(ci, cm, adding, mode_param, source.GetNick()); - - if (adding) - { - pos += cm->mchar; - if (!mode_param.empty()) - pos_params += " " + mode_param; - } - else - { - neg += cm->mchar; - if (!mode_param.empty()) - neg_params += " " + mode_param; - } + neg += cm->mchar; + if (!mode_param.empty()) + neg_params += " " + mode_param; } } } @@ -368,7 +378,9 @@ class CommandCSMode : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to lock " << reply; } else if (needreply) + { source.Reply(_("Nothing to do.")); + } if (ci->c) ci->c->CheckModes(); @@ -400,7 +412,8 @@ class CommandCSMode : public Command source.Reply(_("Unknown mode character \002{0}\002 ignored."), modes[i]); break; } - else if (u && !cm->CanSet(u)) + + if (u && !cm->CanSet(u)) { source.Reply(_("You may not (un)lock mode \002{0}\002."), modes[i]); break; @@ -408,18 +421,21 @@ class CommandCSMode : public Command Anope::string mode_param; if (cm->type != MODE_REGULAR && !sep.GetToken(mode_param)) + { source.Reply(_("Missing parameter for mode \002{0}\002."), cm->mchar); + break; + } + + if (mlocks->RemoveMLock(ci, cm, adding, mode_param)) + { + if (!mode_param.empty()) + 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()); + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unlock " << (adding ? '+' : '-') << cm->mchar << mode_param; + } else { - if (mlocks->RemoveMLock(ci, cm, adding, mode_param)) - { - if (!mode_param.empty()) - 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()); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unlock " << (adding ? '+' : '-') << cm->mchar << mode_param; - } - else - source.Reply(_("\002{0}{1}\002 is not locked on \002{2}\002."), adding == 1 ? '+' : '-', cm->mchar, ci->GetName()); + source.Reply(_("\002{0}{1}\002 is not locked on \002{2}\002."), adding == 1 ? '+' : '-', cm->mchar, ci->GetName()); } } } @@ -462,7 +478,9 @@ class CommandCSMode : public Command source.Reply(replies[i]); } else + { this->OnSyntaxError(source, subcommand); + } } void DoSet(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> ¶ms) @@ -646,7 +664,9 @@ class CommandCSMode : public Command ChannelMode *cm; if (param.length() == 1) + { cm = ModeManager::FindChannelModeByChar(param[0]); + } else { cm = ModeManager::FindChannelModeByName(param.upper()); @@ -703,9 +723,13 @@ class CommandCSMode : public Command this->DoLock(source, ci, params); } else if (!ci->c) + { source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName()); + } else if (subcommand.equals_ci("SET") && params.size() > 2) + { this->DoSet(source, ci, params); + } else if (subcommand.equals_ci("CLEAR")) { if (!source.AccessFor(ci).HasPriv("MODE") && !source.HasPriv("chanserv/administration")) @@ -714,7 +738,9 @@ class CommandCSMode : public Command this->DoClear(source, ci, params); } else + { this->OnSyntaxError(source, ""); + } } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -796,7 +822,9 @@ class CommandCSModes : public Command return; } else + { override = true; + } } if (!override && !m.first && u != targ && (targ->IsProtected() || (ci->HasFieldS("PEACE") && targ_access >= u_access))) @@ -807,7 +835,9 @@ class CommandCSModes : public Command return; } else + { override = true; + } } if (!ci->c->FindUser(targ)) @@ -835,7 +865,9 @@ class CommandCSModes : public Command return Anope::printf(Language::Translate(source.GetAccount(), _("Removes %s status from you or the specified nick on a channel")), m.second.c_str()); } else + { return ""; + } } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override diff --git a/modules/chanserv/register.cpp b/modules/chanserv/register.cpp index 3affb8b43..0c7d77a8f 100644 --- a/modules/chanserv/register.cpp +++ b/modules/chanserv/register.cpp @@ -107,7 +107,7 @@ class CommandCSRegister : public Command ci->SetLastUsed(Anope::CurTime); ci->SetBanType(2); - ci->c = c; // XXX? this isnt set on reconstrubted objects? + ci->c = c; c->ci = ci; if (c && !c->topic.empty()) diff --git a/modules/chanserv/set.cpp b/modules/chanserv/set.cpp index 27ad49fa6..1d49629db 100644 --- a/modules/chanserv/set.cpp +++ b/modules/chanserv/set.cpp @@ -128,7 +128,9 @@ class CommandCSSetAutoOp : public Command source.Reply(_("Services will no longer automatically give modes to users in \002{0}\002."), ci->GetName()); } else + { this->OnSyntaxError(source, "AUTOOP"); + } } bool OnHelp(CommandSource &source, const Anope::string &) override @@ -392,7 +394,9 @@ class CommandCSSetKeepModes : public Command m->Delete(); } else + { this->OnSyntaxError(source, "KEEPMODES"); + } } bool OnHelp(CommandSource &source, const Anope::string &) override @@ -453,7 +457,9 @@ class CommandCSSetPeace : public Command source.Reply(_("Peace option for \002{0}\002 is now \002off\002."), ci->GetName()); } else + { this->OnSyntaxError(source, "PEACE"); + } } bool OnHelp(CommandSource &source, const Anope::string &) override @@ -605,7 +611,9 @@ class CommandCSSetPersist : public Command source.Reply(_("Channel \002{0}\002 is no longer persistent."), ci->GetName()); } else + { this->OnSyntaxError(source, "PERSIST"); + } } bool OnHelp(CommandSource &source, const Anope::string &) override @@ -667,7 +675,9 @@ class CommandCSSetRestricted : public Command source.Reply(_("Restricted access option for \002{0}\002 is now \002off\002."), ci->GetName()); } else + { this->OnSyntaxError(source, "RESTRICTED"); + } } bool OnHelp(CommandSource &source, const Anope::string &) override @@ -728,7 +738,9 @@ class CommandCSSetSecure : public Command source.Reply(_("Secure option for \002{0}\002 is now \002off\002."), ci->GetName()); } else + { this->OnSyntaxError(source, "SECURE"); + } } bool OnHelp(CommandSource &source, const Anope::string &) override @@ -791,7 +803,9 @@ class CommandCSSetSecureFounder : public Command source.Reply(_("Secure founder option for \002{0}\002 is now \002off\002."), ci->GetName()); } else + { this->OnSyntaxError(source, "SECUREFOUNDER"); + } } bool OnHelp(CommandSource &source, const Anope::string &) override @@ -857,7 +871,9 @@ class CommandCSSetSecureOps : public Command source.Reply(_("Secure ops option for \002{0}\002 is now \002off\002."), ci->GetName()); } else + { this->OnSyntaxError(source, "SECUREOPS"); + } } bool OnHelp(CommandSource &source, const Anope::string &) override @@ -928,7 +944,9 @@ class CommandCSSetSignKick : public Command Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable sign kick"; } else + { this->OnSyntaxError(source, "SIGNKICK"); + } } bool OnHelp(CommandSource &source, const Anope::string &) override @@ -979,7 +997,7 @@ class CommandCSSetSuccessor : public Command return; } - NickServ::Account *nc; + NickServ::Account *nc = nullptr; if (!param.empty()) { @@ -999,8 +1017,6 @@ class CommandCSSetSuccessor : public Command nc = na->GetAccount(); } - else - nc = NULL; Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to change the successor from " << (ci->GetSuccessor() ? ci->GetSuccessor()->GetDisplay() : "(none)") << " to " << (nc ? nc->GetDisplay() : "(none)"); @@ -1067,7 +1083,9 @@ class CommandCSSetNoexpire : public Command source.Reply(_("Channel \002{0} will\002 expire."), ci->GetName()); } else + { this->OnSyntaxError(source, "NOEXPIRE"); + } } bool OnHelp(CommandSource &source, const Anope::string &) override diff --git a/modules/chanserv/status.cpp b/modules/chanserv/status.cpp index 3e4b669d3..81834a3e6 100644 --- a/modules/chanserv/status.cpp +++ b/modules/chanserv/status.cpp @@ -54,7 +54,9 @@ public: User *u = User::Find(nick, true); NickServ::Nick *na = NULL; if (u != NULL) + { ag = ci->AccessFor(u); + } else { na = NickServ::FindNick(nick); @@ -63,11 +65,17 @@ public: } if (ag.super_admin) + { source.Reply(_("\002{0}\002 is a super administrator."), nick); + } else if (ag.founder) + { source.Reply(_("\002{0}\002 is the founder of \002{1}\002."), nick, ci->GetName()); + } else if (ag.empty()) + { source.Reply(_("\002{0}\002 has no access on \002{1}\002."), nick, ci->GetName()); + } else { source.Reply(_("Access for \002{0}\002 on \002{1}\002:"), nick, ci->GetName()); diff --git a/modules/chanserv/statusupdate.cpp b/modules/chanserv/statusupdate.cpp index 0d3a25d0f..bc9ef833c 100644 --- a/modules/chanserv/statusupdate.cpp +++ b/modules/chanserv/statusupdate.cpp @@ -23,6 +23,32 @@ class StatusUpdate : public Module , public EventHook<Event::AccessAdd> , public EventHook<Event::AccessDel> { + void ApplyModes(ChanServ::Channel *ci, ChanServ::ChanAccess *access, bool set) + { + if (ci->c == nullptr) + return; + + for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + { + User *user = it->second->user; + + if (user->server != Me && access->Matches(user, user->Account())) + { + ChanServ::AccessGroup ag = ci->AccessFor(user); + + for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i) + { + ChannelModeStatus *cms = ModeManager::GetStatusChannelModesByRank()[i]; + if (!ag.HasPriv("AUTO" + cms->name)) + ci->c->RemoveMode(NULL, cms, user->GetUID()); + } + + if (set) + ci->c->SetCorrectModes(user, true); + } + } + } + public: StatusUpdate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) , EventHook<Event::AccessAdd>(this) @@ -33,46 +59,13 @@ class StatusUpdate : public Module void OnAccessAdd(ChanServ::Channel *ci, CommandSource &, ChanServ::ChanAccess *access) override { - if (ci->c) - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) - { - User *user = it->second->user; - - if (user->server != Me && access->Matches(user, user->Account())) - { - ChanServ::AccessGroup ag = ci->AccessFor(user); - - for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i) - { - ChannelModeStatus *cms = ModeManager::GetStatusChannelModesByRank()[i]; - if (!ag.HasPriv("AUTO" + cms->name)) - ci->c->RemoveMode(NULL, cms, user->GetUID()); - } - ci->c->SetCorrectModes(user, true); - } - } + ApplyModes(ci, access, true); } // XXX this relies on the access entry already being removed from the list? void OnAccessDel(ChanServ::Channel *ci, CommandSource &, ChanServ::ChanAccess *access) override { - if (ci->c) - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) - { - User *user = it->second->user; - - if (user->server != Me && access->Matches(user, user->Account())) - { - ChanServ::AccessGroup ag = ci->AccessFor(user); - - for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i) - { - ChannelModeStatus *cms = ModeManager::GetStatusChannelModesByRank()[i]; - if (!ag.HasPriv("AUTO" + cms->name)) - ci->c->RemoveMode(NULL, cms, user->GetUID()); - } - } - } + ApplyModes(ci, access, false); } }; diff --git a/modules/chanserv/topic.cpp b/modules/chanserv/topic.cpp index fe9d2a80f..76a816c13 100644 --- a/modules/chanserv/topic.cpp +++ b/modules/chanserv/topic.cpp @@ -73,7 +73,9 @@ class CommandCSSetKeepTopic : public Command source.Reply(_("Topic retention option for \002{0}\002 is now \002off\002."), ci->GetName()); } else + { this->OnSyntaxError(source, "KEEPTOPIC"); + } } bool OnHelp(CommandSource &source, const Anope::string &) override @@ -146,7 +148,9 @@ class CommandCSTopic : public Command ci->SetLastTopic(""); } else + { new_topic = topic; + } this->Set(source, ci, new_topic); } @@ -168,17 +172,33 @@ class CommandCSTopic : public Command ChanServ::Channel *ci = ChanServ::Find(channel); if (ci == NULL) + { source.Reply(_("Channel \002{0}\002 isn't registered."), channel); - else if (!source.AccessFor(ci).HasPriv("TOPIC") && !source.HasCommand("chanserv/topic")) + return; + } + + if (!source.AccessFor(ci).HasPriv("TOPIC") && !source.HasCommand("chanserv/topic")) + { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "TOPIC", ci->GetName()); - else if (subcmd.equals_ci("LOCK")) + return; + } + + if (subcmd.equals_ci("LOCK")) + { this->Lock(source, ci, params); + } else if (subcmd.equals_ci("UNLOCK")) + { this->Unlock(source, ci, params); + } else if (!ci->c) + { source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName()); + } else if (subcmd.equals_ci("APPEND") && params.size() > 2) + { this->Append(source, ci, params); + } else { Anope::string topic; @@ -192,6 +212,7 @@ class CommandCSTopic : public Command if (params.size() > 2) topic += " " + params[2]; } + this->Set(source, ci, topic); } } diff --git a/modules/chanserv/unban.cpp b/modules/chanserv/unban.cpp index c4ee62e21..035819ff2 100644 --- a/modules/chanserv/unban.cpp +++ b/modules/chanserv/unban.cpp @@ -96,6 +96,7 @@ class CommandCSUnban : public Command 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/chanserv/updown.cpp b/modules/chanserv/updown.cpp index baa540163..8df6be26b 100644 --- a/modules/chanserv/updown.cpp +++ b/modules/chanserv/updown.cpp @@ -69,72 +69,70 @@ class CommandCSUp : public Command SetModes(source.GetUser(), c); } Log(LOG_COMMAND, source, this, NULL) << "on all channels to update their status modes"; + return; } - else - { - const Anope::string &chan = params[0]; - const Anope::string &nick = params.size() > 1 ? params[1] : source.GetNick(); - ChanServ::Channel *ci = ChanServ::Find(chan); - if (ci == NULL) - { - source.Reply(_("Channel \002{0}\002 isn't registered."), chan); - return; - } + const Anope::string &chan = params[0]; + const Anope::string &nick = params.size() > 1 ? params[1] : source.GetNick(); - if (ci->c == NULL) - { - source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName()); - return; - } + ChanServ::Channel *ci = ChanServ::Find(chan); + if (ci == NULL) + { + source.Reply(_("Channel \002{0}\002 isn't registered."), chan); + return; + } - User *u = User::Find(nick, true); - User *srcu = source.GetUser(); - Channel *c = ci->c; - bool override = false; + if (ci->c == NULL) + { + source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName()); + return; + } - if (u == NULL) - { - source.Reply(_("User \002{0}\002 isn't currently online."), nick); - return; - } + User *u = User::Find(nick, true); + User *srcu = source.GetUser(); + Channel *c = ci->c; + bool override = false; - 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 == NULL) + { + source.Reply(_("User \002{0}\002 isn't currently online."), nick); + return; + } - if (!u->FindChannel(c)) - { - source.Reply(_("You must be on channel \002{0}\002 to use this command."), c->name); - 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{0}\002 is not on channel \002{1}\002."), u->nick, c->name); - return; - } + if (!u->FindChannel(c)) + { + source.Reply(_("You must be on channel \002{0}\002 to use this command."), c->name); + return; + } + + if (!u->FindChannel(c)) + { + source.Reply(_("\002{0}\002 is not on channel \002{1}\002."), u->nick, c->name); + return; + } - if (source.GetUser() && u != source.GetUser() && c->ci->HasFieldS("PEACE")) + if (source.GetUser() && u != source.GetUser() && c->ci->HasFieldS("PEACE")) + { + if (c->ci->AccessFor(u) >= c->ci->AccessFor(source.GetUser())) { - if (c->ci->AccessFor(u) >= c->ci->AccessFor(source.GetUser())) + if (source.HasPriv("chanserv/administration")) + override = true; + else { - if (source.HasPriv("chanserv/administration")) - override = true; - else - { - source.Reply(_("Access denied. \002{0}\002 has more privileges than you on \002{1}\002."), u->nick, ci->GetName()); - return; - } + source.Reply(_("Access denied. \002{0}\002 has more privileges than you on \002{1}\002."), u->nick, ci->GetName()); + return; } } - - Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to update the status modes of " << u->nick; - SetModes(u, c); } + Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to update the status modes of " << u->nick; + SetModes(u, c); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -175,72 +173,71 @@ class CommandCSDown : public Command RemoveAll(source.GetUser(), c); } |
