#include "module.h" #define AUTHOR "SGR" #define VERSION "1.02" /* ----------------------------------------------------------- * Name: cs_checkchan * Author: SGR * Date: 02/11/2003 * ----------------------------------------------------------- * Functions: check_chan_is_reged. * Limitations: only 10 can be checked at a time. * Tested: Ultimate(2.8.x), Unreal(3.2), Bahamut * ----------------------------------------------------------- * This version has been tested on Ultimate2.8.6, Unreal and * Bahamut. All IRCd's should be compatible with this module. * * Up to 10 chans can be specified. * * Please set the config options below. * * ChangeLog * * 1) Works * 2) Updated to use for-loops. * 3) Added free's for sstrdup'd data. * * -----------------------------------------------------------*/ /* ---------------------------------------------------------------------- */ /* START OF CONFIGURATION BLOCK - please read the comments :) */ /* ---------------------------------------------------------------------- */ /* ----------------------------------------------*/ /* ONLY CHANGE WHAT IS INSIDE THE "speach marks" */ /* and limit each line to 400 characters. */ /* ----------------------------------------------*/ /* Use 'checkchan' as a pointer to the chan currently being checked. * ALL defines must have a value. */ #define YES_ITS_REGISTERED "%s is registered. See \2/%s INFO %s\2 for more info.", checkchan, s_ChanServ, checkchan #define NO_ITS_NOT_REGISTERED "%s is NOT registered.", checkchan #define NO_CHAN_GIVEN "SYNTAX: /%s CHECKCHAN [#chan1] [#chan2] [#chan3] ... [#chan10]", s_ChanServ #define ONLY_TEN_CHANS_PLEASE "List Truncated -- Only ten channels can be checked at a time." #define IS_FORBIDDEN_CHAN "%s is a FORBIDDEN channel (can't be registered or used).", checkchan #define IS_SUSPENDED_CHAN "%s is a SUSPENDED channel (registered but locked-out).", checkchan /* ---------------------------------------------------------------------- */ /* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */ /* ---------------------------------------------------------------------- */ int check_chan_is_reged(User * u); void SGR_Module_Help_CHANSERV_CHECKCHAN(User *u); int SGR_Module_Help_CHANSERV_CHECKCHAN_FULL(User *u); int AnopeInit(int argc, char **argv) { Command *c; alog("Loading module ns_operonly_register.so"); c = createCommand("CHECKCHAN", check_chan_is_reged, NULL,-1,-1,-1,-1,-1); moduleAddCommand(CHANSERV, c, MOD_HEAD); moduleAddHelp(c,SGR_Module_Help_CHANSERV_CHECKCHAN_FULL); moduleSetChanHelp(SGR_Module_Help_CHANSERV_CHECKCHAN); alog("[ns_checkchan] NEW Command added: /msg %s CHECKCHAN", s_ChanServ); alog("[ns_checkchan] Yayness!(tm) - MODULE LOADED AND ACTIVE"); moduleAddAuthor(AUTHOR); moduleAddVersion(VERSION); return MOD_CONT; } int check_chan_is_reged(User * u) { /* this has got to be the most ugly function i have EVER made * someone remind me to recode this using a while or for loop * as simply its nasty as hell. */ int howmany=0; int i=0; char *checkchan=NULL; char *chan[11]; ChannelInfo *ci; for (i = 0; i < 11; i++, howmany++) { if ((chan[i] = strtok(NULL, " ")) == NULL) { break; } } //if (ci->flags & CI_VERBOTEN) { if (!howmany) { notice(s_ChanServ, u->nick, NO_CHAN_GIVEN); return MOD_CONT; } for (i = 0; chan[i] != NULL; i++) { if (i >= 10) { break; } if (chan[i]) { checkchan = sstrdup(chan[i]); } if (!cs_findchan(chan[i])) { notice(s_ChanServ, u->nick, NO_ITS_NOT_REGISTERED); } if ((ci = cs_findchan(chan[i]))) { if (ci->flags & CI_VERBOTEN) { notice(s_ChanServ, u->nick, IS_FORBIDDEN_CHAN); } if (ci->flags & CI_SUSPENDED) { notice(s_ChanServ, u->nick, IS_SUSPENDED_CHAN); } else { if (!(ci->flags & CI_VERBOTEN) || (ci->flags & CI_SUSPENDED)) { notice(s_ChanServ, u->nick, YES_ITS_REGISTERED); } } } if (checkchan != NULL) { free(checkchan); } } if (howmany > 10) { notice(s_ChanServ, u->nick, ONLY_TEN_CHANS_PLEASE); } if (checkchan) { free(checkchan); } return MOD_CONT; } int SGR_Module_Help_CHANSERV_CHECKCHAN_FULL(User *u) { notice(s_ChanServ, u->nick, "-----------------------------------------------------------------------"); notice(s_ChanServ, u->nick, "Syntax: CHECKCHAN [chan1] [chan2] [chan3] ... [chan10] "); notice(s_ChanServ, u->nick, " "); notice(s_ChanServ, u->nick, "The CHECKCHAN command can be used as a substute for the INFO command"); notice(s_ChanServ, u->nick, "for checking wether a chan is registered with %s.", s_ChanServ); notice(s_ChanServ, u->nick, "Upto 10 different chans can be specifed in any one command."); notice(s_ChanServ, u->nick, "-----------------------------------------------------------------------"); return MOD_CONT; } void SGR_Module_Help_CHANSERV_CHECKCHAN(User *u) { notice(s_ChanServ,u->nick, " CHECKCHAN Check if a chan is registered."); return; }