anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
ms_send.cpp (2612B)
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 namespace 15 { 16 ServiceReference<MemoServService> memoserv("MemoServService", "MemoServ"); 17 } 18 19 class CommandMSSend : public Command 20 { 21 public: 22 CommandMSSend(Module *creator) : Command(creator, "memoserv/send", 2, 2) 23 { 24 this->SetDesc(_("Send a memo to a nick or channel")); 25 this->SetSyntax(_("{\037nick\037 | \037channel\037} \037memo-text\037")); 26 } 27 28 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override 29 { 30 if (!memoserv) 31 return; 32 33 const Anope::string &nick = params[0]; 34 const Anope::string &text = params[1]; 35 36 if (Anope::ReadOnly && !source.IsOper()) 37 { 38 source.Reply(MEMO_SEND_DISABLED); 39 return; 40 } 41 42 if (source.GetAccount()->HasExt("UNCONFIRMED")) 43 { 44 source.Reply(_("You must confirm your account before you may send a memo.")); 45 return; 46 } 47 48 MemoServService::MemoResult result = memoserv->Send(source.GetNick(), nick, text); 49 if (result == MemoServService::MEMO_SUCCESS) 50 { 51 source.Reply(_("Memo sent to \002%s\002."), nick.c_str()); 52 Log(LOG_COMMAND, source, this) << "to send a memo to " << nick; 53 } 54 else if (result == MemoServService::MEMO_INVALID_TARGET) 55 source.Reply(_("\002%s\002 is not a registered unforbidden nick or channel."), nick.c_str()); 56 else if (result == MemoServService::MEMO_TOO_FAST) 57 source.Reply(_("Please wait %d seconds before using the %s command again."), Config->GetModule("memoserv")->Get<time_t>("senddelay"), source.command.c_str()); 58 else if (result == MemoServService::MEMO_TARGET_FULL) 59 source.Reply(_("Sorry, %s currently has too many memos and cannot receive more."), nick.c_str()); 60 } 61 62 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override 63 { 64 this->SendSyntax(source); 65 source.Reply(" "); 66 source.Reply(_("Sends the named \037nick\037 or \037channel\037 a memo containing\n" 67 "\037memo-text\037. When sending to a nickname, the recipient will\n" 68 "receive a notice that he/she has a new memo. The target\n" 69 "nickname/channel must be registered.")); 70 return true; 71 } 72 }; 73 74 class MSSend : public Module 75 { 76 CommandMSSend commandmssend; 77 78 public: 79 MSSend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), 80 commandmssend(this) 81 { 82 83 if (!memoserv) 84 throw ModuleException("No MemoServ!"); 85 } 86 }; 87 88 MODULE_INIT(MSSend)