cs_identify.c

Go to the documentation of this file.
00001 /* ChanServ core functions
00002  *
00003  * (C) 2003-2008 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  * $Id: cs_identify.c 1345 2008-01-13 12:54:14Z geniusdex $
00012  *
00013  */
00014 /*************************************************************************/
00015 
00016 #include "module.h"
00017 
00018 int do_identify(User * u);
00019 void myChanServHelp(User * u);
00020 
00027 int AnopeInit(int argc, char **argv)
00028 {
00029     Command *c;
00030 
00031     moduleAddAuthor("Anope");
00032     moduleAddVersion("$Id: cs_identify.c 1345 2008-01-13 12:54:14Z geniusdex $");
00033     moduleSetType(CORE);
00034 
00035     c = createCommand("IDENTIFY", do_identify, NULL, CHAN_HELP_IDENTIFY,
00036                       -1, -1, -1, -1);
00037     moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
00038 
00039     c = createCommand("ID", do_identify, NULL, CHAN_HELP_IDENTIFY, -1, -1,
00040                       -1, -1);
00041     moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
00042 
00043     moduleSetChanHelp(myChanServHelp);
00044 
00045     return MOD_CONT;
00046 }
00047 
00051 void AnopeFini(void)
00052 {
00053 
00054 }
00055 
00056 
00057 
00062 void myChanServHelp(User * u)
00063 {
00064     notice_lang(s_ChanServ, u, CHAN_HELP_CMD_IDENTIFY);
00065 }
00066 
00072 int do_identify(User * u)
00073 {
00074     char *chan = strtok(NULL, " ");
00075     char *pass = strtok(NULL, " ");
00076     ChannelInfo *ci;
00077     struct u_chaninfolist *uc;
00078 
00079     if (!pass) {
00080         syntax_error(s_ChanServ, u, "IDENTIFY", CHAN_IDENTIFY_SYNTAX);
00081     } else if (!(ci = cs_findchan(chan))) {
00082         notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
00083     } else if (ci->flags & CI_VERBOTEN) {
00084         notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
00085     } else if (!nick_identified(u)) {
00086         notice_lang(s_ChanServ, u, NICK_IDENTIFY_REQUIRED, s_NickServ);
00087     } else if (is_founder(u, ci)) {
00088         notice_lang(s_ChanServ, u, NICK_ALREADY_IDENTIFIED);
00089     } else {
00090         int res;
00091 
00092         if ((res = enc_check_password(pass, ci->founderpass)) == 1) {
00093             if (!is_identified(u, ci)) {
00094                 uc = scalloc(sizeof(*uc), 1);
00095                 uc->next = u->founder_chans;
00096                 if (u->founder_chans)
00097                     u->founder_chans->prev = uc;
00098                 u->founder_chans = uc;
00099                 uc->chan = ci;
00100                 alog("%s: %s!%s@%s identified for %s", s_ChanServ, u->nick,
00101                      u->username, u->host, ci->name);
00102             }
00103 
00104             notice_lang(s_ChanServ, u, CHAN_IDENTIFY_SUCCEEDED, chan);
00105         } else if (res < 0) {
00106             alog("%s: check_password failed for %s", s_ChanServ, ci->name);
00107             notice_lang(s_ChanServ, u, CHAN_IDENTIFY_FAILED);
00108         } else {
00109             alog("%s: Failed IDENTIFY for %s by %s!%s@%s",
00110                  s_ChanServ, ci->name, u->nick, u->username, u->host);
00111             notice_lang(s_ChanServ, u, PASSWORD_INCORRECT);
00112             bad_password(u);
00113         }
00114 
00115     }
00116     return MOD_CONT;
00117 }

Generated on Sun Oct 5 09:06:54 2008 for Anope by  doxygen 1.5.7.1