#include "module.h" #define AUTHOR "SGR" #define VERSION "1.02" /* ------------------------------------------------------------ * Name: cs_prefixentrymsg * Author: SGR * Date: 27/12/2003 * ------------------------------------------------------------ * Functions: m_cs_set_entrymsg, m_cs_checkentrymsg * Limitations: None known. * Tested: Ultimate(2.8.x) + (3-a31), Unreal(3.2), Viagra * ------------------------------------------------------------ * * This module has no configurable options. For information on * this module, load it and refer to: * /ChanServ HELP SET ENTRYMSG * * Please note that while this module is loaded any new * ENTRYMSGs set using the SET ENTRYMSG command will have that * channels name prefixed to it. * * This module has two configurable options - APPENDSTRING and * PREPENDSTING - * * ------------------------------------------------------------ */ /* ---------------------------------------------------------------------- */ /* START OF CONFIGURATION BLOCK - please read the comments :) */ /* ---------------------------------------------------------------------- */ /* ----------------------------------------------*/ /* ONLY CHANGE WHAT IS INSIDE THE "speach marks" */ /* The sum of the legnth of APPENDSTRING and */ /* PREPENDSTRING if either of one of is used */ /* MUST be less than 500 characters. [ideally no */ /* more than 20] */ /* ----------------------------------------------*/ /* * The following are used in the style: * : * If neither is provided, entrymessages will be saved as: * : * * Yes, I know I put appened and prepend the wrong way round. I didn't * expect to be adding a prepend option. */ #define APPENDSTRING "Entry message for" //#define PREPENDSTRING "Bleh." /* ---------------------------------------------------------------------- */ /* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */ /* ---------------------------------------------------------------------- */ int m_cs_set_entrymsg(User *u, ChannelInfo *ci, char *msg); int m_cs_checkentrymsg(User *u); int AnopeInit(int argc, char **argv) { Command *c; alog("Loading module cs_prefixentrymsg.so"); c = createCommand("SET",m_cs_checkentrymsg,NULL,-1,-1,-1,-1,-1); moduleAddCommand(CHANSERV, c, MOD_HEAD); alog("[cs_prefixentrymsg] Command Modified: /msg %s SET ENTRYMSG", s_ChanServ); alog("[cs_prefixentrymsg] A channel's name will now prefix any newly set entry messages."); alog("[cs_prefixentrymsg] Yayness!(tm) - MODULE LOADED AND ACTIVE"); moduleAddAuthor(AUTHOR); moduleAddVersion(VERSION); return MOD_CONT; } void AnopeFini(void) { alog("Unloading module cs_prefixentrymsg.so"); } int m_cs_set_entrymsg(User *u, ChannelInfo *ci, char *msg) { char newentrymsg[1024]; // Max IRC msg is 512, double that should be *ample* when prefixing with a CHANMAX-legnth string. if (ci->entry_message) { free(ci->entry_message); } if (msg) { #if defined(APPENDSTRING) && defined(PREPENDSTRING) snprintf(newentrymsg, sizeof(newentrymsg), "%s %s %s: %s", APPENDSTRING , ci->name, PREPENDSTRING , msg); #elif defined(APPENDSTRING) && !defined(PREPENDSTRING) snprintf(newentrymsg, sizeof(newentrymsg), "%s %s: %s", APPENDSTRING, ci->name, msg); #elif defined(PREPENDSTRING) && !defined(APPENDSTRING) snprintf(newentrymsg, sizeof(newentrymsg), "%s %s: %s", ci->name, PREPENDSTRING, msg); #else snprintf(newentrymsg, sizeof(newentrymsg), "%s: %s", ci->name, msg); #endif ci->entry_message = sstrdup(newentrymsg); notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_CHANGED, ci->name, newentrymsg); } else { ci->entry_message = NULL; notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_UNSET, ci->name); } return MOD_STOP; } int m_cs_checkentrymsg(User * u) { char *buffer = moduleGetLastBuffer(); char *chan = NULL; char *setting = NULL; char *details = NULL; ChannelInfo *ci; if (readonly) { notice_lang(s_ChanServ, u, CHAN_SET_DISABLED); return MOD_CONT; } if (myStrGetToken(buffer,' ',0) && myStrGetToken(buffer,' ',1)) { chan = sstrdup(myStrGetToken(buffer,' ',0)); setting = sstrdup(myStrGetToken(buffer,' ',1)); } else { return MOD_CONT; } if (myStrGetTokenRemainder(buffer,' ',2)) { details = sstrdup(myStrGetTokenRemainder(buffer,' ',2)); } else { details = NULL; } if (!(ci = cs_findchan(chan))) { notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); } else if (ci->flags & CI_VERBOTEN) { notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, chan); } else if (!is_services_admin(u) && !check_access(u, ci, CA_SET)) { notice_lang(s_ChanServ, u, ACCESS_DENIED); } else if (!stricmp(setting, "ENTRYMSG")) { m_cs_set_entrymsg(u, ci, details); free(chan); free(setting); if (details != NULL) { free(details); } return MOD_CONT; } else { // yeah, I end on an else, call me senteMENTAL. } free(chan); free(setting); if (details != NULL) { free(details); } return MOD_CONT; }