anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
ms_ignore.cpp (3655B)
1 /* MemoServ core functions 2 * 3 * (C) 2003-2022 Anope Team 4 * Contact us at team@anope.org 5 * 6 * Please read COPYING and README for further details. 7 * 8 * Based on the original code of Epona by Lara. 9 * Based on the original code of Services by Andy Church. 10 */ 11 12 #include "module.h" 13 14 class CommandMSIgnore : public Command 15 { 16 public: 17 CommandMSIgnore(Module *creator) : Command(creator, "memoserv/ignore", 1, 3) 18 { 19 this->SetDesc(_("Manage the memo ignore list")); 20 this->SetSyntax(_("[\037channel\037] ADD \037entry\037")); 21 this->SetSyntax(_("[\037channel\037] DEL \037entry\037")); 22 this->SetSyntax(_("[\037channel\037] LIST")); 23 } 24 25 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override 26 { 27 if (Anope::ReadOnly) 28 { 29 source.Reply(READ_ONLY_MODE); 30 return; 31 } 32 33 Anope::string channel = params[0]; 34 Anope::string command = (params.size() > 1 ? params[1] : ""); 35 Anope::string param = (params.size() > 2 ? params[2] : ""); 36 37 if (channel[0] != '#') 38 { 39 param = command; 40 command = channel; 41 channel = source.GetNick(); 42 } 43 44 bool ischan; 45 MemoInfo *mi = MemoInfo::GetMemoInfo(channel, ischan); 46 ChannelInfo *ci = ChannelInfo::Find(channel); 47 if (!mi) 48 source.Reply(ischan ? CHAN_X_NOT_REGISTERED : _(NICK_X_NOT_REGISTERED), channel.c_str()); 49 else if (ischan && !source.AccessFor(ci).HasPriv("MEMO")) 50 source.Reply(ACCESS_DENIED); 51 else if (command.equals_ci("ADD") && !param.empty()) 52 { 53 if (mi->ignores.size() >= Config->GetModule(this->owner)->Get<unsigned>("max", "32")) 54 { 55 source.Reply(_("Sorry, the memo ignore list for \002%s\002 is full."), channel.c_str()); 56 return; 57 } 58 59 if (std::find(mi->ignores.begin(), mi->ignores.end(), param.ci_str()) == mi->ignores.end()) 60 { 61 mi->ignores.push_back(param.ci_str()); 62 source.Reply(_("\002%s\002 added to ignore list."), param.c_str()); 63 } 64 else 65 source.Reply(_("\002%s\002 is already on the ignore list."), param.c_str()); 66 } 67 else if (command.equals_ci("DEL") && !param.empty()) 68 { 69 std::vector<Anope::string>::iterator it = std::find(mi->ignores.begin(), mi->ignores.end(), param.ci_str()); 70 71 if (it != mi->ignores.end()) 72 { 73 mi->ignores.erase(it); 74 source.Reply(_("\002%s\002 removed from the ignore list."), param.c_str()); 75 } 76 else 77 source.Reply(_("\002%s\002 is not on the ignore list."), param.c_str()); 78 } 79 else if (command.equals_ci("LIST")) 80 { 81 if (mi->ignores.empty()) 82 source.Reply(_("Memo ignore list is empty.")); 83 else 84 { 85 ListFormatter list(source.GetAccount()); 86 list.AddColumn(_("Mask")); 87 for (unsigned i = 0; i < mi->ignores.size(); ++i) 88 { 89 ListFormatter::ListEntry entry; 90 entry["Mask"] = mi->ignores[i]; 91 list.AddEntry(entry); 92 } 93 94 source.Reply(_("Ignore list:")); 95 96 std::vector<Anope::string> replies; 97 list.Process(replies); 98 99 for (unsigned i = 0; i < replies.size(); ++i) 100 source.Reply(replies[i]); 101 } 102 } 103 else 104 this->OnSyntaxError(source, ""); 105 106 return; 107 } 108 109 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override 110 { 111 this->SendSyntax(source); 112 source.Reply(" "); 113 source.Reply(_("Allows you to ignore users by nick or host from memoing\n" 114 "you or a channel. If someone on the memo ignore list tries\n" 115 "to memo you or a channel, they will not be told that you have\n" 116 "them ignored.")); 117 return true; 118 } 119 }; 120 121 class MSIgnore : public Module 122 { 123 CommandMSIgnore commandmsignore; 124 125 public: 126 MSIgnore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), 127 commandmsignore(this) 128 { 129 } 130 }; 131 132 MODULE_INIT(MSIgnore)