From e0583918834a3f8683e430adf3923ea89d2a449a Mon Sep 17 00:00:00 2001 From: "rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b" Date: Mon, 2 May 2005 19:02:12 +0000 Subject: BUILD : 1.7.8 (753) BUGS : N/a NOTES : Merged anope-dev with trunk git-svn-id: svn://svn.anope.org/anope/trunk@753 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@516 5417fbe8-f217-4b02-8779-1006273d7864 --- src/modules/catserv/Makefile | 9 - src/modules/catserv/README | 4 - src/modules/catserv/catserv_extern.h | 11 - src/modules/catserv/catserv_messages.c | 14 - src/modules/catserv/catserv_messages.h | 10 - src/modules/catserv/ircd_catserv.c | 112 ----- src/modules/catserv/makefile.win32 | 4 - src/modules/catserv/meow.c | 9 - src/modules/catserv/meow.h | 9 - src/modules/catserv/purr.c | 8 - src/modules/catserv/purr.h | 9 - src/modules/configure | 30 +- src/modules/cs_appendtopic.c | 188 ++++++++ src/modules/cs_enforce.c | 334 ++++++++++++++ src/modules/cs_tban.c | 171 +++++++ src/modules/demos/catserv/Makefile | 9 + src/modules/demos/catserv/README | 4 + src/modules/demos/catserv/catserv_extern.h | 11 + src/modules/demos/catserv/catserv_messages.c | 14 + src/modules/demos/catserv/catserv_messages.h | 10 + src/modules/demos/catserv/ircd_catserv.c | 112 +++++ src/modules/demos/catserv/makefile.win32 | 4 + src/modules/demos/catserv/meow.c | 9 + src/modules/demos/catserv/meow.h | 9 + src/modules/demos/catserv/purr.c | 8 + src/modules/demos/catserv/purr.h | 9 + src/modules/demos/events.c | 82 ++++ src/modules/demos/hs_conf.c | 74 ++++ src/modules/demos/hs_moo.c | 119 +++++ src/modules/events.c | 53 --- src/modules/hs_moo.c | 119 ----- src/modules/makefile.inc.win32 | 4 +- src/modules/makefile.win32 | 1 - src/modules/module.h | 10 - src/modules/ns_maxemail.c | 190 ++++++++ src/modules/ns_noop.c | 483 ++++++++++++++++++++ src/modules/os_info.c | 639 +++++++++++++++++++++++++++ 37 files changed, 2501 insertions(+), 394 deletions(-) delete mode 100644 src/modules/catserv/Makefile delete mode 100644 src/modules/catserv/README delete mode 100644 src/modules/catserv/catserv_extern.h delete mode 100644 src/modules/catserv/catserv_messages.c delete mode 100644 src/modules/catserv/catserv_messages.h delete mode 100644 src/modules/catserv/ircd_catserv.c delete mode 100644 src/modules/catserv/makefile.win32 delete mode 100644 src/modules/catserv/meow.c delete mode 100644 src/modules/catserv/meow.h delete mode 100644 src/modules/catserv/purr.c delete mode 100644 src/modules/catserv/purr.h create mode 100644 src/modules/cs_appendtopic.c create mode 100644 src/modules/cs_enforce.c create mode 100644 src/modules/cs_tban.c create mode 100644 src/modules/demos/catserv/Makefile create mode 100644 src/modules/demos/catserv/README create mode 100644 src/modules/demos/catserv/catserv_extern.h create mode 100644 src/modules/demos/catserv/catserv_messages.c create mode 100644 src/modules/demos/catserv/catserv_messages.h create mode 100644 src/modules/demos/catserv/ircd_catserv.c create mode 100644 src/modules/demos/catserv/makefile.win32 create mode 100644 src/modules/demos/catserv/meow.c create mode 100644 src/modules/demos/catserv/meow.h create mode 100644 src/modules/demos/catserv/purr.c create mode 100644 src/modules/demos/catserv/purr.h create mode 100644 src/modules/demos/events.c create mode 100644 src/modules/demos/hs_conf.c create mode 100644 src/modules/demos/hs_moo.c delete mode 100644 src/modules/events.c delete mode 100644 src/modules/hs_moo.c delete mode 100644 src/modules/module.h create mode 100644 src/modules/ns_maxemail.c create mode 100644 src/modules/ns_noop.c create mode 100644 src/modules/os_info.c (limited to 'src/modules') diff --git a/src/modules/catserv/Makefile b/src/modules/catserv/Makefile deleted file mode 100644 index 5b2f4efa3..000000000 --- a/src/modules/catserv/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -SRCS= ircd_catserv.c \ - catserv_messages.c \ - meow.c \ - purr.c - -TARGET=ircd_catserv - -include ../Makefile.sub - diff --git a/src/modules/catserv/README b/src/modules/catserv/README deleted file mode 100644 index c3d3f7084..000000000 --- a/src/modules/catserv/README +++ /dev/null @@ -1,4 +0,0 @@ -This is an EXAMPLE module, it serves no real purpose. - -This module was broken down into multiple files to demonstrate how multiple files can be used. - diff --git a/src/modules/catserv/catserv_extern.h b/src/modules/catserv/catserv_extern.h deleted file mode 100644 index 02c21addb..000000000 --- a/src/modules/catserv/catserv_extern.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef CATSERV_DEFS_H -#define CATSERV_DEFS_H - -#ifdef _WIN32 -extern __declspec(dllexport) char *s_CatServ; -#else -E char *s_CatServ; -#endif - -#endif - diff --git a/src/modules/catserv/catserv_messages.c b/src/modules/catserv/catserv_messages.c deleted file mode 100644 index e11235b4e..000000000 --- a/src/modules/catserv/catserv_messages.c +++ /dev/null @@ -1,14 +0,0 @@ -#include "catserv_messages.h" -#include "module.h" -#include "meow.h" -#include "purr.h" - -void addMessageList(void) -{ - Command *c; - c = createCommand("meow", do_meow, NULL, -1, -1, -1, -1, -1); - moduleAddCommand(Catserv_cmdTable, c, MOD_UNIQUE); - c = createCommand("purr", do_purr, NULL, -1, -1, -1, -1, -1); - moduleAddCommand(Catserv_cmdTable, c, MOD_UNIQUE); -} - diff --git a/src/modules/catserv/catserv_messages.h b/src/modules/catserv/catserv_messages.h deleted file mode 100644 index bb3f82dd0..000000000 --- a/src/modules/catserv/catserv_messages.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef CATSERV_MESSAGES_H -#define CATSERV_MESSAGES_H - -#include "module.h" - -CommandHash *Catserv_cmdTable[MAX_CMD_HASH]; -void addMessageList(void); - -#endif - diff --git a/src/modules/catserv/ircd_catserv.c b/src/modules/catserv/ircd_catserv.c deleted file mode 100644 index 2fa7b52b3..000000000 --- a/src/modules/catserv/ircd_catserv.c +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Simple module to load up a client called CatServ and process commands for it - * This module is an example, and has no useful purpose! - * - * Please visit http://modules.anope.org for useful modules! - * - **/ - -#include "module.h" -#include "catserv_messages.h" - -#define AUTHOR "Anope" -#define VERSION "1.2" - -int my_privmsg(char *source, int ac, char **av); - -void addClient(char *nick, char *realname); -void delClient(void); -void catserv(User * u, char *buf); - -char *s_CatServ = "CatServ"; - -int AnopeInit(int argc, char **argv) -{ - Message *msg = NULL; - int status; -#ifdef IRC_UNREAL32 - if (UseTokens) { - msg = createMessage("!", my_privmsg); - } else { - msg = createMessage("PRIVMSG", my_privmsg); - } -#else - msg = createMessage("PRIVMSG", my_privmsg); -#endif - status = moduleAddMessage(msg, MOD_HEAD); - if (status == MOD_ERR_OK) { - addClient(s_CatServ, "meow!"); - addMessageList(); - } - moduleAddAuthor(AUTHOR); - moduleAddVersion(VERSION); - alog("ircd_catserv.so: loaded, message status [%d]", status); - return MOD_CONT; -} - -void AnopeFini(void) -{ - delClient(); -} - -int my_privmsg(char *source, int ac, char **av) -{ - User *u; - char *s; - - /* First, some basic checks */ - if (ac != 2) - return MOD_CONT; /* bleh */ - if (!(u = finduser(source))) { - return MOD_CONT; - } /* non-user source */ - if (*av[0] == '#') { - return MOD_CONT; - } - /* Channel message */ - /* we should prolly honour the ignore list here, but i cba for this... */ - s = strchr(av[0], '@'); - if (s) { - *s++ = 0; - if (stricmp(s, ServerName) != 0) - return MOD_CONT; - } - if ((stricmp(av[0], s_CatServ)) == 0) { /* its for US! */ - catserv(u, av[1]); - return MOD_STOP; - } else { /* ok it isnt us, let the old code have it */ - return MOD_CONT; - } -} - -void addClient(char *nick, char *realname) -{ - anope_cmd_bot_nick(nick, "catserv", "meow.meow.land", realname, "+"); -} - -void delClient(void) -{ - anope_cmd_quit(s_CatServ, "QUIT :Module Unloaded!"); -} - -/*****************************************************************************/ -/* Main CatServ routine. */ -void catserv(User * u, char *buf) -{ - char *cmd, *s; - - cmd = strtok(buf, " "); - - if (!cmd) { - return; - } else if (stricmp(cmd, "\1PING") == 0) { - if (!(s = strtok(NULL, ""))) - s = "\1"; - notice(s_CatServ, u->nick, "\1PING %s", s); - } else if (skeleton) { - notice_lang(s_CatServ, u, SERVICE_OFFLINE, s_CatServ); - } else { - mod_run_cmd(s_CatServ, u, Catserv_cmdTable, cmd); - } -} - diff --git a/src/modules/catserv/makefile.win32 b/src/modules/catserv/makefile.win32 deleted file mode 100644 index 638704440..000000000 --- a/src/modules/catserv/makefile.win32 +++ /dev/null @@ -1,4 +0,0 @@ -SRCS=ircd_catserv.c purr.c catserv_messages.c meow.c -TARGET=ircd_catserv.dll - -include ..\Makefile.sub.win32 diff --git a/src/modules/catserv/meow.c b/src/modules/catserv/meow.c deleted file mode 100644 index 9279eec0b..000000000 --- a/src/modules/catserv/meow.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "meow.h" - -#include "catserv_extern.h" - -int do_meow(User * u) { - notice(s_CatServ, u->nick, "MEOW!"); - return MOD_STOP; -} - diff --git a/src/modules/catserv/meow.h b/src/modules/catserv/meow.h deleted file mode 100644 index 0f28673a0..000000000 --- a/src/modules/catserv/meow.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef CATSERV_MEOW_H -#define CATSERV_MEOW_H - -#include "module.h" - -int do_meow(User * u); - -#endif - diff --git a/src/modules/catserv/purr.c b/src/modules/catserv/purr.c deleted file mode 100644 index 5a39dc26e..000000000 --- a/src/modules/catserv/purr.c +++ /dev/null @@ -1,8 +0,0 @@ -#include "purr.h" -#include "catserv_extern.h" - -int do_purr(User * u) -{ - notice(s_CatServ, u->nick, "PURR!"); - return MOD_STOP; -} diff --git a/src/modules/catserv/purr.h b/src/modules/catserv/purr.h deleted file mode 100644 index a92e421f6..000000000 --- a/src/modules/catserv/purr.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef CATSERV_PURR_H -#define CATSERV_PURR_H - -#include "module.h" - -int do_purr(User * u); - -#endif - diff --git a/src/modules/configure b/src/modules/configure index 119c7c887..4ce3dbd32 100755 --- a/src/modules/configure +++ b/src/modules/configure @@ -2,16 +2,23 @@ echo -n "SRCS=" > ./Makefile.inc FIRST=1 -for oldfile in *.c -do - if [ "$FIRST" = 1 ] ; then - echo -n " "$oldfile >> ./Makefile.inc - else - echo "\\" >> ./Makefile.inc - echo -n " " $oldfile >> ./Makefile.inc - fi - FIRST=0 -done + +LS=`ls *.c 2>/dev/null | wc -l ` +if [ "0" == "$LS" ] ; then + echo "*** no modules found" +else + for oldfile in *.c + do + if [ "$FIRST" = 1 ] ; then + echo -n " "$oldfile >> ./Makefile.inc + else + echo "\\" >> ./Makefile.inc + echo -n " " $oldfile >> ./Makefile.inc + fi + FIRST=0 + done +fi + echo "" >> ./Makefile.inc echo -n "SUBS=" >> ./Makefile.inc @@ -27,6 +34,9 @@ do echo -n " " $dir >> ./Makefile.inc fi FIRST=0 + if [ -f $dir/configure ] ; then + $dir/configure + fi fi fi done diff --git a/src/modules/cs_appendtopic.c b/src/modules/cs_appendtopic.c new file mode 100644 index 000000000..774ba35f1 --- /dev/null +++ b/src/modules/cs_appendtopic.c @@ -0,0 +1,188 @@ +#include "module.h" + +/* Original module: cs_appendtopic by SGR + * + * Included in the Anope module pack since 1.7.9 + * Anope Coder: GeniusDex + * + * Send bug reports to the Anope Coder instead of the module + * author, because any changes since the inclusion into anope + * are not supported by the original author. + */ + +#define AUTHOR "SGR" +#define VERSION "$Id$" + + /* ------------------------------------------------------------ + * Name: cs_appendtopic + * Author: SGR + * Date: 31/08/2003 + * ------------------------------------------------------------ + * + * This module has no configurable options. For information on + * this module, load it and refer to /ChanServ APPENDTOPIC HELP + * + * Thanks to dengel, Rob and Certus for all there support. + * Especially Rob, who always manages to show me where I have + * not allocated any memory. Even if it takes a few weeks of + * pestering to get him to look at it. + * + * ------------------------------------------------------------ + */ + +/* ---------------------------------------------------------------------- */ +/* DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING */ +/* ---------------------------------------------------------------------- */ + +#define LNG_NUM_STRINGS 3 + +#define LNG_CHAN_HELP 0 +#define LNG_CHAN_HELP_APPENDTOPIC 1 +#define LNG_APPENDTOPIC_SYNTAX 2 + +int my_cs_appendtopic(User * u); +void my_cs_help(User * u); +int my_cs_help_appendtopic(User * u); +void my_add_languages(void); + +int AnopeInit(int argc, char **argv) +{ + Command *c; + int status; + + moduleAddAuthor(AUTHOR); + moduleAddVersion(VERSION); + moduleSetType(SUPPORTED); + + c = createCommand("APPENDTOPIC", my_cs_appendtopic, NULL, -1, -1, -1, + -1, -1); + if ((status = moduleAddCommand(CHANSERV, c, MOD_HEAD))) { + alog("[cs_appendtopic] Unable to create APPENDTOPIC command: %d", + status); + return MOD_STOP; + } + moduleAddHelp(c, my_cs_help_appendtopic); + moduleSetChanHelp(my_cs_help); + + my_add_languages(); + + alog("[cs_appendtopic] Loaded succesfully"); + + return MOD_CONT; +} + +void AnopeFini(void) +{ + alog("[cs_appendtopic] Unloaded succefully"); +} + +void my_cs_help(User * u) +{ + moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP); +} + +int my_cs_help_appendtopic(User * u) +{ + moduleNoticeLang(s_ChanServ, u, LNG_APPENDTOPIC_SYNTAX); + notice(s_ChanServ, u->nick, " "); + moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_APPENDTOPIC); + return MOD_STOP; +} + +int my_cs_appendtopic(User * u) +{ + char *cur_buffer; + char *chan; + char *newtopic; + char topic[1024]; + Channel *c; + ChannelInfo *ci; + + cur_buffer = moduleGetLastBuffer(); + chan = myStrGetToken(cur_buffer, ' ', 0); + newtopic = myStrGetTokenRemainder(cur_buffer, ' ', 1); + + if (!chan || !newtopic) { + moduleNoticeLang(s_ChanServ, u, LNG_APPENDTOPIC_SYNTAX); + } else if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); + } else if (!is_services_admin(u) && !check_access(u, ci, CA_TOPIC)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + if (ci->last_topic) { + snprintf(topic, sizeof(topic), "%s %s", ci->last_topic, + newtopic); + free(ci->last_topic); + } else { + strscpy(topic, newtopic, sizeof(topic)); + } + + ci->last_topic = topic ? sstrdup(topic) : NULL; + strscpy(ci->last_topic_setter, u->nick, NICKMAX); + ci->last_topic_time = time(NULL); + + if (c->topic) + free(c->topic); + c->topic = topic ? sstrdup(topic) : NULL; + strscpy(c->topic_setter, u->nick, NICKMAX); + if (ircd->topictsbackward) + c->topic_time = c->topic_time - 1; + else + c->topic_time = ci->last_topic_time; + + if (is_services_admin(u) && !check_access(u, ci, CA_TOPIC)) + alog("%s: %s!%s@%s changed topic of %s as services admin.", + s_ChanServ, u->nick, u->username, u->host, c->name); + if (ircd->join2set) { + if (whosends(ci) == s_ChanServ) { + anope_cmd_join(s_ChanServ, c->name, time(NULL)); + anope_cmd_mode(NULL, c->name, "+o %s", s_ChanServ); + } + } + anope_cmd_topic(whosends(ci), c->name, u->nick, topic ? topic : "", + c->topic_time); + if (ircd->join2set) { + if (whosends(ci) == s_ChanServ) { + anope_cmd_part(s_ChanServ, c->name, NULL); + } + } + } + return MOD_CONT; +} + +void my_add_languages(void) +{ + /* English (US) */ + char *langtable_en_us[] = { + /* LNG_CHAN_HELP */ + " APPENDTOPIC Add text to a channels topic", + /* LNG_CHAN_HELP_APPENDTOPIC */ + "This command allows users to append text to a currently set\n" + "channel topic. When TOPICLOCK is on, the topic is updated and\n" + "the new, updated topic is locked.", + /* LNG_APPENDTOPIC_SYNTAX */ + "Syntax: APPENDTOPIC channel text\n" + }; + + /* Dutch */ + char *langtable_nl[] = { + /* LNG_CHAN_HELP */ + " APPENDTOPIC Voeg tekst aan een kanaal onderwerp toe", + /* LNG_CHAN_HELP_APPENDTOPIC */ + "Dit command stelt gebruikers in staat om text toe te voegen\n" + "achter het huidige onderwerp van een kanaal. Als TOPICLOCK aan\n" + "staat, zal het onderwerp worden bijgewerkt en zal het nieuwe,\n" + "bijgewerkte topic worden geforceerd.", + /* LNG_APPENDTOPIC_SYNTAX */ + "Gebruik: APPENDTOPIC kanaal tekst\n" + }; + + moduleInsertLanguage(LANG_EN_US, LNG_NUM_STRINGS, langtable_en_us); + moduleInsertLanguage(LANG_NL, LNG_NUM_STRINGS, langtable_nl); +} + +/* EOF */ diff --git a/src/modules/cs_enforce.c b/src/modules/cs_enforce.c new file mode 100644 index 000000000..9c6f0b796 --- /dev/null +++ b/src/modules/cs_enforce.c @@ -0,0 +1,334 @@ +/* cs_enforce - Add a /cs ENFORCE command to enforce various set + * options and channelmodes on a channel. + * + * (C) 2003-2005 Anope Team + * Contact us at info@anope.org + * + * Included in the Anope module pack since Anope 1.7.9 + * Anope Coder: GeniusDex + * + * Please read COPYING and README for further details. + * + * Send any bug reports to the Anope Coder, as he will be able + * to deal with it best. + */ + +#include "module.h" + +#define AUTHOR "Anope" +#define VERSION "$Id$" + +int my_cs_enforce(User * u); +void my_cs_help(User * u); +int my_cs_help_enforce(User * u); +void my_add_languages(void); + +#define LNG_NUM_STRINGS 5 + +#define LNG_CHAN_HELP 0 +#define LNG_ENFORCE_SYNTAX 1 +#define LNG_CHAN_HELP_ENFORCE 2 +#define LNG_CHAN_HELP_ENFORCE_R_ENABLED 3 +#define LNG_CHAN_HELP_ENFORCE_R_DISABLED 4 + +int AnopeInit(int argc, char **argv) +{ + Command *c; + int status; + + moduleAddAuthor(AUTHOR); + moduleAddVersion(VERSION); + moduleSetType(SUPPORTED); + + c = createCommand("ENFORCE", my_cs_enforce, NULL, -1, -1, -1, -1, -1); + if ((status = moduleAddCommand(CHANSERV, c, MOD_HEAD))) { + alog("[cs_enforce] Unable to create ENFORCE command: %d", status); + return MOD_STOP; + } + + moduleAddHelp(c, my_cs_help_enforce); + moduleSetChanHelp(my_cs_help); + + my_add_languages(); + + return MOD_CONT; +} + +void AnopeFini(void) +{ + /* Nothing to clean up */ +} + +/* Enforcing functions */ +void do_enforce_secureops(Channel * c) +{ + struct c_userlist *user; + struct c_userlist *next; + ChannelInfo *ci; + uint32 flags; + + if (!(ci = c->ci)) + return; + + if (debug) + alog("debug: cs_enforce: Enforcing SECUREOPS on %s", c->name); + + /* Dirty hack to allow chan_set_correct_modes to work ok. + * We pretend like SECUREOPS is on so it doesn't ignore that + * part of the code. This way we can enforce SECUREOPS even + * if it's off. + */ + flags = ci->flags; + ci->flags |= CI_SECUREOPS; + + user = c->users; + do { + next = user->next; + chan_set_correct_modes(user->user, c, 0); + user = next; + } while (user); + + ci->flags = flags; +} + +void do_enforce_restricted(Channel * c) +{ + struct c_userlist *user; + struct c_userlist *next; + ChannelInfo *ci; + int16 old_nojoin_level; + char mask[BUFSIZE]; + char *reason; + char *av[3]; + User *u; + + if (!(ci = c->ci)) + return; + + if (debug) + alog("debug: cs_enforce: Enforcing RESTRICTED on %s", c->name); + + old_nojoin_level = ci->levels[CA_NOJOIN]; + if (ci->levels[CA_NOJOIN] < 0) + ci->levels[CA_NOJOIN] = 0; + + user = c->users; + do { + next = user->next; + u = user->user; + if (check_access(u, c->ci, CA_NOJOIN)) { + get_idealban(ci, u, mask, sizeof(mask)); + reason = getstring(u->na, CHAN_NOT_ALLOWED_TO_JOIN); + anope_cmd_mode(whosends(ci), ci->name, "+b %s %lu", mask, + time(NULL)); + anope_cmd_kick(whosends(ci), ci->name, u->nick, "%s", reason); + av[0] = ci->name; + av[1] = u->nick; + av[2] = reason; + do_kick(s_ChanServ, 3, av); + } + user = next; + } while (user); + + ci->levels[CA_NOJOIN] = old_nojoin_level; +} + +void do_enforce_cmode_R(Channel * c) +{ + struct c_userlist *user; + struct c_userlist *next; + ChannelInfo *ci; + char mask[BUFSIZE]; + char *reason; + char *av[3]; + User *u; + CBMode *cbm; + + if (!(ci = c->ci)) + return; + + if (debug) + alog("debug: cs_enforce: Enforcing mode +R on %s", c->name); + + user = c->users; + do { + next = user->next; + u = user->user; + if (!nick_identified(u)) { + get_idealban(ci, u, mask, sizeof(mask)); + reason = getstring(u->na, CHAN_NOT_ALLOWED_TO_JOIN); + if (((cbm = &cbmodes['R'])->flag == 0) + || !(c->mode & cbm->flag)) + anope_cmd_mode(whosends(ci), ci->name, "+b %s %lu", mask, + time(NULL)); + anope_cmd_kick(whosends(ci), ci->name, u->nick, "%s", reason); + av[0] = ci->name; + av[1] = u->nick; + av[2] = reason; + do_kick(s_ChanServ, 3, av); + } + user = next; + } while (user); +} + +/* Enforcing Group Functions */ +void do_enforce_set(Channel * c) +{ + ChannelInfo *ci; + + if (!(ci = c->ci)) + return; + + if (ci->flags & CI_SECUREOPS) + do_enforce_secureops(c); + if (ci->flags & CI_RESTRICTED) + do_enforce_restricted(c); +} + +void do_enforce_modes(Channel * c) +{ + CBMode *cbm; + + if (((cbm = &cbmodes['R'])->flag != 0) && (c->mode & cbm->flag)) + do_enforce_cmode_R(c); +} + +/* End of enforcing functions */ + +int my_cs_enforce(User * u) +{ + char *cur_buffer; + char *chan; + char *what; + Channel *c; + ChannelInfo *ci; + + cur_buffer = moduleGetLastBuffer(); + chan = myStrGetToken(cur_buffer, ' ', 0); + + if (!chan) { + moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX); + } else if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name); + } else if (!is_services_admin(u) && !check_access(u, ci, CA_AKICK)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + what = myStrGetToken(cur_buffer, ' ', 1); + if (!what || (stricmp(what, "SET") == 0)) { + do_enforce_set(c); + } else if (stricmp(what, "MODES") == 0) { + do_enforce_modes(c); + } else if (stricmp(what, "SECUREOPS") == 0) { + do_enforce_secureops(c); + } else if (stricmp(what, "RESTRICTED") == 0) { + do_enforce_restricted(c); + } else if (stricmp(what, "+R") == 0) { + do_enforce_cmode_R(c); + } else { + moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX); + } + } + + free(chan); + free(what); + + return MOD_CONT; +} + +/* Language and response stuff */ +void my_cs_help(User * u) +{ + moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP); +} + +int my_cs_help_enforce(User * u) +{ + moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX); + notice(s_ChanServ, u->nick, " "); + moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE); + notice(s_ChanServ, u->nick, " "); + if (cbmodes['R'].flag != 0) + moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE_R_ENABLED); + else + moduleNoticeLang(s_ChanServ, u, LNG_CHAN_HELP_ENFORCE_R_DISABLED); + + return MOD_STOP; +} + +void my_add_languages(void) +{ + /* English (US) */ + char *langtable_en_us[] = { + /* LNG_CHAN_HELP */ + " ENFORCE Enforce various channel modes and set options", + /* LNG_ENFORCE_SYNTAX */ + "Syntax: \002ENFORCE \037channel\037 [\037what\037]\002", + /* LNG_CHAN_HELP_ENFORCE */ + "Enforce various channel modes and set options. The \037channel\037\n" + "option indicates what channel to enforce the modes and options\n" + "on. The \037what\037 option indicates what modes and options to\n" + "enforce, and can be any of SET, SECUREOPS, RESTRICTED, MODES,\n" + "or +R. When left out, it defaults to SET.\n" + " \n" + "If \037what\037 is SET, it will enforce SECUREOPS and RESTRICTED\n" + "on the users currently in the channel, if they are set. Give\n" + "SECUREOPS to enforce the SECUREOPS option, even if it is not\n" + "enabled. Use RESTRICTED to enfore the RESTRICTED option, also\n" + "if it's not enabled.", + /* LNG_CHAN_HELP_ENFORCE_R_ENABLED */ + "If \037what\037 is MODES, it will enforce channelmode +R if it is\n" + "set. If +R is specified for \037what\037, the +R channelmode will\n" + "also be enforced, but even if it is not set. If it is not set,\n" + "users will be banned to ensure they don't just rejoin.", + /* LNG_CHAN_HELP_ENFORCE_R_DISABLED */ + "If \037what\037 is MODES, nothing will be enforced, since it would\n" + "enforce modes that the current ircd does not support. If +R is\n" + "specified for \037what\037, an equalivant of channelmode +R on\n" + "other ircds will be enforced. All users that are in the channel\n" + "but have not identified for their nickname will be kicked and\n" + "banned from the channel." + }; + + /* Dutch */ + char *langtable_nl[] = { + /* LNG_CHAN_HELP */ + " ENFORCE Forceer enkele kanaalmodes en set-opties", + /* LNG_ENFORCE_SYNTAX */ + "Syntax: \002ENFORCE \037kanaal\037 [\037wat\037]\002", + /* LNG_CHAN_HELP_ENFORCE */ + "Forceer enkele kannalmodes en set-opties. De \037kanaal\037 optie\n" + "geeft aan op welk kanaal de modes en opties geforceerd moeten\n" + "worden. De \037wat\037 optie geeft aan welke modes en opties\n" + "geforceerd moeten worden; dit kan SET, SECUREOPS, RESTRICTED,\n" + "MODES, of +R zijn. Indien weggelaten is dit standaard SET.\n" + " \n" + "Als er voor \037wat\037 SET wordt ingevuld, zullen SECUREOPS en\n" + "RESTRICTED geforceerd worden op de gebruikers in het kanaal,\n" + "maar alleen als die opties aangezet zijn voor het kanaal. Als\n" + "SECUREOPS of RESTRICTED wordt gegeven voor \037wat\037 zal die optie\n" + "altijd geforceerd worden, ook als die niet is aangezet.", + /* LNG_CHAN_HELP_ENFORCE_R_ENABLED */ + "Als er voor \037wat\037 MODES wordt ingevuld, zal kanaalmode +R worden\n" + "geforceerd, als die op het kanaal aan staat. Als +R wordt ingevuld,\n" + "zal kanaalmode +R worden geforceerd, maar ook als die niet aan" + "staat voor het kanaal. Als +R niet aan staat, zullen alle ook\n" + "gebanned worden om te zorgen dat ze niet opnieuw het kanaal binnen\n" + "kunnen komen.", + /* LNG_CHAN_HELP_ENFORCE_R_DISABLED */ + "Als er voor \037wat\037 MODES wordt ingevuld, zal er niks gebeuren.\n" + "Normaal gesproken wordt er een kanaalmode geforceerd die op deze\n" + "server niet ondersteund wordt. Als +R wordt ingevuld voor \037wat\037\n" + "zullen alle gebruikers die in het kanaal zitten maar zich niet\n" + "hebben geidentificeerd voor hun nick uit het kanaal gekicked en\n" + "verbannen worden." + }; + + moduleInsertLanguage(LANG_EN_US, LNG_NUM_STRINGS, langtable_en_us); + moduleInsertLanguage(LANG_NL, LNG_NUM_STRINGS, langtable_nl); +} + +/* EOF */ diff --git a/src/modules/cs_tban.c b/src/modules/cs_tban.c new file mode 100644 index 000000000..9f56211b9 --- /dev/null +++ b/src/modules/cs_tban.c @@ -0,0 +1,171 @@ +#include "module.h" + +#define AUTHOR "Rob" +#define VERSION "1" + +void myHelp(User *u); +void myFullHelpSyntax(User *u); +int myFullHelp(User *u); +void mySendResponse(User *u, char *channel, char *mask, char *time); + +int do_tban(User *u); +void addBan(Channel *c, time_t timeout, char *banmask); +int delBan(int argc, char **argv); +int canBanUser(Channel *c, User *u, User *u2); + +void mAddLanguages(void); + +#define LANG_NUM_STRINGS 4 +#define TBAN_HELP 0 +#define TBAN_SYNTAX 1 +#define TBAN_HELP_DETAIL 2 +#define TBAN_RESPONSE 3 + +int AnopeInit(int argc, char **argv) { + Command *c; + int status = 0; + + moduleSetChanHelp(myHelp); + c = createCommand("TBAN", do_tban, NULL, -1,-1,-1,-1,-1); + moduleAddHelp(c,myFullHelp); + status = moduleAddCommand(CHANSERV, c, MOD_HEAD); + + mAddLanguages(); + + if(status!=MOD_ERR_OK) { + return MOD_STOP; + } + return MOD_CONT; +} + +void AnopeFini(void) +{ + /* module is unloading */ +} + +void myHelp(User *u) { + moduleNoticeLang(s_ChanServ, u,TBAN_HELP); +} + +void myFullHelpSyntax(User *u) { + moduleNoticeLang(s_ChanServ, u,TBAN_SYNTAX); +} + +int myFullHelp(User *u) { + myFullHelpSyntax(u); + notice(s_ChanServ,u->nick,""); + moduleNoticeLang(s_ChanServ, u,TBAN_HELP_DETAIL); + return MOD_CONT; +} + +void mySendResponse(User *u, char *channel, char *mask, char *time) { + moduleNoticeLang(s_ChanServ, u,TBAN_RESPONSE,mask,channel,time); +} + +int do_tban(User *u) { + char mask[BUFSIZE]; + Channel *c; + User *u2=NULL; + + char *buffer = moduleGetLastBuffer(); + char *chan; + char *nick; + char *time; + + chan = myStrGetToken(buffer, ' ', 0); + nick = myStrGetToken(buffer,' ',1); + time = myStrGetToken(buffer,' ',2); + + if(time && chan && nick) { + + if (!(c = findchan(chan))) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan); + } else if (!(u2 = finduser(nick))) { + notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick); + } else { + if(canBanUser(c,u,u2)) { + get_idealban(c->ci, u2, mask, sizeof(mask)); + addBan(c,dotime(time),mask); + mySendResponse(u,chan,mask,time); + } + } + } else { + myFullHelpSyntax(u); + } + if(time) free(time); + if(nick) free(nick); + if(chan) free(chan); + + return MOD_CONT; +} + +void addBan(Channel *c, time_t timeout, char *banmask) { + char *av[3]; + char *cb[2]; + + cb[0] = c->name; + cb[1] = banmask; + + av[0] = sstrdup("+b"); + av[1] = banmask; + + anope_cmd_mode(whosends(c->ci), c->name, "+b %s", av[1]); + chan_set_modes(s_ChanServ, c, 2, av, 1); + + free(av[0]); + moduleAddCallback("tban",time(NULL)+timeout,delBan,2,cb); +} + +int delBan(int argc, char **argv) { + char *av[3]; + Channel *c; + + av[0] = sstrdup("-b"); + av[1] = argv[1]; + + if((c=findchan(argv[0])) && c->ci ) { + anope_cmd_mode(whosends(c->ci), c->name, "-b %s", av[1]); + chan_set_modes(s_ChanServ, c, 2, av, 1); + } + + free(av[0]); + + return MOD_CONT; +} + +int canBanUser(Channel *c, User *u, User *u2) { + ChannelInfo *ci; + int ok = 0; + if (!(ci = c->ci)) { + notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, c->name); + } else if (!check_access(u, ci, CA_BAN)) { + notice_lang(s_ChanServ, u, ACCESS_DENIED); + } else if (ircd->except && is_excepted(ci, u2)) { + notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name); + } else if (ircd->protectedumode && is_protected(u2)) { + notice_lang(s_ChanServ, u, PERMISSION_DENIED); + } else { + ok = 1; + } + + return ok; +} + + +void mAddLanguages(void) { + char *langtable_en_us[] = { + " TBAN Bans the user for a given length of time", + "Syntax: TBAN channel nick time", + "Bans the given user from a channel\n" + "for a specified length of time.\n" + "If the ban is removed before hand, it will\n" + "NOT be replaced.", + "%s banned from %s, will auto-expire in %s" + }; + moduleInsertLanguage(LANG_EN_US, LANG_NUM_STRINGS, langtable_en_us); +} + + +/* EOF */ diff --git a/src/modules/demos/catserv/Makefile b/src/modules/demos/catserv/Makefile new file mode 100644 index 000000000..5b2f4efa3 --- /dev/null +++ b/src/modules/demos/catserv/Makefile @@ -0,0 +1,9 @@ +SRCS= ircd_catserv.c \ + catserv_messages.c \ + meow.c \ + purr.c + +TARGET=ircd_catserv + +include ../Makefile.sub + diff --git a/src/modules/demos/catserv/README b/src/modules/demos/catserv/README new file mode 100644 index 000000000..c3d3f7084 --- /dev/null +++ b/src/modules/demos/catserv/README @@ -0,0 +1,4 @@ +This is an EXAMPLE module, it serves no real purpose. + +This module was broken down into multiple files to demonstrate how multiple files can be used. + diff --git a/src/modules/demos/catserv/catserv_extern.h b/src/modules/demos/catserv/catserv_extern.h new file mode 100644 index 000000000..02c21addb --- /dev/null +++ b/src/modules/demos/catserv/catserv_extern.h @@ -0,0 +1,11 @@ +#ifndef CATSERV_DEFS_H +#define CATSERV_DEFS_H + +#ifdef _WIN32 +extern __declspec(dllexport) char *s_CatServ; +#else +E char *s_CatServ; +#endif + +#endif + diff --git a/src/modules/demos/catserv/catserv_messages.c b/src/modules/demos/catserv/catserv_messages.c new file mode 100644 index 000000000..e11235b4e --- /dev/null +++ b/src/modules/demos/catserv/catserv_messages.c @@ -0,0 +1,14 @@ +#include "catserv_messages.h" +#include "module.h" +#include "meow.h" +#include "purr.h" + +void addMessageList(void) +{ + Command *c; + c = createCommand("meow", do_meow, NULL, -1, -1, -1, -1, -1); + moduleAddCommand(Catserv_cmdTable, c, MOD_UNIQUE); + c = createCommand("purr", do_purr, NULL, -1, -1, -1, -1, -1); + moduleAddCommand(Catserv_cmdTable, c, MOD_UNIQUE); +} + diff --git a/src/modules/demos/catserv/catserv_messages.h b/src/modules/demos/catserv/catserv_messages.h new file mode 100644 index 000000000..bb3f82dd0 --- /dev/null +++ b/src/modules/demos/catserv/catserv_messages.h @@ -0,0 +1,10 @@ +#ifndef CATSERV_MESSAGES_H +#define CATSERV_MESSAGES_H + +#include "module.h" + +CommandHash *Catserv_cmdTable[MAX_CMD_HASH]; +void addMessageList(void); + +#endif + diff --git a/src/modules/demos/catserv/ircd_catserv.c b/src/modules/demos/catserv/ircd_catserv.c new file mode 100644 index 000000000..ae34d6161 --- /dev/null +++ b/src/modules/demos/catserv/ircd_catserv.c @@ -0,0 +1,112 @@ +/** + * Simple module to load up a client called CatServ and process commands for it + * This module is an example, and has no useful purpose! + * + * Please visit http://modules.anope.org for useful modules! + * + **/ + +#include "module.h" +#include "catserv_messages.h" + +#define AUTHOR "Anope" +#define VERSION "$Id$" + +int my_privmsg(char *source, int ac, char **av); + +void addClient(char *nick, char *realname); +void delClient(void); +void catserv(User * u, char *buf); + +char *s_CatServ = "CatServ"; + +int AnopeInit(int argc, char **argv) +{ + Message *msg = NULL; + int status; +#ifdef IRC_UNREAL32 + if (UseTokens) { + msg = createMessage("!", my_privmsg); + } else { + msg = createMessage("PRIVMSG", my_privmsg); + } +#else + msg = createMessage("PRIVMSG", my_privmsg); +#endif + status = moduleAddMessage(msg, MOD_HEAD); + if (status == MOD_ERR_OK) { + addClient(s_CatServ, "meow!"); + addMessageList(); + } + moduleAddAuthor(AUTHOR); + moduleAddVersion(VERSION); + alog("ircd_catserv.so: loaded, message status [%d]", status); + return MOD_CONT; +} + +void AnopeFini(void) +{ + delClient(); +} + +int my_privmsg(char *source, int ac, char **av) +{ + User *u; + char *s; + + /* First, some basic checks */ + if (ac != 2) + return MOD_CONT; /* bleh */ + if (!(u = finduser(source))) { + return MOD_CONT; + } /* non-user source */ + if (*av[0] == '#') { + return MOD_CONT; + } + /* Channel message */ + /* we should prolly honour the ignore list here, but i cba for this... */ + s = strchr(av[0], '@'); + if (s) { + *s++ = 0; + if (stricmp(s, ServerName) != 0) + return MOD_CONT; + } + if ((stricmp(av[0], s_CatServ)) == 0) { /* its for US! */ + catserv(u, av[1]); + return MOD_STOP; + } else { /* ok it isnt us, let the old code have it */ + return MOD_CONT; + } +} + +void addClient(char *nick, char *realname) +{ + anope_cmd_bot_nick(nick, "catserv", "meow.meow.land", realname, "+"); +} + +void delClient(void) +{ + anope_cmd_quit(s_CatServ, "QUIT :Module Unloaded!"); +} + +/*****************************************************************************/ +/* Main CatServ routine. */ +void catserv(User * u, char *buf) +{ + char *cmd, *s; + + cmd = strtok(buf, " "); + + if (!cmd) { + return; + } else if (stricmp(cmd, "\1PING") == 0) { + if (!(s = strtok(NULL, ""))) + s = "\1"; + notice(s_CatServ, u->nick, "\1PING %s", s); + } else if (skeleton) { + notice_lang(s_CatServ, u, SERVICE_OFFLINE, s_CatServ); + } else { + mod_run_cmd(s_CatServ, u, Catserv_cmdTable, cmd); + } +} + diff --git a/src/modules/demos/catserv/makefile.win32 b/src/modules/demos/catserv/makefile.win32 new file mode 100644 index 000000000..638704440 --- /dev/null +++ b/src/modules/demos/catserv/makefile.win32 @@ -0,0 +1,4 @@ +SRCS=ircd_catserv.c purr.c catserv_messages.c meow.c +TARGET=ircd_catserv.dll + +include ..\Makefile.sub.win32 diff --git a/src/modules/demos/catserv/meow.c b/src/modules/demos/catserv/meow.c new file mode 100644 index 000000000..9279eec0b --- /dev/null +++ b/src/modules/demos/catserv/meow.c @@ -0,0 +1,9 @@ +#include "meow.h" + +#include "catserv_extern.h" + +int do_meow(User * u) { + notice(s_CatServ, u->nick, "MEOW!"); + return MOD_STOP; +} + diff --git a/src/modules/demos/catserv/meow.h b/src/modules/demos/catserv/meow.h new file mode 100644 index 000000000..0f28673a0 --- /dev/null +++ b/src/modules/demos/catserv/meow.h @@ -0,0 +1,9 @@ +#ifndef CATSERV_MEOW_H +#define CATSERV_MEOW_H + +#include "module.h" + +int do_meow(User * u); + +#endif + diff --git a/src/modules/demos/catserv/purr.c b/src/modules/demos/catserv/purr.c new file mode 100644 index 000000000..5a39dc26e --- /dev/null +++ b/src/modules/demos/catserv/purr.c @@ -0,0 +1,8 @@ +#include "purr.h" +#include "catserv_extern.h" + +int do_purr(User * u) +{ + notice(s_CatServ, u->nick, "PURR!"); + return MOD_STOP; +} diff --git a/src/modules/demos/catserv/purr.h b/src/modules/demos/catserv/purr.h new file mode 100644 index 000000000..a92e421f6 --- /dev/null +++ b/src/modules/demos/catserv/purr.h @@ -0,0 +1,9 @@ +#ifndef CATSERV_PURR_H +#define CATSERV_PURR_H + +#include "module.h" + +int do_purr(User * u); + +#endif + diff --git a/src/modules/demos/events.c b/src/modules/demos/events.c new file mode 100644 index 000000000..c61d62985 --- /dev/null +++ b/src/modules/demos/events.c @@ -0,0 +1,82 @@ +/** + * Simple module to show the usage of event messages and hooks + * This module is an example, and has no useful purpose! + * + * Please visit http://modules.anope.org for useful modules! + * + **/ + +#include "module.h" + +#define AUTHOR "Anope" +#define VERSION "$Id$" + +int my_nick(char *source, int ac, char **av); +int my_save(int argc, char **argv); +int do_moo(int argc, char **argv); + +int AnopeInit(int argc, char **argv) +{ + EvtMessage *msg = NULL; + EvtHook *hook = NULL; + int status; + msg = createEventHandler("NICK", my_nick); + status = moduleAddEventHandler(msg); + + hook = createEventHook(EVENT_DB_SAVING, my_save); + status = moduleAddEventHook(hook); + + + hook = createEventHook(EVENT_BOT_FANTASY, do_moo); + status = moduleAddEventHook(hook); + + moduleAddAuthor(AUTHOR); + moduleAddVersion(VERSION); + return MOD_CONT; +} + +void AnopeFini(void) +{ + /* unloading */ +} + +int my_nick(char *source, int ac, char **av) +{ + alog("Internal Event - nick is %s",av[0]); + return MOD_CONT; +} + +int my_save(int argc, char **argv) +{ + if(argc>=1) { + if (!stricmp(argv[0], EVENT_START)) { + alog("Saving the databases! has started"); + } else { + alog("Saving the databases is complete"); + } + } + return MOD_CONT; +} + +/** + * command to be called when a EVENT_BOT_FANTASY event is recived. + * @param argc The paramater count for this event. + * @param argv[0] The cmd used. + * @param argv[1] The nick of the command user. + * @param argv[2] The channel name the command was used in. + * @param argv[3] The rest of the text after the command. + * @return MOD_CONT or MOD_STOP + **/ +int do_moo(int argc, char **argv) { + ChannelInfo *ci; + if(argc>=3) { /* We need at least 3 arguments */ + if(stricmp(argv[0],"!moo")==0) { /* is it meant for us? */ + if((ci = cs_findchan(argv[2]))) { /* channel should always exist */ + anope_cmd_privmsg(ci->bi->nick, ci->name, "%cACTION moo's at %s %c",1,argv[1],1); + return MOD_STOP; /* We've dealt with it, dont let others */ + } + } + } + return MOD_CONT; /* guess it wasnt for us, pass it on */ +} + diff --git a/src/modules/demos/hs_conf.c b/src/modules/demos/hs_conf.c new file mode 100644 index 000000000..45b4bb330 --- /dev/null +++ b/src/modules/demos/hs_conf.c @@ -0,0 +1,74 @@ +#include "module.h" + +#define AUTHOR "Anope" +#define VERSION "1" + +/** + * Default setting to be used if no confing value is found + **/ +#define DEFAULT_SETTING "moo" + +int mShowSetting(User *u); +int mReadConfig(int argc, char **argv); + +char *setting; + +int AnopeInit(int argc, char **argv) { + Command *c; + EvtHook *hook; + int status = 0; + + setting = NULL; + + mReadConfig(0,NULL); + + c = createCommand("SHOW",mShowSetting,NULL,-1,-1,-1,-1,-1); + status = moduleAddCommand(HOSTSERV, c, MOD_HEAD); + + hook = createEventHook(EVENT_RELOAD, mReadConfig); + status = moduleAddEventHook(hook); + + if(status!=MOD_ERR_OK) { + return MOD_STOP; + } + return MOD_CONT; +} + +/** + * free the globals when we close + **/ +void AnopeFini(void) { + if(setting) + free(setting); +} + +/** + * Simple function to show the user the current config setting + **/ +int mShowSetting(User *u) { + notice(s_HostServ,u->nick,"Setting in use is [%s]",setting); + return MOD_CONT; +} + +/** + * Load the config setting up, this will be called whenever + * the EVENT_RELOAD event is recived. + **/ +int mReadConfig(int argc, char **argv) { + char *tmp=NULL; + Directive d[] = {{"HSConfigSetting", {{PARAM_STRING, PARAM_RELOAD, &tmp}}}}; + moduleGetConfigDirective(d); + + if(setting) { + free(setting); + } + if(tmp) { + setting = tmp; + } else { + setting = sstrdup(DEFAULT_SETTING); + } + return MOD_CONT; +} + + +/* EOF */ diff --git a/src/modules/demos/hs_moo.c b/src/modules/demos/hs_moo.c new file mode 100644 index 000000000..b65e83bb6 --- /dev/null +++ b/src/modules/demos/hs_moo.c @@ -0,0 +1,119 @@ +/** + * This is an EXAMPLE module, which adds the "moo" command to HostServ + * + * This command does NOT do anything useful at all! + * + * Please visit http://modules.anope.org for useful modules! + * + **/ +#include "module.h" + +#define AUTHOR "Anope" /* Set the Author for a modinfo reply */ +#define VERSION "$Id$" /* Set the version for a modinfo reply */ + +int hs_moo_show(User * u); /* Function to use when a /hs moo command is recived */ +int test(int argc, char **argv); +void myHostServHelp(User *u); /* Function to display out help in a /hs help response */ +int myHostServMooHelp(User *u); /* Function to display help to _everyone_ when a /hs help moo is called*/ +int myHostServMooRegHelp(User *u); /* Function to display extra help to regular-users when a /hs help moo is called*/ +int myHostServMooOperHelp(User *u); /* Function to display extra help to opers when a /hs help moo is called*/ +int myHostServMooAdminHelp(User *u); /* Function to display extra help to admins when a /hs help moo is called*/ +int myHostServMooRootHelp(User *u); /* Function to display extra help to roors when a /hs help moo is called*/ + +int AnopeInit(int argc, char **argv) /* This will be executed when the module is loaded */ +{ + Command *c; /* Pointer to a Command */ + int status = 0; /* the status of our new command */ + c = createCommand("moo", hs_moo_show, NULL, -1, -1, -1, -1, -1); /* Create a new command "moo" pointing to hs_moo */ + + moduleAddHelp(c,myHostServMooHelp); /* add help for all users to this command */ + moduleAddRegHelp(c,myHostServMooRegHelp); /* add extra regular-user only help to this command */ + moduleAddOperHelp(c,myHostServMooOperHelp); /* add extra oper only help to this command */ + moduleAddAdminHelp(c,myHostServMooAdminHelp); /* add extra admin only help to this command */ + moduleAddRootHelp(c,myHostServMooRootHelp); /* add extra root only help to this command */ + + moduleSetHostHelp(myHostServHelp); /* add us to the .hs help list */ + + status = moduleAddCommand(HOSTSERV, c, MOD_HEAD); /* Add the command to the HOSTSERV cmd table */ + + /* Check if we have any argv's */ + if(argc>0) { + /* we do, the first will be the nick of the person modload'ing us */ + /* or NULL if we were auto-loaded */ + if(argv[0]) { + alog("hs_moo was modloaded by: [%s]",argv[0]); + } else { + alog("hs_moo was automatically loaded by anope"); + } + } + alog("hs_moo.so: Add Command 'moo' Status: %d",status); /* Log the command being added */ + + moduleAddCallback("test",time(NULL)+dotime("15s"),test,0,NULL); /* set a call-back function to exec in 3 mins time */ + moduleDelCallback("test"); + moduleAddAuthor(AUTHOR); /* tell Anope about the author */ + moduleAddVersion(VERSION); /* Tell Anope about the verison */ + + if(status!=MOD_ERR_OK) { + return MOD_STOP; + } + return MOD_CONT; +} + +int hs_moo_show(User * u) +{ + notice(s_HostServ, u->nick, "MOO! - This command was loaded via a module!"); /* Just notice the user */ + return MOD_STOP; /* MOD_STOP means we will NOT pass control back to other */ +} /* modules waiting to handle the /hs moo command! */ + +int test(int argc, char **argv) { + alog("CallBack from hs_moo with %d paramaters",argc); + return MOD_CONT; +} + +void AnopeFini(void) +{ + /* module is unloading */ +} + +/***************************************************************************************************************************************/ +/* The code below here shows various ways of dealing with the module help system */ +/***************************************************************************************************************************************/ + +void myHostServHelp(User *u) { + notice(s_HostServ,u->nick, " MOO Moo's at the user!"); /* this will appear in the help list */ +} + +int myHostServMooHelp(User *u) { + notice(s_HostServ,u->nick,"Syntax: Moo"); /* this will be sent to everyone who does /msg hostserv help moo */ + notice(s_HostServ,u->nick,"This command is an example provided"); + notice(s_HostServ,u->nick,"by the Anope development team."); + return MOD_CONT; /* allow any other module's with help for /hs moo to run */ +} + +int myHostServMooRootHelp(User *u) { /* this will only be sent to ROOTS ONLY who /msg hostserv moo */ + myHostServMooAdminHelp(u); /* this line lets us show roots the ADMIN help as well as the root help */ + notice(s_HostServ,u->nick,"Only roots will see this part of the help"); + return MOD_CONT; +} + +int myHostServMooAdminHelp(User *u) { /* this will only be sent to ADMINS ONLY who /msg hostserv moo */ + myHostServMooOperHelp(u); /* this line lets us show admins the OPER help as well as the admin help */ + notice(s_HostServ,u->nick,"Only admins will see this part of the help"); + notice(s_HostServ,u->nick,"why not visit us on www.anope.org ?"); + return MOD_CONT; +} + +int myHostServMooOperHelp(User *u) { /* this will only be sent to OPERS ONLY who /msg hostserv moo */ + notice(s_HostServ,u->nick,"Only opers will see this part of the help"); + notice(s_HostServ,u->nick,"for more help/support with modules"); + notice(s_HostServ,u->nick,"visit us on irc.anope.org #anope! :)"); + return MOD_CONT; +} + +int myHostServMooRegHelp(User *u) { /* this will only be sent to REGULAR USERS ONLY who /msg hostserv moo */ + notice(s_HostServ,u->nick,"Only non-opers will see this part of the help"); + notice(s_HostServ,u->nick,"as we've left it hidden from opers"); + return MOD_CONT; +} + +/* EOF */ diff --git a/src/modules/events.c b/src/modules/events.c deleted file mode 100644 index af53a3d40..000000000 --- a/src/modules/events.c +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Simple module to show the usage of event messages and hooks - * This module is an example, and has no useful purpose! - * - * Please visit http://modules.anope.org for useful modules! - * - **/ - -#include "module.h" - -#define AUTHOR "Anope" -#define VERSION "1.1" - -int my_nick(char *source, int ac, char **av); -int my_save(char *message); - -int AnopeInit(int argc, char **argv) -{ - EvtMessage *msg = NULL; - EvtHook *hook = NULL; - int status; - msg = createEventHandler("NICK", my_nick); - status = moduleAddEventHandler(msg); - - hook = createEventHook(EVENT_DB_SAVING, my_save); - status = moduleAddEventHook(hook); - - moduleAddAuthor(AUTHOR); - moduleAddVersion(VERSION); - return MOD_CONT; -} - -void AnopeFini(void) -{ - /* unloading */ -} - -int my_nick(char *source, int ac, char **av) -{ - alog("Internal Event - nick is %s",av[0]); - return MOD_CONT; -} - -int my_save(char *message) -{ - if (!stricmp(message, EVENT_START)) { - alog("Saving the databases! has started"); - } else { - alog("Saving the databases is complete"); - } - return MOD_CONT; -} - diff --git a/src/modules/hs_moo.c b/src/modules/hs_moo.c deleted file mode 100644 index 0c3070036..000000000 --- a/src/modules/hs_moo.c +++ /dev/null @@ -1,119 +0,0 @@ -/** - * This is an EXAMPLE module, which adds the "moo" command to HostServ - * - * This command does NOT do anything useful at all! - * - * Please visit http://modules.anope.org for useful modules! - * - **/ -#include "module.h" - -#define AUTHOR "Anope" /* Set the Author for a modinfo reply */ -#define VERSION "1.1" /* Set the version for a modinfo reply */ - -int hs_moo_show(User * u); /* Function to use when a /hs moo command is recived */ -int test(int argc, char **argv); -void myHostServHelp(User *u); /* Function to display out help in a /hs help response */ -int myHostServMooHelp(User *u); /* Function to display help to _everyone_ when a /hs help moo is called*/ -int myHostServMooRegHelp(User *u); /* Function to display extra help to regular-users when a /hs help moo is called*/ -int myHostServMooOperHelp(User *u); /* Function to display extra help to opers when a /hs help moo is called*/ -int myHostServMooAdminHelp(User *u); /* Function to display extra help to admins when a /hs help moo is called*/ -int myHostServMooRootHelp(User *u); /* Function to display extra help to roors when a /hs help moo is called*/ - -int AnopeInit(int argc, char **argv) /* This will be executed when the module is loaded */ -{ - Command *c; /* Pointer to a Command */ - int status = 0; /* the status of our new command */ - c = createCommand("moo", hs_moo_show, NULL, -1, -1, -1, -1, -1); /* Create a new command "moo" pointing to hs_moo */ - - moduleAddHelp(c,myHostServMooHelp); /* add help for all users to this command */ - moduleAddRegHelp(c,myHostServMooRegHelp); /* add extra regular-user only help to this command */ - moduleAddOperHelp(c,myHostServMooOperHelp); /* add extra oper only help to this command */ - moduleAddAdminHelp(c,myHostServMooAdminHelp); /* add extra admin only help to this command */ - moduleAddRootHelp(c,myHostServMooRootHelp); /* add extra root only help to this command */ - - moduleSetHostHelp(myHostServHelp); /* add us to the .hs help list */ - - status = moduleAddCommand(HOSTSERV, c, MOD_HEAD); /* Add the command to the HOSTSERV cmd table */ - - /* Check if we have any argv's */ - if(argc>0) { - /* we do, the first will be the nick of the person modload'ing us */ - /* or NULL if we were auto-loaded */ - if(argv[0]) { - alog("hs_moo was modloaded by: [%s]",argv[0]); - } else { - alog("hs_moo was automatically loaded by anope"); - } - } - alog("hs_moo.so: Add Command 'moo' Status: %d",status); /* Log the command being added */ - - moduleAddCallback("test",time(NULL)+dotime("15s"),test,0,NULL); /* set a call-back function to exec in 3 mins time */ - moduleDelCallback("test"); - moduleAddAuthor(AUTHOR); /* tell Anope about the author */ - moduleAddVersion(VERSION); /* Tell Anope about the verison */ - - if(status!=MOD_ERR_OK) { - return MOD_STOP; - } - return MOD_CONT; -} - -int hs_moo_show(User * u) -{ - notice(s_HostServ, u->nick, "MOO! - This command was loaded via a module!"); /* Just notice the user */ - return MOD_STOP; /* MOD_STOP means we will NOT pass control back to other */ -} /* modules waiting to handle the /hs moo command! */ - -int test(int argc, char **argv) { - alog("CallBack from hs_moo with %d paramaters",argc); - return MOD_CONT; -} - -void AnopeFini(void) -{ - /* module is unloading */ -} - -/***************************************************************************************************************************************/ -/* The code below here shows various ways of dealing with the module help system */ -/***************************************************************************************************************************************/ - -void myHostServHelp(User *u) { - notice(s_HostServ,u->nick, " MOO Moo's at the user!"); /* this will appear in the help list */ -} - -int myHostServMooHelp(User *u) { - notice(s_HostServ,u->nick,"Syntax: Moo"); /* this will be sent to everyone who does /msg hostserv help moo */ - notice(s_HostServ,u->nick,"This command is an example provided"); - notice(s_HostServ,u->nick,"by the Anope development team."); - return MOD_CONT; /* allow any other module's with help for /hs moo to run */ -} - -int myHostServMooRootHelp(User *u) { /* this will only be sent to ROOTS ONLY who /msg hostserv moo */ - myHostServMooAdminHelp(u); /* this line lets us show roots the ADMIN help as well as the root help */ - notice(s_HostServ,u->nick,"Only roots will see this part of the help"); - return MOD_CONT; -} - -int myHostServMooAdminHelp(User *u) { /* this will only be sent to ADMINS ONLY who /msg hostserv moo */ - myHostServMooOperHelp(u); /* this line lets us show admins the OPER help as well as the admin help */ - notice(s_HostServ,u->nick,"Only admins will see this part of the help"); - notice(s_HostServ,u->nick,"why not visit us on www.anope.org ?"); - return MOD_CONT; -} - -int myHostServMooOperHelp(User *u) { /* this will only be sent to OPERS ONLY who /msg hostserv moo */ - notice(s_HostServ,u->nick,"Only opers will see this part of the help"); - notice(s_HostServ,u->nick,"for more help/support with modules"); - notice(s_HostServ,u->nick,"visit us on irc.anope.org #anope! :)"); - return MOD_CONT; -} - -int myHostServMooRegHelp(User *u) { /* this will only be sent to REGULAR USERS ONLY who /msg hostserv moo */ - notice(s_HostServ,u->nick,"Only non-opers will see this part of the help"); - notice(s_HostServ,u->nick,"as we've left it hidden from opers"); - return MOD_CONT; -} - -/* EOF */ diff --git a/src/modules/makefile.inc.win32 b/src/modules/makefile.inc.win32 index f069be350..9b933f4a5 100644 --- a/src/modules/makefile.inc.win32 +++ b/src/modules/makefile.inc.win32 @@ -1,2 +1,2 @@ -SRCS=hs_moo.c events.c -SUBS=catserv +SRCS=cs_appendtopic.c cs_enforce.c cs_tban.c ns_maxemail.c ns_noop.c os_info.c +SUBS=test diff --git a/src/modules/makefile.win32 b/src/modules/makefile.win32 index f7a827ec8..61a3e250a 100644 --- a/src/modules/makefile.win32 +++ b/src/modules/makefile.win32 @@ -12,7 +12,6 @@ distclean: clean spotless .c.dll: $(CC) $(CFLAGS) $(IRCTYPE) $< $(LFLAGS) - subs: @for %i in ( $(SUBS) ); do \ @if exist %i; @cd %i && $(MAKE) $(MAKEARGS) && cd .. diff --git a/src/modules/module.h b/src/modules/module.h deleted file mode 100644 index 3f341c0aa..000000000 --- a/src/modules/module.h +++ /dev/null @@ -1,10 +0,0 @@ -#include "services.h" -#include "commands.h" -#include "language.h" -#include "modules.h" -#include "depricated.h" - -#define MOD_UNIQUE 0 -#define MOD_HEAD 1 -#define MOD_TAIL 2 - diff --git a/src/modules/ns_maxemail.c b/src/modules/ns_maxemail.c new file mode 100644 index 000000000..ac51d3d5c --- /dev/null +++ b/src/modules/ns_maxemail.c @@ -0,0 +1,190 @@ +/* ns_maxemail.c - Limit the amount of times an email address + * can be used for a NickServ account. + * + * (C) 2003-2005 Anope Team + * Contact us at info@anope.org + * + * Included in the Anope module pack since Anope 1.7.9 + * Anope Coder: GeniusDex + * + * Please read COPYING and README for further details. + * + * Send any bug reports to the Anope Coder, as he will be able + * to deal with it best. + */ + +#include "module.h" + +#define AUTHOR "Anope" +#define VERSION "$Id$" + +void my_load_config(void); +void my_add_languages(void); +int my_ns_register(User * u); +int my_ns_set(User * u); +int my_event_reload(int argc, char **argv); + +int NSEmailMax = 0; + +#define LNG_NUM_STRINGS 2 +#define LNG_NSEMAILMAX_REACHED 0 +#define LNG_NSEMAILMAX_REACHED_ONE 1 + +int AnopeInit(int argc, char **argv) +{ + Command *c; + EvtHook *evt; + int status; + + moduleAddAuthor(AUTHOR); + moduleAddVersion(VERSION); + moduleSetType(SUPPORTED); + + c = createCommand("REGISTER", my_ns_register, NULL, -1, -1, -1, -1, + -1); + if ((status = moduleAddCommand(NICKSERV, c, MOD_HEAD))) { + alog("[ns_maxemail] Unable to create REGISTER command: %d", + status); + return MOD_STOP; + } + + c = createCommand("SET", my_ns_set, NULL, -1, -1, -1, -1, -1); + if ((status = moduleAddCommand(NICKSERV, c, MOD_HEAD))) { + alog("[ns_maxemail] Unable to create SET command: %d", status); + return MOD_STOP; + } + + evt = createEventHook(EVENT_RELOAD, my_event_reload); + if ((status = moduleAddEventHook(evt))) { + alog("[ns_maxemail] Unable to hook to EVENT_RELOAD: %d", status); + return MOD_STOP; + } + + my_load_config(); + my_add_languages(); + + return MOD_CONT; +} + +void AnopeFini(void) +{ + /* Nothing to do while unloading */ +} + +int count_email_in_use(char *email, User * u) +{ + NickCore *nc; + int i; + int count = 0; + + if (!email) + return 0; + + for (i = 0; i < 1024; i++) { + for (nc = nclists[i]; nc; nc = nc->next) { + if (!(u->na && u->na->nc && u->na->nc == nc) + && (stricmp(nc->email, email) == 0)) + count++; + } + } + + return count; +} + +int check_email_limit_reached(char *email, User * u) +{ + if ((NSEmailMax < 1) || !email || is_services_admin(u)) + return MOD_CONT; + + if (count_email_in_use(email, u) < NSEmailMax) + return MOD_CONT; + + if (NSEmailMax == 1) + moduleNoticeLang(s_NickServ, u, LNG_NSEMAILMAX_REACHED_ONE); + else + moduleNoticeLang(s_NickServ, u, LNG_NSEMAILMAX_REACHED, + NSEmailMax); + + return MOD_STOP; +} + +int my_ns_register(User * u) +{ + char *cur_buffer; + char *email; + int ret; + + cur_buffer = moduleGetLastBuffer(); + email = myStrGetToken(cur_buffer, ' ', 1); + + ret = check_email_limit_reached(email, u); + free(email); + + return ret; +} + +int my_ns_set(User * u) +{ + char *cur_buffer; + char *set; + char *email; + int ret; + + cur_buffer = moduleGetLastBuffer(); + set = myStrGetToken(cur_buffer, ' ', 0); + + if (stricmp(set, "email") != 0) { + free(set); + return MOD_CONT; + } + + free(set); + email = myStrGetToken(cur_buffer, ' ', 1); + + ret = check_email_limit_reached(email, u); + free(email); + + return ret; +} + +int my_event_reload(int argc, char **argv) +{ + if ((argc > 0) && (stricmp(argv[0], EVENT_START) == 0)) + my_load_config(); + + return MOD_CONT; +} + +void my_load_config(void) +{ + Directive confvalues[] = { + {"NSEmailMax", {{PARAM_INT, PARAM_RELOAD, &NSEmailMax}}} + }; + + moduleGetConfigDirective(confvalues); + + if (debug) + alog("debug: [ns_maxemail] NSEmailMax set to %d", NSEmailMax); +} + +void my_add_languages(void) +{ + char *langtable_en_us[] = { + /* LNG_NSEMAILMAX_REACHED */ + "The given email address has reached it's usage limit of %d users.", + /* LNG_NSEMAILMAX_REACHED_ONE */ + "The given email address has reached it's usage limit of 1 user." + }; + + char *langtable_nl[] = { + /* LNG_NSEMAILMAX_REACHED */ + "Het gegeven email adres heeft de limiet van %d gebruikers bereikt.", + /* LNG_NSEMAILMAX_REACHED_ONE */ + "Het gegeven email adres heeft de limiet van 1 gebruiker bereikt." + }; + + moduleInsertLanguage(LANG_EN_US, LNG_NUM_STRINGS, langtable_en_us); + moduleInsertLanguage(LANG_NL, LNG_NUM_STRINGS, langtable_nl); +} + +/* EOF */ diff --git a/src/modules/ns_noop.c b/src/modules/ns_noop.c new file mode 100644 index 000000000..14662596b --- /dev/null +++ b/src/modules/ns_noop.c @@ -0,0 +1,483 @@ +/* ns_noop.c - Allows users to optionaly set autoop to off + * + * (C) 2003-2005 Anope Team + * Contact us at info@anope.org + * + * Based on the original module by Rob + * Included in the Anope module pack since Anope 1.7.9 + * Anope Coder: DrStein + * + * Please read COPYING and README for further details. + * + * Send bug reports to the Anope Coder instead of the module + * author, because any changes since the inclusion into anope + * are not supported by the original author. + * + */ +/*************************************************************************/ + +#include "module.h" + +#define AUTHOR "Rob" +#defin