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 CommandNSSetDisplay : public Command
00017 {
00018 public:
00019 CommandNSSetDisplay(Module *creator, const Anope::string &sname = "nickserv/set/display", size_t min = 1) : Command(creator, sname, min, min + 1)
00020 {
00021 this->SetDesc(_("Set the display of your group in Services"));
00022 this->SetSyntax(_("\037new-display\037"));
00023 }
00024
00025 void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m)
00026 {
00027 const NickAlias *user_na = NickAlias::Find(user), *na = NickAlias::Find(param);
00028
00029 if (user_na == NULL)
00030 {
00031 source.Reply(NICK_X_NOT_REGISTERED, user.c_str());
00032 return;
00033 }
00034 else if (!na || *na->nc != *user_na->nc)
00035 {
00036 source.Reply(_("The new display MUST be a nickname of the nickname group %s"), user_na->nc->display.c_str());
00037 return;
00038 }
00039
00040 EventReturn MOD_RESULT;
00041 FOREACH_RESULT(I_OnSetNickOption, OnSetNickOption(source, this, user_na->nc, param));
00042 if (MOD_RESULT == EVENT_STOP)
00043 return;
00044
00045 user_na->nc->SetDisplay(na);
00046 source.Reply(NICK_SET_DISPLAY_CHANGED, user_na->nc->display.c_str());
00047 }
00048
00049 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00050 {
00051 this->Run(source, source.nc->display, params[0]);
00052 }
00053
00054 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00055 {
00056 this->SendSyntax(source);
00057 source.Reply(" ");
00058 source.Reply(_("Changes the display used to refer to your nickname group in \n"
00059 "Services. The new display MUST be a nick of your group."));
00060 return true;
00061 }
00062 };
00063
00064 class CommandNSSASetDisplay : public CommandNSSetDisplay
00065 {
00066 public:
00067 CommandNSSASetDisplay(Module *creator) : CommandNSSetDisplay(creator, "nickserv/saset/display", 2)
00068 {
00069 this->ClearSyntax();
00070 this->SetSyntax(_("\037nickname\037 \037new-display\037"));
00071 }
00072
00073 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
00074 {
00075 this->Run(source, params[0], params[1]);
00076 }
00077
00078 bool OnHelp(CommandSource &source, const Anope::string &) anope_override
00079 {
00080 this->SendSyntax(source);
00081 source.Reply(" ");
00082 source.Reply(_("Changes the display used to refer to the nickname group in \n"
00083 "Services. The new display MUST be a nick of your group."));
00084 return true;
00085 }
00086 };
00087
00088 class NSSetDisplay : public Module
00089 {
00090 CommandNSSetDisplay commandnssetdisplay;
00091 CommandNSSASetDisplay commandnssasetdisplay;
00092
00093 public:
00094 NSSetDisplay(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00095 commandnssetdisplay(this), commandnssasetdisplay(this)
00096 {
00097 this->SetAuthor("Anope");
00098
00099 if (Config->NoNicknameOwnership)
00100 throw ModuleException(modname + " can not be used with options:nonicknameownership enabled");
00101 }
00102 };
00103
00104 MODULE_INIT(NSSetDisplay)