Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "module.h"
00015
00016 class CommandNSAList : public Command
00017 {
00018 public:
00019 CommandNSAList(Module *creator) : Command(creator, "nickserv/alist", 0, 2)
00020 {
00021 this->SetDesc(_("List channels you have access on"));
00022 this->SetSyntax(_("[\037nickname\037]"));
00023 }
00024
00025 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00026 {
00027 Anope::string nick = source.GetNick();
00028 NickCore *nc = source.nc;
00029
00030 if (params.size() && source.HasPriv("nickserv/alist"))
00031 {
00032 nick = params[0];
00033 const NickAlias *na = NickAlias::Find(nick);
00034 if (!na)
00035 {
00036 source.Reply(NICK_X_NOT_REGISTERED, nick.c_str());
00037 return;
00038 }
00039 nc = na->nc;
00040 }
00041
00042 ListFormatter list;
00043 int chan_count = 0;
00044
00045 list.AddColumn("Number").AddColumn("Channel").AddColumn("Access");
00046
00047 source.Reply(_("Channels that \002%s\002 has access on:"), nc->display.c_str());
00048
00049 std::deque<ChannelInfo *> queue;
00050 nc->GetChannelReferences(queue);
00051
00052 if (queue.empty())
00053 {
00054 source.Reply(_("\2%s\2 has no access in any channels."), nc->display.c_str());
00055 return;
00056 }
00057
00058 for (unsigned i = 0; i < queue.size(); ++i)
00059 {
00060 ChannelInfo *ci = queue[i];
00061 ListFormatter::ListEntry entry;
00062
00063 if (ci->GetFounder() == nc)
00064 {
00065 ++chan_count;
00066 entry["Number"] = stringify(chan_count);
00067 entry["Channel"] = (ci->HasExt("NO_EXPIRE") ? "!" : "") + ci->name;
00068 entry["Access"] = "Founder";
00069 list.AddEntry(entry);
00070 continue;
00071 }
00072
00073 if (ci->GetSuccessor() == nc)
00074 {
00075 ++chan_count;
00076 entry["Number"] = stringify(chan_count);
00077 entry["Channel"] = (ci->HasExt("NO_EXPIRE") ? "!" : "") + ci->name;
00078 entry["Access"] = "Successor";
00079 list.AddEntry(entry);
00080 continue;
00081 }
00082
00083 AccessGroup access = ci->AccessFor(nc);
00084 if (access.empty())
00085 continue;
00086
00087 ++chan_count;
00088
00089 entry["Number"] = stringify(chan_count);
00090 entry["Channel"] = (ci->HasExt("NO_EXPIRE") ? "!" : "") + ci->name;
00091 for (unsigned j = 0; j < access.size(); ++j)
00092 entry["Access"] = entry["Access"] + ", " + access[j]->AccessSerialize();
00093 entry["Access"] = entry["Access"].substr(2);
00094 list.AddEntry(entry);
00095 }
00096
00097 std::vector<Anope::string> replies;
00098 list.Process(replies);
00099 for (unsigned i = 0; i < replies.size(); ++i)
00100 source.Reply(replies[i]);
00101
00102 source.Reply(_("End of list - %d channels shown."), chan_count);
00103 }
00104
00105 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
00106 {
00107 this->SendSyntax(source);
00108 source.Reply(" ");
00109 source.Reply(_("Lists all channels you have access on.\n"
00110 " \n"
00111 "Channels that have the \037NOEXPIRE\037 option set will be\n"
00112 "prefixed by an exclamation mark. The nickname parameter is\n"
00113 "limited to Services Operators"));
00114
00115 return true;
00116 }
00117 };
00118
00119 class NSAList : public Module
00120 {
00121 CommandNSAList commandnsalist;
00122
00123 public:
00124 NSAList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00125 commandnsalist(this)
00126 {
00127 this->SetAuthor("Anope");
00128
00129 }
00130 };
00131
00132 MODULE_INIT(NSAList)