ns_getemail.cpp

Go to the documentation of this file.
00001 /* NickServ core functions
00002  *
00003  * (C) 2003-2013 Anope Team
00004  * Contact us at team@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church.
00010  *
00011  * A simple call to check for all emails that a user may have registered
00012  * with. It returns the nicks that match the email you provide. Wild
00013  * Cards are not excepted. Must use user@email-host.
00014  */
00015 
00016 /*************************************************************************/
00017 
00018 #include "module.h"
00019 
00020 class CommandNSGetEMail : public Command
00021 {
00022  public:
00023         CommandNSGetEMail(Module *creator) : Command(creator, "nickserv/getemail", 1, 1)
00024         {
00025                 this->SetDesc(_("Matches and returns all users that registered using given email"));
00026                 this->SetSyntax(_("\037email\037"));
00027         }
00028 
00029         void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
00030         {
00031                 const Anope::string &email = params[0];
00032                 int j = 0;
00033 
00034                 Log(LOG_ADMIN, source, this) << "on " << email;
00035 
00036                 for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
00037                 {
00038                         const NickCore *nc = it->second;
00039 
00040                         if (!nc->email.empty() && nc->email.equals_ci(email))
00041                         {
00042                                 ++j;
00043                                 source.Reply(_("Email matched: \002%s\002 to \002%s\002."), nc->display.c_str(), email.c_str());
00044                         }
00045                 }
00046 
00047                 if (j <= 0)
00048                 {
00049                         source.Reply(_("No nick registrations matching \002%s\002 found."), email.c_str());
00050                         return;
00051                 }
00052 
00053                 return;
00054         }
00055 
00056         bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
00057         {
00058                 this->SendSyntax(source);
00059                 source.Reply(" ");
00060                 source.Reply(_("Returns the matching nicks that used given email. \002Note\002 that\n"
00061                                 "you can not use wildcards. Whenever this command is used, a message\n"
00062                                 "including the person who issued the command and the email it was used\n"
00063                                 "on will be logged."));
00064                 return true;
00065         }
00066 };
00067 
00068 class NSGetEMail : public Module
00069 {
00070         CommandNSGetEMail commandnsgetemail;
00071  public:
00072         NSGetEMail(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
00073                 commandnsgetemail(this)
00074         {
00075                 this->SetAuthor("Anope");
00076 
00077         }
00078 };
00079 
00080 MODULE_INIT(NSGetEMail)