cs_sendpass.c

Go to the documentation of this file.
00001 /* ChanServ 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  * $Id: cs_sendpass.c 1265 2007-08-26 15:33:06Z geniusdex $
00012  *
00013  */
00014 /*************************************************************************/
00015 
00016 #include "module.h"
00017 
00018 int do_sendpass(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_sendpass.c 1265 2007-08-26 15:33:06Z geniusdex $");
00033     moduleSetType(CORE);
00034 
00035     c = createCommand("SENDPASS", do_sendpass, NULL, CHAN_HELP_SENDPASS,
00036                       -1, -1, -1, -1);
00037     moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
00038 
00039     moduleSetChanHelp(myChanServHelp);
00040 
00041     if (UseMail) {
00042         return MOD_CONT;
00043     } else {
00044         return MOD_STOP;
00045     }
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_SENDPASS);
00065 }
00066 
00072 int do_sendpass(User * u)
00073 {
00074 
00075     char *chan = strtok(NULL, " ");
00076     ChannelInfo *ci;
00077     NickCore *founder;
00078 
00079     if (!chan) {
00080         syntax_error(s_ChanServ, u, "SENDPASS", CHAN_SENDPASS_SYNTAX);
00081     } else if (RestrictMail && !is_services_oper(u)) {
00082         notice_lang(s_ChanServ, u, PERMISSION_DENIED);
00083     } else if (!(ci = cs_findchan(chan)) || !(founder = ci->founder)) {
00084         notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
00085     } else if (ci->flags & CI_VERBOTEN) {
00086         notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan);
00087     } else {
00088         char buf[BUFSIZE];
00089     char tmp_pass[PASSMAX];
00090     if(enc_decrypt(ci->founderpass,tmp_pass,PASSMAX)==1) {
00091             MailInfo *mail;
00092 
00093             snprintf(buf, sizeof(buf),
00094                      getstring2(founder, CHAN_SENDPASS_SUBJECT), ci->name);
00095             mail = MailBegin(u, founder, buf, s_ChanServ);
00096             if (!mail)
00097                 return MOD_CONT;
00098 
00099             fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_HEAD));
00100             fprintf(mail->pipe, "\n\n");
00101             fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_1),
00102                     ci->name);
00103             fprintf(mail->pipe, "\n\n");
00104             fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_2),
00105                     tmp_pass);
00106             fprintf(mail->pipe, "\n\n");
00107             fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_3));
00108             fprintf(mail->pipe, "\n\n");
00109             fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_4));
00110             fprintf(mail->pipe, "\n\n");
00111             fprintf(mail->pipe, getstring2(founder, CHAN_SENDPASS_LINE_5),
00112                     NetworkName);
00113             fprintf(mail->pipe, "\n.\n");
00114  
00115             MailEnd(mail);
00116 
00117             alog("%s: %s!%s@%s used SENDPASS on %s", s_ChanServ, u->nick,
00118                  u->username, u->host, chan);
00119             notice_lang(s_ChanServ, u, CHAN_SENDPASS_OK, chan);
00120         } else {
00121         notice_lang(s_ChanServ, u, CHAN_SENDPASS_UNAVAILABLE);
00122     }
00123     }
00124     return MOD_CONT;
00125 }

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