ns_getemail.c

Go to the documentation of this file.
00001 /* NickServ core functions
00002  *
00003  * (C) 2003-2007 Anope Team
00004  * Contact us at info@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  *
00012  * A simple call to check for all emails that a user may have registered 
00013  * with. It returns the nicks that match the email you provide. Wild     
00014  * Cards are not excepted. Must use user@email-host.                     
00015  * 
00016  * $Id: ns_getemail.c 1265 2007-08-26 15:33:06Z geniusdex $
00017  *
00018  */
00019 /*************************************************************************/
00020 
00021 #include "module.h"
00022 
00023 int do_getemail(User * u);
00024 void myNickServHelp(User * u);
00025 
00032 int AnopeInit(int argc, char **argv)
00033 {
00034     Command *c;
00035 
00036     moduleAddAuthor("Anope");
00037     moduleAddVersion("$Id: ns_getemail.c 1265 2007-08-26 15:33:06Z geniusdex $");
00038     moduleSetType(CORE);
00039 
00040     c = createCommand("GETEMAIL", do_getemail, is_services_admin, -1, -1,
00041                       -1, NICK_SERVADMIN_HELP_GETEMAIL,
00042                       NICK_SERVADMIN_HELP_GETEMAIL);
00043     moduleAddCommand(NICKSERV, c, MOD_UNIQUE);
00044 
00045     moduleSetNickHelp(myNickServHelp);
00046 
00047     return MOD_CONT;
00048 }
00049 
00053 void AnopeFini(void)
00054 {
00055 
00056 }
00057 
00062 void myNickServHelp(User * u)
00063 {
00064     if (is_services_admin(u)) {
00065         notice_lang(s_NickServ, u, NICK_HELP_CMD_GETEMAIL);
00066     }
00067 }
00068 
00074 int do_getemail(User * u)
00075 {
00076     char *email = strtok(NULL, " ");
00077     int i, j = 0;
00078     NickCore *nc;
00079 
00080     if (!email) {
00081         syntax_error(s_NickServ, u, "GETMAIL", NICK_GETEMAIL_SYNTAX);
00082         return MOD_CONT;
00083     }
00084     alog("%s: %s!%s@%s used GETEMAIL on %s", s_NickServ, u->nick,
00085          u->username, u->host, email);
00086     for (i = 0; i < 1024; i++) {
00087         for (nc = nclists[i]; nc; nc = nc->next) {
00088             if (nc->email) {
00089                 if (stricmp(nc->email, email) == 0) {
00090                     j++;
00091                     notice_lang(s_NickServ, u, NICK_GETEMAIL_EMAILS_ARE,
00092                                 nc->display, email);
00093                 }
00094             }
00095         }
00096     }
00097     if (j <= 0) {
00098         notice_lang(s_NickServ, u, NICK_GETEMAIL_NOT_USED, email);
00099         return MOD_CONT;
00100     }
00101     return MOD_CONT;
00102 }

Generated on Sun Dec 30 09:26:47 2007 for Anope by  doxygen 1.5.1-20070107