#include "module.h" #define AUTHOR "SGR" #define VERSION "1.00" /* ----------------------------------------------------------- * Name: bs_autoassign * Author: SGR * Date: 04/04/2004 * ----------------------------------------------------------- * Functions: m_cs_auto_set_successor, m_cs_is_real_founder. * Limitations: None Known. * Tested: Ultimate(2.8.x), Unreal(3.2), Viagra. * ----------------------------------------------------------- * * This module is designed to set the sucessor of a channel * to a specific Nick as it is registered. Additionally, * notices about the setting can be sent to the channel * founder. * * Finally, the module can be configured to check all channels * and if any are found to not have a founder set to set it to * the pre-defined nick. * * ----------------------------------------------------------- * Change Log: * * 1: Works * * ----------------------------------------------------------- */ /* ---------------------------------------------------------------------- */ /* START OF CONFIGURATION BLOCK - please read the comments :) */ /* ---------------------------------------------------------------------- */ /* This nick MUST be that of a registered Nick on you network, that is * NOT suspended or forbidden. [MANDATORY] */ #define SUCCESSOR_NICK "Boobs" /* The below notices will be broadcast when a user registers a channel that * then has its successor set to SUCCESSOR_NICK automatically. Up to 6 * notices can be sent. To use these notices define them by remvoving the * // from the beginnning of the lines, then by editing the text between * the "quotes". */ // #define DEFAULT_SUCCESSOR_NOTICE1 "You channel's successor is being set to the networks 'channel" // #define DEFAULT_SUCCESSOR_NOTICE2 "recovery' bot. Feel free to change the sucessor, however we" // #define DEFAULT_SUCCESSOR_NOTICE3 "request you don't UNSET the successor for the sake of it." // #define DEFAULT_SUCCESSOR_NOTICE4 " " // #define DEFAULT_SUCCESSOR_NOTICE5 " " /* if the below is defined, a logchan message will NOT be generated when * this module sets the default successor of a channel to the * SUCCESSOR_NICK. To undefine this add // to the beginning of the line. */ #define DONT_LOG_SET_DEFAULT_SUCCESSOR /* Define this If you wish for this module to automatically Scan all channels * and If any without a successor are found to set the successor to the * SUCCESSOR_NICK when the module is loaded. */ #define SET_BLANK_TO_SUCCESSOR_NICK_ON_LOAD /* ---------------------------------------------------------------------- * DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING * ---------------------------------------------------------------------- No, like seriously, stop reading here. Erm.. this is important... like stop ... now. you just won't give up will you? pff, some people have no respect for others. ------------------------------------------------------------------------ */ static int m_cs_is_real_founder(User *u, ChannelInfo *ci); int m_cs_auto_set_successor(User *u); NickAlias *sna; extern ChannelInfo *chanlists[256]; int AnopeInit(int argc, char **argv) { NickAlias *na; Command *c; int count=0; int i = 0; ChannelInfo *ci; if (!SUCCESSOR_NICK) { alog("[cs_defaultsuccessor] ERROR: See Below."); alog("[cs_defaultsuccessor] Auto-Unloading (Please configure this module properly.)"); return MOD_STOP; } if (!(na = findnick(SUCCESSOR_NICK))) { alog("[cs_defaultsuccessor] ERROR: See Below."); alog("[cs_defaultsuccessor] You set a nick, in the module configuration block..."); alog("[cs_defaultsuccessor] but was it worth it if that nick hasn't been registered?"); alog("[cs_defaultsuccessor] Set a %s registered nick in the module config block!", s_NickServ); alog("[cs_defaultsuccessor] Auto-Unloading (Please configure this module properly."); return MOD_STOP; } if (na->status & NS_VERBOTEN) { alog("[cs_defaultsuccessor] ERROR: See Below."); alog("[cs_defaultsuccessor] You set a nick, in the module configuration block..."); alog("[cs_defaultsuccessor] but was it worth it if that nick is forbidden?"); alog("[cs_defaultsuccessor] Auto-Unloading (Please configure this module properly.)"); return MOD_CONT; } sna = na; c = createCommand("REGISTER", m_cs_auto_set_successor, NULL,-1,-1,-1,-1,-1); moduleAddCommand(CHANSERV, c, MOD_TAIL); alog("[cs_defaultsuccessor] All channels registered will now have their successor set to %s by default.", sna->nc->display); alog("[cs_defaultsuccessor] Yayness!(tm) - MODULE LOADED AND ACTIVE"); moduleAddAuthor(AUTHOR); moduleAddVersion(VERSION); #ifdef SET_BLANK_TO_SUCCESSOR_NICK_ON_LOAD for (i = 0; i < 256; i++) { for (ci = chanlists[i]; ci; ci = ci->next) { if ((ci->successor == NULL)) { count++; ci->successor = sna->nc; ci->successor->display = sna->nc->display; } } } alog("[cs_defaultsuccessor] Auto-Set successor on %d channels to %s.", count, sna->nc->display); #endif return MOD_CONT; } void AnopeFini(void) { alog("Unloading module cs_defaultsuccessor.so"); } int m_cs_auto_set_successor(User *u) { char *getchan = moduleGetLastBuffer(); char *chanB = strtok(getchan, " "); ChannelInfo *ci; if (!getchan || !chanB) { return MOD_CONT; } /* No chan was registered - syntax error perhaps? */ if (!(ci = cs_findchan(chanB))) { return MOD_CONT; } /* peep is trying to reg a chan thats already registered or the chan is flagged NOBOT*/ if (!m_cs_is_real_founder(u, ci)) { return MOD_CONT; } #ifndef DONT_LOG_SET_DEFAULT_SUCCESSOR alog("ChanServ: AUTO-SETTING Successor [%s] [Chan: %s] [Founder: %s]", ci->name, chanB, u->nick); #endif ci->successor = sna->nc; ci->successor->display = sna->nc->display; #ifdef DEFAULT_SUCCESSOR_NOTICE1 notice(s_ChanServ, u->nick, DEFAULT_SUCCESSOR_NOTICE1) #endif #ifdef DEFAULT_SUCCESSOR_NOTICE2 notice(s_ChanServ, u->nick, DEFAULT_SUCCESSOR_NOTICE2) #endif #ifdef DEFAULT_SUCCESSOR_NOTICE3 notice(s_ChanServ, u->nick, DEFAULT_SUCCESSOR_NOTICE3) #endif #ifdef DEFAULT_SUCCESSOR_NOTICE4 notice(s_ChanServ, u->nick, DEFAULT_SUCCESSOR_NOTICE4) #endif #ifdef DEFAULT_SUCCESSOR_NOTICE5 notice(s_ChanServ, u->nick, DEFAULT_SUCCESSOR_NOTICE5) #endif return MOD_CONT; } static int m_cs_is_real_founder(User *u, ChannelInfo *ci) { if (u->isSuperAdmin) { return 1; } if (u->na && u->na->nc == ci->founder) { if ((nick_identified(u) || (nick_recognized(u) && !(ci->flags & CI_SECURE)))) { return 1; } } return 0; }