#include "module.h" #define AUTHOR "SGR" #define VERSION "1.01" /* ------------------------------------------------------------ * Name: cs_emailonregister * Author: SGR * Date: 08/01/2004 * ------------------------------------------------------------ * Functions: m_cs_check_email_register * m_cs_check_did_register * do_send_about_to_expire_chan * m_cs_send_on_reg_mailpipe * MailInfo *m_cs_MailBegin_NETSTAFF * Limitations: None known. * Tested: Ultimate(2.8.x) + (3-a31), Unreal(3.2), Viagra * ------------------------------------------------------------ * * This module has 25 configurable options. For information on * this module, read the comments in the configuration block. * * * ------------------------------------------------------------ * Change Log: * * 1: Works * 2: Added Support for Anope-1.7.x (revision 370+) * ------------------------------------------------------------ */ /* ---------------------------------------------------------------------- */ /* START OF CONFIGURATION BLOCK - please read the comments :) */ /* ---------------------------------------------------------------------- */ /* If you are using Anope-1.7.x or later, leave this alone. * Otherwise change it to '#undef ANOPE17x' (no quotes). * * THIS IS IMPORTANT * */ #define ANOPE17x /* Set this to 1 to Enable mailing to the founder on channel registration, * or 0 to disable - MANDATORY*/ #define MAIL_TO_USER 1 /* Set this to 1 to Enable mailing to the STAFF_MAIL_ADDRESS address on * channel registration, or 0 to disable - MANDATORY */ #define MAIL_TO_STAFF 1 /* The below must be defined. To disable it set MAIL_TO_STAFF to 0. * This _MUST_ be a _VALID_ email address. - MANDATORY*/ #define STAFF_MAIL_ADDRESS "lamer@to-lazy-to-configure.localhost" /* The below is the subject and contents of the Email sent. */ /* Subject used when mailing to a staff address - MANDATORY*/ #define STAFFCHANMAILONREGSUBJECT "Channel registered." /* Subject used when mailing to the channel founder - MANDATORY */ #define CHANMAILONREGSUBJECT "You have sucessfully registered a channel." /* This is the contents of the mail sent - configure to your networks * style. Please use '\n' to represent a line-feed character. * feel free to use as few or as many as you wish, comment * them out if they are unused. [To comment a line out * add // to the beginning of it].*/ #define CHANMAILONREG1 "Your have sucessfully registered a channel on the SGR-IRC\n" #define CHANMAILONREG2 "network. ChanServ will now provide your channel with a \n" #define CHANMAILONREG3 "full set of access control and channel maintaince options\n" #define CHANMAILONREG4 "\n\n" #define CHANMAILONREG5 "Your channel: " //#define CHANMAILONREG6 " " /* CHANNEL NAME GOES HERE HERE */ #define CHANMAILONREG7 "\n was sucessfully" #define CHANMAILONREG8 "registered with the password:" //#define CHANMAILONREG9 " " //#define CHANMAILONREG10 " " /* CHANNEL PASSWORD GOES HERE HERE [If anope was NOT compiled with MD5] */ #define CHANMAILONREG11 "\n\n" #define CHANMAILONREG12 "For help on configuring the settings of your channel with\n" #define CHANMAILONREG13 "ChanServ, please see '/ChanServ HELP' from within IRC." #define CHANMAILONREG14 "\n\n PLEASE DO NOT REPLY TO THIS E-MAIL!\n\n" #define CHANMAILONREG15 "The SGR-IRC Services Team." //#define CHANMAILONREG16 " " //#define CHANMAILONREG17 " " //#define CHANMAILONREG18 " " //#define CHANMAILONREG19 " " //#define CHANMAILONREG20 " " /* ---------------------------------------------------------------------- */ /* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */ /* ---------------------------------------------------------------------- */ int m_cs_check_email_register(User *u); int m_cs_check_did_register(User *u); static int do_send_about_to_expire_chan(User *u, ChannelInfo *ci); void m_cs_send_on_reg_mailpipe(MailInfo *mail, ChannelInfo *ci); MailInfo *m_cs_MailBegin_NETSTAFF(char *mailaddy, char *subject); int do_allow_on_regsend=1; int AnopeInit(int argc, char **argv) { Command *c; if (!UseMail) { alog("[cs_emailonregister] ERROR: UseMail not defined."); alog("[cs_emailonregister] Module Auto-Unloading."); return MOD_STOP; } if (stricmp("lamer@to-lazy-to-configure.localhost",STAFF_MAIL_ADDRESS)==0) { alog("[cs_emailonregister] ERROR: Services-Root is a total lamer."); alog("[cs_emailonregister] ERROR: Services-Root needs to configure modules before compiling them."); oper_global(NULL,"So you all know - the 'Services Root Administrator' of this network is a total lamer."); alog("[cs_emailonregister] Module Auto-Unloading."); return MOD_STOP; } c=createCommand("REGISTER", m_cs_check_email_register,NULL,-1,-1,-1,-1,-1); moduleAddCommand(CHANSERV,c,MOD_HEAD); c=createCommand("REGISTER", m_cs_check_did_register,NULL,-1,-1,-1,-1,-1); moduleAddCommand(CHANSERV,c,MOD_TAIL); alog("[cs_emailonregister] Loading module cs_emailonregister.so"); alog("[cs_emailonregister] Command Modified: /msg ChanServ REGISTER"); alog("[cs_emailonregister] /msg ChanServ REGISTER now supports the arguments:"); alog("[cs_emailonregister] EMAIL [on|off] - For Services Admins and above."); alog("[cs_emailonregister] i.e: /msg ChanServ REGISTER EMAIL [on|off]"); alog("[cs_emailonregister] Yayness (TM) - Module loaded and active."); return MOD_CONT; } void AnopeFini(void) { alog("Unloading cs_mailexpirewarning.so"); } int m_cs_check_email_register(User *u) { char *gettext = moduleGetLastBuffer(); if (!is_services_admin(u)) { return MOD_CONT; } if (myStrGetToken(gettext,' ',0)) { if (stricmp("email",myStrGetToken(gettext,' ',0))==0) { if (myStrGetToken(gettext,' ',1)==NULL) { if (do_allow_on_regsend==1) { notice(s_ChanServ, u->nick, "E-mailing on register is currently ON"); } else { notice(s_ChanServ, u->nick, "E-mailing on register is currently OFF"); } return MOD_STOP; } else if (stricmp("on",myStrGetToken(gettext,' ',1))==0) { do_allow_on_regsend = 1; notice(s_ChanServ, u->nick, "E-mailing on register has been set ON"); #ifndef ANOPE17x wallops(s_ChanServ, "E-mailing on register has been set ON by %s", u->nick); #else anope_cmd_global(s_ChanServ, "E-mailing on register has been set ON by %s", u->nick); #endif } else if (stricmp("off",myStrGetToken(gettext,' ',1))==0) { do_allow_on_regsend = 0; notice(s_ChanServ, u->nick, "E-mailing on register has been set OFF"); #ifndef ANOPE17x wallops(s_ChanServ, "E-mailing on register has been set OFF by %s", u->nick); #else anope_cmd_global(s_ChanServ, "E-mailing on register has been set OFF by %s", u->nick); #endif } return MOD_STOP; } return MOD_CONT; } return MOD_CONT; } int m_cs_check_did_register(User *u) { char *gettext = moduleGetLastBuffer(); ChannelInfo *ci; if (myStrGetToken(gettext,' ',0)) { if (!(ci = cs_findchan(myStrGetToken(gettext,' ',0)))) { return MOD_CONT; } else { do_send_about_to_expire_chan(u, ci); } } return MOD_CONT; } static int do_send_about_to_expire_chan(User *u, ChannelInfo *ci) { if (!ci) { return MOD_STOP; } else if (!ci->name) { return MOD_STOP; } else if (ci->flags & (CI_VERBOTEN | CI_SUSPENDED)) { return MOD_STOP; } else { if (MAIL_TO_USER == 1) { char buf[BUFSIZE]; MailInfo *mail; //User * u, NickCore * nc, char *subject, char *service snprintf(buf, sizeof(buf), CHANMAILONREGSUBJECT); mail = MailBegin(u, u->na->nc, buf, s_ChanServ); if (!mail) { return MOD_STOP; } m_cs_send_on_reg_mailpipe(mail, ci); } if (MAIL_TO_STAFF == 1) { char bufa[BUFSIZE]; MailInfo *mail; snprintf(bufa, sizeof(bufa), STAFFCHANMAILONREGSUBJECT); mail = m_cs_MailBegin_NETSTAFF(STAFF_MAIL_ADDRESS, bufa); if (!mail) { return MOD_STOP; } m_cs_send_on_reg_mailpipe(mail, ci); } } return MOD_CONT; } void m_cs_send_on_reg_mailpipe(MailInfo *mail, ChannelInfo *ci) { #ifdef CHANMAILONREG1 fprintf(mail->pipe, CHANMAILONREG1); #endif #ifdef CHANMAILONREG2 fprintf(mail->pipe, CHANMAILONREG2); #endif #ifdef CHANMAILONREG3 fprintf(mail->pipe, CHANMAILONREG3); #endif #ifdef CHANMAILONREG4 fprintf(mail->pipe, CHANMAILONREG4); #endif #ifdef CHANMAILONREG5 fprintf(mail->pipe, CHANMAILONREG5); #endif #ifdef CHANMAILONREG6 fprintf(mail->pipe, CHANMAILONREG6); #endif fprintf(mail->pipe, "%s", ci->name); #ifdef CHANMAILONREG7 fprintf(mail->pipe, CHANMAILONREG7); #endif #ifdef CHANMAILONREG8 fprintf(mail->pipe, CHANMAILONREG8); #endif #ifdef CHANMAILONREG9 fprintf(mail->pipe, CHANMAILONREG9); #endif #ifdef CHANMAILONREG10 fprintf(mail->pipe, CHANMAILONREG10); #endif #ifndef USE_ENCRYPTION fprintf(mail->pipe, "%s", ci->founderpass); #endif #ifdef CHANMAILONREG11 fprintf(mail->pipe, CHANMAILONREG11); #endif #ifdef CHANMAILONREG12 fprintf(mail->pipe, CHANMAILONREG12); #endif #ifdef CHANMAILONREG12 fprintf(mail->pipe, CHANMAILONREG13); #endif #ifdef CHANMAILONREG14 fprintf(mail->pipe, CHANMAILONREG14); #endif #ifdef CHANMAILONREG15 fprintf(mail->pipe, CHANMAILONREG15); #endif #ifdef CHANMAILONREG16 fprintf(mail->pipe, CHANMAILONREG16); #endif #ifdef CHANMAILONREG17 fprintf(mail->pipe, CHANMAILONREG17); #endif #ifdef CHANMAILONREG18 fprintf(mail->pipe, CHANMAILONREG18); #endif #ifdef CHANMAILONREG19 fprintf(mail->pipe, CHANMAILONREG19); #endif #ifdef CHANMAILONREG20 fprintf(mail->pipe, CHANMAILONREG20); #endif MailEnd(mail); } MailInfo *m_cs_MailBegin_NETSTAFF(char *mailaddy, char *subject) { if (!mailaddy || !subject) { return NULL; } if (!UseMail) { return NULL; } else { MailInfo *mail; mail = scalloc(sizeof(MailInfo), 1); mail->sender = NULL; mail->recipient = NULL; mail->recip = NULL; if (!(mail->pipe = popen(SendMailPath, "w"))) { free(mail); alog("[cs_emailonregister] ERROR: Sending e-mail delayed. "); alog("[cs_emailonregister] ERROR: Suggestion: \002/msg %s REGISTER EMAIL OFF\002", s_ChanServ); alog("[cs_emailonregister] ERROR: untill the problem is resolved"); return NULL; } fprintf(mail->pipe, "From: %s\n", SendFrom); if (DontQuoteAddresses) { fprintf(mail->pipe, "To: %s <%s>\n", NetworkName, mailaddy); } else { fprintf(mail->pipe, "To: \"%s\" <%s>\n", NetworkName, mailaddy); } fprintf(mail->pipe, "Subject: %s\n", subject); return mail; } return NULL; }