diff options
author | Adam <Adam@anope.org> | 2011-10-14 12:20:07 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-10-14 12:20:07 -0400 |
commit | ddc3c2f38cf6ddc0c1f8ad82489a281e01ef50fc (patch) | |
tree | 832b02a62d2da9078b7ab5f9d4d5d99e15570294 /modules/commands | |
parent | 53275c362c521807b70e1eb7cf936f35593dd4dc (diff) |
Added options:nonicknameownership config option
Diffstat (limited to 'modules/commands')
-rw-r--r-- | modules/commands/ns_ghost.cpp | 2 | ||||
-rw-r--r-- | modules/commands/ns_group.cpp | 8 | ||||
-rw-r--r-- | modules/commands/ns_logout.cpp | 6 | ||||
-rw-r--r-- | modules/commands/ns_recover.cpp | 7 | ||||
-rw-r--r-- | modules/commands/ns_register.cpp | 12 | ||||
-rw-r--r-- | modules/commands/ns_release.cpp | 2 | ||||
-rw-r--r-- | modules/commands/ns_saset.cpp | 43 | ||||
-rw-r--r-- | modules/commands/ns_set.cpp | 38 | ||||
-rw-r--r-- | modules/commands/ns_set_display.cpp | 99 | ||||
-rw-r--r-- | modules/commands/ns_set_kill.cpp | 2 |
10 files changed, 126 insertions, 93 deletions
diff --git a/modules/commands/ns_ghost.cpp b/modules/commands/ns_ghost.cpp index db4ff1dcd..a03ca9a3f 100644 --- a/modules/commands/ns_ghost.cpp +++ b/modules/commands/ns_ghost.cpp @@ -115,6 +115,8 @@ class NSGhost : public Module { this->SetAuthor("Anope"); + if (Config->NoNicknameOwnership) + throw ModuleException(modname + " can not be used with options:nonicknameownership enabled"); } }; diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp index b41cad09d..6a83f4f46 100644 --- a/modules/commands/ns_group.cpp +++ b/modules/commands/ns_group.cpp @@ -109,10 +109,10 @@ class CommandNSGroup : public Command na->time_registered = na->last_seen = Anope::CurTime; u->Login(na->nc); + ircdproto->SendLogin(u); + if (!Config->NoNicknameOwnership && na->nc == u->Account() && na->nc->HasFlag(NI_UNCONFIRMED) == false) + u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); FOREACH_MOD(I_OnNickGroup, OnNickGroup(u, target)); - if (target->nc->HasFlag(NI_UNCONFIRMED) == false) - ircdproto->SendAccountLogin(u, u->Account()); - ircdproto->SetAutoIdentificationToken(u); Log(LOG_COMMAND, u, this) << "makes " << u->nick << " join group of " << target->nick << " (" << target->nc->display << ") (email: " << (!target->nc->email.empty() ? target->nc->email : "none") << ")"; source.Reply(_("You are now in the group of \002%s\002."), target->nick.c_str()); @@ -296,6 +296,8 @@ class NSGroup : public Module { this->SetAuthor("Anope"); + if (Config->NoNicknameOwnership) + throw ModuleException(modname + " can not be used with options:nonicknameownership enabled"); } }; diff --git a/modules/commands/ns_logout.cpp b/modules/commands/ns_logout.cpp index 63798cdcb..fb958fd90 100644 --- a/modules/commands/ns_logout.cpp +++ b/modules/commands/ns_logout.cpp @@ -51,10 +51,8 @@ class CommandNSLogout : public Command else source.Reply(_("Your nick has been logged out.")); - ircdproto->SendAccountLogout(u2, u2->Account()); - u2->RemoveMode(source.owner, UMODE_REGISTERED); - ircdproto->SendUnregisteredNick(u2); - + ircdproto->SendLogout(u2); + u2->RemoveMode(findbot(Config->NickServ), UMODE_REGISTERED); u2->Logout(); /* Send out an event */ diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp index f1a22129d..a6761db51 100644 --- a/modules/commands/ns_recover.cpp +++ b/modules/commands/ns_recover.cpp @@ -23,9 +23,8 @@ class CommandNSRecover : public Command if (u->Account() == na->nc) { - ircdproto->SendAccountLogout(u, u->Account()); - u->RemoveMode(source.owner, UMODE_REGISTERED); - ircdproto->SendUnregisteredNick(u); + ircdproto->SendLogout(u); + u->RemoveMode(findbot(Config->NickServ), UMODE_REGISTERED); } u->Collide(na); @@ -133,6 +132,8 @@ class NSRecover : public Module { this->SetAuthor("Anope"); + if (Config->NoNicknameOwnership) + throw ModuleException(modname + " can not be used with options:nonicknameownership enabled"); } }; diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index acfcd2acd..303321551 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -53,9 +53,10 @@ class CommandNSConfirm : public Command Log(LOG_COMMAND, u, this) << "to confirm their email"; source.Reply(_("Your email address of \002%s\002 has been confirmed."), u->Account()->email.c_str()); u->Account()->UnsetFlag(NI_UNCONFIRMED); - ircdproto->SendAccountLogin(u, u->Account()); + + ircdproto->SendLogin(u); NickAlias *na = findnick(u->nick); - if (na && na->nc == u->Account()) + if (!Config->NoNicknameOwnership && na != NULL && na->nc == u->Account() && na->nc->HasFlag(NI_UNCONFIRMED) == false) u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); } else @@ -199,8 +200,11 @@ class CommandNSRegister : public Command } } else - ircdproto->SendAccountLogin(u, u->Account()); - ircdproto->SetAutoIdentificationToken(u); + { + ircdproto->SendLogin(u); + if (!Config->NoNicknameOwnership && na->nc == u->Account() && na->nc->HasFlag(NI_UNCONFIRMED) == false) + u->SetMode(findbot(Config->NickServ), UMODE_REGISTERED); + } u->lastnickreg = Anope::CurTime; } diff --git a/modules/commands/ns_release.cpp b/modules/commands/ns_release.cpp index eb8a42729..0fdc2517c 100644 --- a/modules/commands/ns_release.cpp +++ b/modules/commands/ns_release.cpp @@ -103,6 +103,8 @@ class NSRelease : public Module { this->SetAuthor("Anope"); + if (Config->NoNicknameOwnership) + throw ModuleException(modname + " can not be used with options:nonicknameownership enabled"); } }; diff --git a/modules/commands/ns_saset.cpp b/modules/commands/ns_saset.cpp index d8305e43a..481b8655e 100644 --- a/modules/commands/ns_saset.cpp +++ b/modules/commands/ns_saset.cpp @@ -55,46 +55,6 @@ class CommandNSSASet : public Command } }; -class CommandNSSASetDisplay : public Command -{ - public: - CommandNSSASetDisplay(Module *creator) : Command(creator, "nickserv/saset/display", 2, 2) - { - this->SetDesc(_("Set the display of the group in Services")); - this->SetSyntax(_("\037nickname\037 \037new-display\037")); - } - - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) - { - NickAlias *setter_na = findnick(params[0]); - if (setter_na == NULL) - { - source.Reply(NICK_X_NOT_REGISTERED, params[0].c_str()); - return; - } - NickCore *nc = setter_na->nc; - - NickAlias *na = findnick(params[1]); - if (!na || na->nc != nc) - { - source.Reply(_("The new display for \002%s\002 MUST be a nickname of the nickname group!"), nc->display.c_str()); - return; - } - - change_core_display(nc, params[1]); - source.Reply(NICK_SET_DISPLAY_CHANGED, nc->display.c_str()); - return; - } - - bool OnHelp(CommandSource &source, const Anope::string &) - { - this->SendSyntax(source); - source.Reply(_("Changes the display used to refer to the nickname group in \n" - "Services. The new display MUST be a nick of the group.")); - return true; - } -}; - class CommandNSSASetPassword : public Command { public: @@ -155,12 +115,11 @@ class CommandNSSASetPassword : public Command class NSSASet : public Module { CommandNSSASet commandnssaset; - CommandNSSASetDisplay commandnssasetdisplay; CommandNSSASetPassword commandnssasetpassword; public: NSSASet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - commandnssaset(this), commandnssasetdisplay(this), commandnssasetpassword(this) + commandnssaset(this), commandnssasetpassword(this) { this->SetAuthor("Anope"); diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index 11334565f..a3f2a1950 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -55,41 +55,6 @@ class CommandNSSet : public Command } }; -class CommandNSSetDisplay : public Command -{ - public: - CommandNSSetDisplay(Module *creator) : Command(creator, "nickserv/set/display", 1) - { - this->SetDesc(_("Set the display of your group in Services")); - this->SetSyntax(_("\037new-display\037")); - } - - void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) - { - User *u = source.u; - NickAlias *na = findnick(params[1]); - - if (!na || na->nc != u->Account()) - { - source.Reply(_("The new display MUST be a nickname of your nickname group!")); - return; - } - - change_core_display(u->Account(), params[1]); - source.Reply(NICK_SET_DISPLAY_CHANGED, u->Account()->display.c_str()); - return; - } - - bool OnHelp(CommandSource &source, const Anope::string &) - { - this->SendSyntax(source); - source.Reply(" "); - source.Reply(_("Changes the display used to refer to your nickname group in \n" - "Services. The new display MUST be a nick of your group.")); - return true; - } -}; - class CommandNSSetPassword : public Command { public: @@ -140,12 +105,11 @@ class CommandNSSetPassword : public Command class NSSet : public Module { CommandNSSet commandnsset; - CommandNSSetDisplay commandnssetdisplay; CommandNSSetPassword commandnssetpassword; public: NSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), - commandnsset(this), commandnssetdisplay(this), commandnssetpassword(this) + commandnsset(this), commandnssetpassword(this) { this->SetAuthor("Anope"); diff --git a/modules/commands/ns_set_display.cpp b/modules/commands/ns_set_display.cpp new file mode 100644 index 000000000..a2328247c --- /dev/null +++ b/modules/commands/ns_set_display.cpp @@ -0,0 +1,99 @@ +/* NickServ core functions + * + * (C) 2003-2011 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + +/*************************************************************************/ + +#include "module.h" + +class CommandNSSetDisplay : public Command +{ + public: + CommandNSSetDisplay(Module *creator, const Anope::string &sname = "nickserv/set/display", size_t min = 1) : Command(creator, sname, min, min + 1) + { + this->SetDesc(_("Set the display of your group in Services")); + this->SetSyntax(_("\037new-display\037")); + } + + void Run(CommandSource &source, const Anope::string &user, const Anope::string ¶m) + { + NickAlias *user_na = findnick(user), *na = findnick(param); + + if (user_na == NULL) + { + source.Reply(NICK_X_NOT_REGISTERED, user.c_str()); + return; + } + else if (!na || na->nc != user_na->nc) + { + source.Reply(_("The new display MUST be a nickname of the nickname group %s"), user_na->nc->display.c_str()); + return; + } + + change_core_display(user_na->nc, na->nick); + source.Reply(NICK_SET_DISPLAY_CHANGED, user_na->nc->display.c_str()); + } + + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + { + this->Run(source, source.u->Account()->display, params[0]); + } + + bool OnHelp(CommandSource &source, const Anope::string &) + { + this->SendSyntax(source); + source.Reply(" "); + source.Reply(_("Changes the display used to refer to your nickname group in \n" + "Services. The new display MUST be a nick of your group.")); + return true; + } +}; + +class CommandNSSASetDisplay : public CommandNSSetDisplay +{ + public: + CommandNSSASetDisplay(Module *creator) : CommandNSSetDisplay(creator, "nickserv/saset/display", 2) + { + this->ClearSyntax(); + this->SetSyntax(_("\037nickname\037 \037new-display\037")); + } + + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) + { + this->Run(source, params[0], params[1]); + } + + bool OnHelp(CommandSource &source, const Anope::string &) + { + this->SendSyntax(source); + source.Reply(" "); + source.Reply(_("Changes the display used to refer to the nickname group in \n" + "Services. The new display MUST be a nick of your group.")); + return true; + } +}; + +class NSSetDisplay : public Module +{ + CommandNSSetDisplay commandnssetdisplay; + CommandNSSASetDisplay commandnssasetdisplay; + + public: + NSSetDisplay(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE), + commandnssetdisplay(this), commandnssasetdisplay(this) + { + this->SetAuthor("Anope"); + + if (Config->NoNicknameOwnership) + throw ModuleException(modname + " can not be used with options:nonicknameownership enabled"); + } +}; + +MODULE_INIT(NSSetDisplay) diff --git a/modules/commands/ns_set_kill.cpp b/modules/commands/ns_set_kill.cpp index ed15d57f4..33a8a2531 100644 --- a/modules/commands/ns_set_kill.cpp +++ b/modules/commands/ns_set_kill.cpp @@ -141,6 +141,8 @@ class NSSetKill : public Module { this->SetAuthor("Anope"); + if (Config->NoNicknameOwnership) + throw ModuleException(modname + " can not be used with options:nonicknameownership enabled"); } }; |