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 CommandNSSetGreet : public Command
00017 {
00018 public:
00019 CommandNSSetGreet(Module *creator, const Anope::string &sname = "nickserv/set/greet", size_t min = 0) : Command(creator, sname, min, min + 1)
00020 {
00021 this->SetDesc(_("Associate a greet message with your nickname"));
00022 this->SetSyntax(_("\037message\037"));
00023 }
00024
00025 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
00026 {
00027 const NickAlias *na = NickAlias::Find(user);
00028 if (!na)
00029 {
00030 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
00031 return;
00032 }
00033 NickCore *nc = na->nc;
00034
00035 EventReturn MOD_RESULT;
00036 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, nc, param));
00037 if (MOD_RESULT == EVENT_STOP)
00038 return;
00039
00040 if (!param.empty())
00041 {
00042 nc->greet = param;
00043 source.Reply(_("Greet message for \002%s\002 changed to \002%s\002."), nc->display.c_str(), nc->greet.c_str());
00044 }
00045 else
00046 {
00047 nc->greet.clear();
00048 source.Reply(_("Greet message for \002%s\002 unset."), nc->display.c_str());
00049 }
00050
00051 return;
00052 }
00053
00054 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00055 {
00056 this->Run(source, source.nc->display, params.size() > 0 ? params[0] : "");
00057 }
00058
00059 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00060 {
00061 this->SendSyntax(source);
00062 source.Reply(" ");
00063 source.Reply(_("Makes the given message the greet of your nickname, that\n"
00064 "will be displayed when joining a channel that has GREET\n"
00065 "option enabled, provided that you have the necessary \n"
00066 "access on it."));
00067 return true;
00068 }
00069 };
00070
00071 class CommandNSSASetGreet : public CommandNSSetGreet
00072 {
00073 public:
00074 CommandNSSASetGreet(Module *creator) : CommandNSSetGreet(creator, "nickserv/saset/greet", 1)
00075 {
00076 this->ClearSyntax();
00077 this->SetSyntax(_("\037nickname\037 \037message\037"));
00078 }
00079
00080 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00081 {
00082 this->Run(source, params[0], params.size() > 1 ? params[1] : "");
00083 }
00084
00085 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00086 {
00087 this->SendSyntax(source);
00088 source.Reply(" ");
00089 source.Reply(_("Makes the given message the greet of the nickname, that\n"
00090 "will be displayed when joining a channel that has GREET\n"
00091 "option enabled, provided that the user has the necessary \n"
00092 "access on it."));
00093 return true;
00094 }
00095 };
00096
00097 class NSSetGreet : public Module
00098 {
00099 CommandNSSetGreet commandnssetgreet;
00100 CommandNSSASetGreet commandnssasetgreet;
00101
00102 public:
00103 NSSetGreet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00104 commandnssetgreet(this), commandnssasetgreet(this)
00105 {
00106 this->SetAuthor("Anope");
00107
00108 }
00109 };
00110
00111 MODULE_INIT(NSSetGreet)