anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
ns_status.cpp (2945B)
1 /* NickServ 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 CommandNSStatus : public Command 15 { 16 public: 17 CommandNSStatus(Module *creator) : Command(creator, "nickserv/status", 0, 16) 18 { 19 this->SetDesc(_("Returns the owner status of the given nickname")); 20 this->SetSyntax(_("[\037nickname\037]")); 21 this->AllowUnregistered(true); 22 } 23 24 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override 25 { 26 const Anope::string &nick = !params.empty() ? params[0] : source.GetNick(); 27 const NickAlias *na = NickAlias::Find(nick); 28 spacesepstream sep(nick); 29 Anope::string nickbuf; 30 31 while (sep.GetToken(nickbuf)) 32 { 33 User *u2 = User::Find(nickbuf, true); 34 if (!u2) /* Nick is not online */ 35 source.Reply("STATUS %s %d %s", nickbuf.c_str(), 0, ""); 36 else if (u2->IsIdentified() && na && na->nc == u2->Account()) /* Nick is identified */ 37 source.Reply("STATUS %s %d %s", nickbuf.c_str(), 3, u2->Account()->display.c_str()); 38 else if (u2->IsRecognized()) /* Nick is recognised, but NOT identified */ 39 source.Reply("STATUS %s %d %s", nickbuf.c_str(), 2, u2->Account() ? u2->Account()->display.c_str() : ""); 40 else if (!na) /* Nick is online, but NOT a registered */ 41 source.Reply("STATUS %s %d %s", nickbuf.c_str(), 0, ""); 42 else 43 /* Nick is not identified for the nick, but they could be logged into an account, 44 * so we tell the user about it 45 */ 46 source.Reply("STATUS %s %d %s", nickbuf.c_str(), 1, u2->Account() ? u2->Account()->display.c_str() : ""); 47 } 48 return; 49 } 50 51 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override 52 { 53 this->SendSyntax(source); 54 source.Reply(" "); 55 source.Reply(_("Returns whether the user using the given nickname is\n" 56 "recognized as the owner of the nickname. The response has\n" 57 "this format:\n" 58 " \n" 59 " \037nickname\037 \037status-code\037 \037account\037\n" 60 " \n" 61 "where \037nickname\037 is the nickname sent with the command,\n" 62 "\037status-code\037 is one of the following, and \037account\037\n" 63 "is the account they are logged in as.\n" 64 " \n" 65 " 0 - no such user online \002or\002 nickname not registered\n" 66 " 1 - user not recognized as nickname's owner\n" 67 " 2 - user recognized as owner via access list only\n" 68 " 3 - user recognized as owner via password identification\n" 69 " \n" 70 "If no nickname is given, your status will be returned.")); 71 return true; 72 } 73 }; 74 75 class NSStatus : public Module 76 { 77 CommandNSStatus commandnsstatus; 78 79 public: 80 NSStatus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), 81 commandnsstatus(this) 82 { 83 84 } 85 }; 86 87 MODULE_INIT(NSStatus)