summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorsjaz <sjaz@5417fbe8-f217-4b02-8779-1006273d7864>2009-01-01 12:00:20 +0000
committersjaz <sjaz@5417fbe8-f217-4b02-8779-1006273d7864>2009-01-01 12:00:20 +0000
commitc777c8d9aa7cd5c2e9a399727a7fa9985a77fb1c (patch)
tree9e996ae4a1bbb833cec036c5cd4d87a590149e85 /src/modules
Anope Stable Branch
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/stable@1902 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/Makefile48
-rw-r--r--src/modules/Makefile.sub28
-rw-r--r--src/modules/README1
-rw-r--r--src/modules/bs_fantasy_unban.c82
-rwxr-xr-xsrc/modules/configure58
-rw-r--r--src/modules/cs_appendtopic.c247
-rw-r--r--src/modules/cs_enforce.c479
-rw-r--r--src/modules/cs_tban.c253
-rw-r--r--src/modules/demos/catserv/Makefile9
-rw-r--r--src/modules/demos/catserv/README4
-rw-r--r--src/modules/demos/catserv/catserv_extern.h11
-rw-r--r--src/modules/demos/catserv/catserv_messages.c14
-rw-r--r--src/modules/demos/catserv/catserv_messages.h10
-rw-r--r--src/modules/demos/catserv/ircd_catserv.c112
-rw-r--r--src/modules/demos/catserv/makefile.win324
-rw-r--r--src/modules/demos/catserv/meow.c9
-rw-r--r--src/modules/demos/catserv/meow.h9
-rw-r--r--src/modules/demos/catserv/purr.c8
-rw-r--r--src/modules/demos/catserv/purr.h9
-rw-r--r--src/modules/demos/events.c82
-rw-r--r--src/modules/demos/hs_conf.c74
-rw-r--r--src/modules/demos/hs_moo.c119
-rw-r--r--src/modules/dummy/Makefile6
-rw-r--r--src/modules/hs_request.c986
-rw-r--r--src/modules/makefile.inc.win322
-rw-r--r--src/modules/makefile.sub.win3219
-rw-r--r--src/modules/makefile.win3241
-rw-r--r--src/modules/ns_maxemail.c228
-rw-r--r--src/modules/ns_noop_convert.c173
-rw-r--r--src/modules/os_ignore_db.c545
-rw-r--r--src/modules/os_info.c780
31 files changed, 4450 insertions, 0 deletions
diff --git a/src/modules/Makefile b/src/modules/Makefile
new file mode 100644
index 000000000..cafbe451c
--- /dev/null
+++ b/src/modules/Makefile
@@ -0,0 +1,48 @@
+include ./Makefile.inc
+
+MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \
+ 'LDFLAGS=${LDFLAGS}' 'BINDEST=${BINDEST}' 'INSTALL=${INSTALL}' \
+ 'INCLUDEDIR=${INCLUDEDIR}' 'RM=${RM}' 'CP=${CP}' \
+ 'TOUCH=${TOUCH}' 'SHELL=${SHELL}' 'DATDEST=${DATDEST}' \
+ 'RUNGROUP=${RUNGROUP}' 'MODULE_PATH=${MODULE_PATH}' \
+ 'PROFILE=${PROFILE}' 'SHARED=${SHARED}' 'MODULEFLAGS=${MODULEFLAGS}'
+
+OBJECTS= $(SRCS:.c=.o)
+SO_FILES=$(OBJECTS:.o=.s)
+CDEFS= -rdynamic -Wall
+
+all: modules subs
+
+modules: $(OBJECTS) $(SO_FILES)
+
+install:
+ $(CP) ./*.so $(MODULE_PATH)
+ @for i in $(SUBS); do \
+ echo "make install in $$i..."; \
+ (cd $$i; $(MAKE) $(MAKEARGS) install);done
+
+distclean: spotless
+
+.c.o:
+ $(CC) ${CFLAGS} ${CDEFS} ${MODULEFLAGS} -I../${INCLUDEDIR} -c $<
+
+.o.s:
+ $(CC) ${SHARED} ../mod_version.o $< -o $*.so ${PROFILE}
+ @$(TOUCH) $*.s
+
+subs:
+ @for i in $(SUBS); do \
+ echo "make all in $$i..."; \
+ (cd $$i; $(MAKE) $(MAKEARGS) all); done
+
+subs_clean:
+ @for i in $(SUBS); do \
+ echo "cleaning in $$i..."; \
+ (cd $$i; $(MAKE) $(MAKEARGS) clean); done
+
+clean: subs_clean
+ rm -f *.o *.s *.so *.c~ core
+
+spotless:
+ rm -f *.o *.s *.so *.c~ core *.so Makefile.inc
+
diff --git a/src/modules/Makefile.sub b/src/modules/Makefile.sub
new file mode 100644
index 000000000..7697249bf
--- /dev/null
+++ b/src/modules/Makefile.sub
@@ -0,0 +1,28 @@
+MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \
+ 'LDFLAGS=${LDFLAGS}' 'BINDEST=${BINDEST}' 'INSTALL=${INSTALL}' \
+ 'INCLUDEDIR=${INCLUDEDIR}' 'RM=${RM}' 'CP=${CP}' \
+ 'TOUCH=${TOUCH}' 'SHELL=${SHELL}' 'DATDEST=${DATDEST}' \
+ 'RUNGROUP=${RUNGROUP}' 'MODULE_PATH=${MODULE_PATH}' \
+ 'PROFILE=${PROFILE}' 'SHARED=${SHARED}' 'MODULEFLAGS=${MODULEFLAGS}'
+
+OBJECTS= $(SRCS:.c=.o)
+SO_FILES=$(OBJECTS:.o=.s)
+CDEFS= -rdynamic -Wall
+
+all: module
+
+module: $(OBJECTS) so
+
+distclean: spotless
+
+.c.o:
+ $(CC) ${CFLAGS} ${CDEFS} ${MODULEFLAGS} -I../ -I../../${INCLUDEDIR} -c $<
+
+so:
+ $(CC) ${SHARED} ../../mod_version.o $(OBJECTS) -o ../$(TARGET).so ${PROFILE}
+
+clean:
+ rm -f *.o *.so *.c~ core
+
+spotless:
+ rm -f *~ *.o *.so *.c~ core
diff --git a/src/modules/README b/src/modules/README
new file mode 100644
index 000000000..6aee0ac47
--- /dev/null
+++ b/src/modules/README
@@ -0,0 +1 @@
+Please read the "MODULES" file located on the "docs" directory.
diff --git a/src/modules/bs_fantasy_unban.c b/src/modules/bs_fantasy_unban.c
new file mode 100644
index 000000000..a17e06551
--- /dev/null
+++ b/src/modules/bs_fantasy_unban.c
@@ -0,0 +1,82 @@
+/* BotServ core fantasy functions
+ *
+ * (C) 2003-2008 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Please read COPYING and README for further details.
+ *
+ * Based on the original code of Epona by Lara.
+ * Based on the original code of Services by Andy Church.
+ *
+ * $Id$
+ *
+ */
+/*************************************************************************/
+
+#include "module.h"
+
+int do_fantasy(int argc, char **argv);
+
+/**
+ * Create the hook, and tell anope about it.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT to allow the module, MOD_STOP to stop it
+ **/
+int AnopeInit(int argc, char **argv)
+{
+ EvtHook *hook;
+
+ moduleAddAuthor("Anope");
+ moduleAddVersion
+ ("$Id$");
+ moduleSetType(CORE);
+
+ hook = createEventHook(EVENT_BOT_FANTASY, do_fantasy);
+ moduleAddEventHook(hook);
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+
+}
+
+/**
+ * Handle unban fantasy command.
+ * @param argc Argument count
+ * @param argv Argument list
+ * @return MOD_CONT or MOD_STOP
+ **/
+int do_fantasy(int argc, char **argv)
+{
+ User *u;
+ ChannelInfo *ci;
+ char *target = NULL;
+
+ if (argc < 3)
+ return MOD_CONT;
+
+ if (stricmp(argv[0], "unban") == 0) {
+ u = finduser(argv[1]);
+ ci = cs_findchan(argv[2]);
+ if (!u || !ci || !check_access(u, ci, CA_UNBAN))
+ return MOD_CONT;
+
+ if (argc >= 4)
+ target = myStrGetToken(argv[3], ' ', 0);
+ if (!target)
+ common_unban(ci, u->nick);
+ else
+ common_unban(ci, target);
+
+ /* free target if needed (#852) */
+ Anope_Free(target);
+ }
+
+ return MOD_CONT;
+}
diff --git a/src/modules/configure b/src/modules/configure
new file mode 100755
index 000000000..cf2158d66
--- /dev/null
+++ b/src/modules/configure
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+echo2 () {
+ $ECHO2 "$*$ECHO2SUF" # these are defined later
+}
+
+ECHO2SUF=''
+if [ "`echo -n a ; echo -n b`" = "ab" ] ; then
+ ECHO2='echo -n'
+elif [ "`echo 'a\c' ; echo 'b\c'`" = "ab" ] ; then
+ ECHO2='echo' ; ECHO2SUF='\c'
+elif [ "`printf 'a' 2>&1 ; printf 'b' 2>&1`" = "ab" ] ; then
+ ECHO2='printf "%s"'
+else
+ # oh well...
+ ECHO2='echo'
+fi
+export ECHO2 ECHO2SUF
+
+
+echo2 "SRCS=" > ./Makefile.inc
+FIRST=1
+for oldfile in *.c
+do
+ if [ "$FIRST" = 1 ] ; then
+ echo2 " "$oldfile >> ./Makefile.inc
+ else
+ echo "\\" >> ./Makefile.inc
+ echo2 " " $oldfile >> ./Makefile.inc
+ fi
+ FIRST=0
+done
+echo "" >> ./Makefile.inc
+
+echo2 "SUBS=" >> ./Makefile.inc
+FIRST=1
+for dir in *
+do
+ if [ -d $dir ] ; then
+ if [ -f $dir/configure ] ; then
+ cd $dir
+ ./configure
+ cd ..
+ fi
+ if [ -f $dir/Makefile ] ; then
+ if [ "$FIRST" = 1 ] ; then
+ echo2 " "$dir >> ./Makefile.inc
+ else
+ echo "\\" >> ./Makefile.inc
+ echo2 " " $dir >> ./Makefile.inc
+ fi
+ FIRST=0
+ fi
+ fi
+done
+
+exit 0
+
diff --git a/src/modules/cs_appendtopic.c b/src/modules/cs_appendtopic.c
new file mode 100644
index 000000000..7e0d27bb4
--- /dev/null
+++ b/src/modules/cs_appendtopic.c
@@ -0,0 +1,247 @@
+/* cs_appendtopic.c - Add text to a channels topic
+ *
+ * (C) 2003-2008 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Based on the original module by SGR <Alex_SGR@ntlworld.com>
+ * Included in the Anope module pack since Anope 1.7.9
+ * Anope Coder: GeniusDex <geniusdex@anope.org>
+ *
+ * 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 "SGR"
+#define VERSION "$Id$"
+
+ /* ------------------------------------------------------------
+ * Name: cs_appendtopic
+ * Author: SGR <Alex_SGR@ntlworld.com>
+ * 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 successfully");
+
+ return MOD_CONT;
+}
+
+void AnopeFini(void)
+{
+ alog("[cs_appendtopic] Unloaded successfully");
+}
+
+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, c->creation_time);
+ anope_cmd_mode(NULL, c->name, "+o %s", s_ChanServ);
+ }
+ }
+ anope_cmd_topic(whosends(ci), c->name, u->nick, 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 (NL) */
+ 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"
+ };
+
+ /* German (DE) */
+ char *langtable_de[] = {
+ /* LNG_CHAN_HELP */
+ " APPENDTOPIC Fьgt einen Text zu einem Channel-Topic hinzu.",
+ /* LNG_CHAN_HELP_APPENDTOPIC */
+ "Dieser Befehl erlaubt Benutzern, einen Text zu dem vorhandenen Channel-Topic\n"
+ "hinzuzufьgen. Wenn TOPICLOCK gesetzt ist, wird das Topic aktualisiert\n"
+ "und das neue, aktualisierte Topic wird gesperrt.",
+ /* LNG_APPENDTOPIC_SYNTAX */
+ "Syntax: APPENDTOPIC Channel Text\n"
+ };
+
+ /* Portuguese (PT) */
+ char *langtable_pt[] = {
+ /* LNG_CHAN_HELP */
+ " APPENDTOPIC Adiciona texto ao tуpico de um canal",
+ /* LNG_CHAN_HELP_APPENDTOPIC */
+ "Este comando permite aos usuбrios anexar texto a um tуpico de canal\n"
+ "jб definido. Quando TOPICLOCK estб ativado, o tуpico й atualizado e\n"
+ "o novo tуpico й travado.",
+ /* LNG_APPENDTOPIC_SYNTAX */
+ "Sintaxe: APPENDTOPIC canal texto\n"
+ };
+
+ /* Russian (RU) */
+ char *langtable_ru[] = {
+ /* LNG_CHAN_HELP */
+ " APPENDTOPIC Добавляет текст к топику канала",
+ /* LNG_CHAN_HELP_APPENDTOPIC */
+ "Данная команда позволяет добавить текст к топику, который установлен на указанном\n"
+ "канале. Если активирован режим TOPICLOCK, топик будет обновлен и заблокирован.\n"
+ "Примечание: текст будет ДОБАВЛЕН к топику, то есть старый топик удален НЕ БУДЕТ.\n",
+ /* LNG_APPENDTOPIC_SYNTAX */
+ "Синтаксис: APPENDTOPIC #канал текст\n"
+ };
+
+ /* Italian (IT) */
+ char *langtable_it[] = {
+ /* LNG_CHAN_HELP */
+ " APPENDTOPIC Aggiunge del testo al topic di un canale",
+ /* LNG_CHAN_HELP_APPENDTOPIC */
+ "Questo comando permette agli utenti di aggiungere del testo ad un topic di un canale\n"
+ "giа impostato. Se TOPICLOCK и attivato, il topic viene aggiornato e il nuovo topic\n"
+ "viene bloccato.",
+ /* LNG_APPENDTOPIC_SYNTAX */
+ "Sintassi: APPENDTOPIC canale testo\n"
+ };
+
+ moduleInsertLanguage(LANG_EN_US, LNG_NUM_STRINGS, langtable_en_us);
+ moduleInsertLanguage(LANG_NL, LNG_NUM_STRINGS, langtable_nl);
+ moduleInsertLanguage(LANG_DE, LNG_NUM_STRINGS, langtable_de);
+ moduleInsertLanguage(LANG_PT, LNG_NUM_STRINGS, langtable_pt);
+ moduleInsertLanguage(LANG_RU, LNG_NUM_STRINGS, langtable_ru);
+ moduleInsertLanguage(LANG_IT, LNG_NUM_STRINGS, langtable_it);
+}
+
+/* EOF */
diff --git a/src/modules/cs_enforce.c b/src/modules/cs_enforce.c
new file mode 100644
index 000000000..a9beec419
--- /dev/null
+++ b/src/modules/cs_enforce.c
@@ -0,0 +1,479 @@
+/* cs_enforce - Add a /cs ENFORCE command to enforce various set
+ * options and channelmodes on a channel.
+ *
+ * (C) 2003-2008 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Included in the Anope module pack since Anope 1.7.9
+ * Anope Coder: GeniusDex <geniusdex@anope.org>
+ *
+ * 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 6
+
+#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
+#define LNG_CHAN_RESPONSE 5
+
+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=NULL;
+ char *what=NULL;
+ 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);
+ moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what);
+ } else if (stricmp(what, "MODES") == 0) {
+ do_enforce_modes(c);
+ moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what);
+ } else if (stricmp(what, "SECUREOPS") == 0) {
+ do_enforce_secureops(c);
+ moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what);
+ } else if (stricmp(what, "RESTRICTED") == 0) {
+ do_enforce_restricted(c);
+ moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what);
+ } else if (stricmp(what, "+R") == 0) {
+ do_enforce_cmode_R(c);
+ moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what);
+ } else {
+ moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX);
+ }
+ }
+
+ if(chan) free(chan);
+ if(what) 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.",
+ /* LNG_CHAN_RESPONSE */
+ "Enforced %s"
+ };
+
+ /* Dutch (NL) */
+ 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