From 1a3d9a016d3adc49788bbff73aac9b3b5ea85b17 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 1 Jul 2013 22:17:52 -0400 Subject: Change extensible keys to require explicitly having a type defined for it. Completely modularize more features like bs_kick, entrymsg, log, mode, etc. Move fantasy to its own module. Move greet to its own module. --- modules/commands/cs_list.cpp | 83 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 79 insertions(+), 4 deletions(-) (limited to 'modules/commands/cs_list.cpp') diff --git a/modules/commands/cs_list.cpp b/modules/commands/cs_list.cpp index 9e2df0a62..a92729b61 100644 --- a/modules/commands/cs_list.cpp +++ b/modules/commands/cs_list.cpp @@ -81,11 +81,11 @@ class CommandCSList : public Command { const ChannelInfo *ci = it->second; - if (!is_servadmin && (ci->HasExt("PRIVATE") || ci->HasExt("SUSPENDED"))) + if (!is_servadmin && (ci->HasExt("CS_PRIVATE") || ci->HasExt("SUSPENDED"))) continue; else if (suspended && !ci->HasExt("SUSPENDED")) continue; - else if (channoexpire && !ci->HasExt("NO_EXPIRE")) + else 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)) @@ -93,7 +93,7 @@ class CommandCSList : public Command if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nchans <= listmax) { bool isnoexpire = false; - if (is_servadmin && (ci->HasExt("NO_EXPIRE"))) + if (is_servadmin && (ci->HasExt("CS_NO_EXPIRE"))) isnoexpire = true; ListFormatter::ListEntry entry; @@ -159,14 +159,89 @@ class CommandCSList : public Command } }; +class CommandCSSetPrivate : public Command +{ + public: + CommandCSSetPrivate(Module *creator, const Anope::string &cname = "chanserv/set/private") : Command(creator, cname, 2, 2) + { + this->SetDesc(_("Hide channel from the LIST command")); + this->SetSyntax(_("\037channel\037 {ON | OFF}")); + } + + void Execute(CommandSource &source, const std::vector ¶ms) anope_override + { + ChannelInfo *ci = ChannelInfo::Find(params[0]); + if (ci == NULL) + { + source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); + return; + } + + EventReturn MOD_RESULT; + FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + if (MOD_RESULT == EVENT_STOP) + return; + + if (MOD_RESULT != EVENT_ALLOW && !source.AccessFor(ci).HasPriv("SET") && source.permission.empty() && !source.HasPriv("chanserv/administration")) + { + source.Reply(ACCESS_DENIED); + return; + } + + if (params[1].equals_ci("ON")) + { + Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable private"; + ci->Extend("CS_PRIVATE"); + source.Reply(_("Private option for %s is now \002on\002."), ci->name.c_str()); + } + else if (params[1].equals_ci("OFF")) + { + Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable private"; + ci->Shrink("CS_PRIVATE"); + source.Reply(_("Private option for %s is now \002off\002."), ci->name.c_str()); + } + else + this->OnSyntaxError(source, "PRIVATE"); + + return; + } + + bool OnHelp(CommandSource &source, const Anope::string &) anope_override + { + this->SendSyntax(source); + source.Reply(" "); + source.Reply(_("Enables or disables the \002private\002 option for a channel.")); + + BotInfo *bi; + Anope::string cmd; + if (Command::FindCommandFromService("chanserv/list", bi, cmd)) + source.Reply(_("When \002private\002 is set, the channel will not appear in\n" + "%s's %s command."), bi->nick.c_str(), cmd.c_str()); + return true; + } +}; + class CSList : public Module { CommandCSList commandcslist; + CommandCSSetPrivate commandcssetprivate; + + SerializableExtensibleItem priv; public: - CSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcslist(this) + CSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), + commandcslist(this), commandcssetprivate(this), priv(this, "CS_PRIVATE") { } + + void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_all) anope_override + { + if (!show_all) + return; + + if (priv.HasExt(ci)) + info.AddOption(_("Private")); + } }; MODULE_INIT(CSList) -- cgit