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 CommandBSBotList : public Command
00017 {
00018 public:
00019 CommandBSBotList(Module *creator) : Command(creator, "botserv/botlist", 0, 0)
00020 {
00021 this->SetDesc(_("Lists available bots"));
00022 this->SetSyntax("");
00023 }
00024
00025 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00026 {
00027 unsigned count = 0;
00028 ListFormatter list;
00029
00030 list.AddColumn("Nick").AddColumn("Mask");
00031
00032 for (botinfo_map::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
00033 {
00034 BotInfo *bi = it->second;
00035
00036 if (source.HasPriv("botserv/administration") || !bi->oper_only)
00037 {
00038 ++count;
00039 ListFormatter::ListEntry entry;
00040 entry["Nick"] = (bi->oper_only ? "* " : "") + bi->nick;
00041 entry["Mask"] = bi->GetIdent() + "@" + bi->host;
00042 list.AddEntry(entry);
00043 }
00044 }
00045
00046 std::vector<Anope::string> replies;
00047 list.Process(replies);
00048
00049 if (!count)
00050 source.Reply(_("There are no bots available at this time.\n"
00051 "Ask a Services Operator to create one!"));
00052 else
00053 {
00054 source.Reply(_("Bot list:"));
00055
00056 for (unsigned i = 0; i < replies.size(); ++i)
00057 source.Reply(replies[i]);
00058
00059 source.Reply(_("%d bots available."), count);
00060 }
00061 }
00062
00063 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
00064 {
00065 this->SendSyntax(source);
00066 source.Reply(" ");
00067 source.Reply(_("Lists all available bots on this network.\n"
00068 "Bots prefixed by a * are reserved for IRC Operators."));
00069 return true;
00070 }
00071 };
00072
00073 class BSBotList : public Module
00074 {
00075 CommandBSBotList commandbsbotlist;
00076
00077 public:
00078 BSBotList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00079 commandbsbotlist(this)
00080 {
00081 this->SetAuthor("Anope");
00082
00083 }
00084 };
00085
00086 MODULE_INIT(BSBotList)