Anope IRC Services  Version 1.8
ns_getemail.c
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  *
12  * A simple call to check for all emails that a user may have registered
13  * with. It returns the nicks that match the email you provide. Wild
14  * Cards are not excepted. Must use user@email-host.
15  *
16  *
17  */
18 /*************************************************************************/
19 
20 #include "module.h"
21 
22 static int do_getemail(User * u);
23 static void myNickServHelp(User * u);
24 
31 int AnopeInit(int argc, char **argv)
32 {
33  Command *c;
34 
35  moduleAddAuthor("Anope");
36  moduleAddVersion(VERSION_STRING);
38 
39  c = createCommand("GETEMAIL", do_getemail, is_services_admin, -1, -1,
40  -1, NICK_SERVADMIN_HELP_GETEMAIL,
41  NICK_SERVADMIN_HELP_GETEMAIL);
43 
45 
46  return MOD_CONT;
47 }
48 
52 void AnopeFini(void)
53 {
54 
55 }
56 
61 static void myNickServHelp(User * u)
62 {
63  if (is_services_admin(u)) {
64  notice_lang(s_NickServ, u, NICK_HELP_CMD_GETEMAIL);
65  }
66 }
67 
73 static int do_getemail(User * u)
74 {
75  char *email = strtok(NULL, " ");
76  int i, j = 0;
77  NickCore *nc;
78 
79  if (!email) {
80  syntax_error(s_NickServ, u, "GETMAIL", NICK_GETEMAIL_SYNTAX);
81  return MOD_CONT;
82  }
83  alog("%s: %s!%s@%s used GETEMAIL on %s", s_NickServ, u->nick,
84  u->username, u->host, email);
85  for (i = 0; i < 1024; i++) {
86  for (nc = nclists[i]; nc; nc = nc->next) {
87  if (nc->email) {
88  if (stricmp(nc->email, email) == 0) {
89  j++;
90  notice_lang(s_NickServ, u, NICK_GETEMAIL_EMAILS_ARE,
91  nc->display, email);
92  }
93  }
94  }
95  }
96  if (j <= 0) {
97  notice_lang(s_NickServ, u, NICK_GETEMAIL_NOT_USED, email);
98  return MOD_CONT;
99  }
100  return MOD_CONT;
101 }
char nick[NICKMAX]
Definition: services.h:875
E int stricmp(const char *s1, const char *s2)
Definition: compat.c:58
char * host
Definition: services.h:878
MDE void moduleAddAuthor(const char *author)
Definition: modules.c:1772
E void syntax_error(char *service, User *u, const char *command, int msgnum)
Definition: language.c:295
E void notice_lang(char *source, User *dest, int message,...)
Definition: send.c:169
MDE void moduleSetType(MODType type)
Definition: modules.c:818
void AnopeFini(void)
Definition: ns_getemail.c:52
char * display
Definition: services.h:542
static void myNickServHelp(User *u)
Definition: ns_getemail.c:61
int AnopeInit(int argc, char **argv)
Definition: ns_getemail.c:31
NickCore * next
Definition: services.h:540
MDE void moduleAddVersion(const char *version)
Definition: modules.c:1760
Command * c
Definition: ns_recover.c:17
E void alog(const char *fmt,...) FORMAT(printf
#define MOD_CONT
Definition: modules.h:54
E int is_services_admin(User *u)
Definition: operserv.c:591
char * username
Definition: services.h:877
MDE void moduleSetNickHelp(void(*func)(User *u))
Definition: modules.c:2078
Definition: modules.h:99
MDE Command * createCommand(const char *name, int(*func)(User *u), int(*has_priv)(User *u), int help_all, int help_reg, int help_oper, int help_admin, int help_root)
Definition: modules.c:987
static int do_getemail(User *u)
Definition: ns_getemail.c:73
E NickCore * nclists[1024]
Definition: extern.h:924
E char * s_NickServ
Definition: extern.h:284
MDE int moduleAddCommand(CommandHash *cmdTable[], Command *c, int pos)
Definition: modules.c:1082
#define NICKSERV
Definition: modules.h:59
#define MOD_UNIQUE
Definition: module.h:11
char * email
Definition: services.h:544