Anope IRC Services  Version 2.0
ns_getemail.cpp
Go to the documentation of this file.
1 /* NickServ core functions
2  *
3  * (C) 2003-2014 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  * A simple call to check for all emails that a user may have registered
12  * with. It returns the nicks that match the email you provide. Wild
13  * Cards are not excepted. Must use user@email-host.
14  */
15 
16 #include "module.h"
17 
18 class CommandNSGetEMail : public Command
19 {
20  public:
21  CommandNSGetEMail(Module *creator) : Command(creator, "nickserv/getemail", 1, 1)
22  {
23  this->SetDesc(_("Matches and returns all users that registered using given email"));
24  this->SetSyntax(_("\037email\037"));
25  }
26 
27  void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
28  {
29  const Anope::string &email = params[0];
30  int j = 0;
31 
32  Log(LOG_ADMIN, source, this) << "on " << email;
33 
34  for (nickcore_map::const_iterator it = NickCoreList->begin(), it_end = NickCoreList->end(); it != it_end; ++it)
35  {
36  const NickCore *nc = it->second;
37 
38  if (!nc->email.empty() && nc->email.equals_ci(email))
39  {
40  ++j;
41  source.Reply(_("Email matched: \002%s\002 to \002%s\002."), nc->display.c_str(), email.c_str());
42  }
43  }
44 
45  if (j <= 0)
46  {
47  source.Reply(_("No nick registrations matching \002%s\002 found."), email.c_str());
48  return;
49  }
50 
51  return;
52  }
53 
54  bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
55  {
56  this->SendSyntax(source);
57  source.Reply(" ");
58  source.Reply(_("Returns the matching nicks that used given email. \002Note\002 that\n"
59  "you can not use wildcards. Whenever this command is used, a message\n"
60  "including the person who issued the command and the email it was used\n"
61  "on will be logged."));
62  return true;
63  }
64 };
65 
66 class NSGetEMail : public Module
67 {
69  public:
70  NSGetEMail(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
71  commandnsgetemail(this)
72  {
73 
74  }
75 };
76 
NSGetEMail(const Anope::string &modname, const Anope::string &creator)
Definition: ns_getemail.cpp:70
CoreExport Serialize::Checker< nickcore_map > NickCoreList
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: ns_getemail.cpp:27
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: ns_getemail.cpp:54
void SetDesc(const Anope::string &d)
Definition: command.cpp:130
bool equals_ci(const char *_str) const
Definition: anope.h:78
Anope::string display
Definition: account.h:113
#define anope_override
Definition: services.h:56
bool empty() const
Definition: anope.h:126
#define MODULE_INIT(x)
Definition: modules.h:45
void SetSyntax(const Anope::string &s)
Definition: command.cpp:140
void SendSyntax(CommandSource &)
Definition: command.cpp:145
const char * c_str() const
Definition: anope.h:117
Definition: logger.h:53
CommandNSGetEMail commandnsgetemail
Definition: ns_getemail.cpp:68
Anope::string email
Definition: account.h:116
CommandNSGetEMail(Module *creator)
Definition: ns_getemail.cpp:21
#define _(x)
Definition: services.h:50