summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2005-05-02 19:02:12 +0000
committerrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2005-05-02 19:02:12 +0000
commite0583918834a3f8683e430adf3923ea89d2a449a (patch)
treeff36ada734c3874d3be1a806e3a2b994386b54ed /src/modules
parent49491770383e66f1b8074d8b0f80026e3086e9d8 (diff)
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
Diffstat (limited to 'src/modules')
-rwxr-xr-xsrc/modules/configure30
-rw-r--r--src/modules/cs_appendtopic.c188
-rw-r--r--src/modules/cs_enforce.c334
-rw-r--r--src/modules/cs_tban.c171
-rw-r--r--src/modules/demos/catserv/Makefile (renamed from src/modules/catserv/Makefile)0
-rw-r--r--src/modules/demos/catserv/README (renamed from src/modules/catserv/README)0
-rw-r--r--src/modules/demos/catserv/catserv_extern.h (renamed from src/modules/catserv/catserv_extern.h)0
-rw-r--r--src/modules/demos/catserv/catserv_messages.c (renamed from src/modules/catserv/catserv_messages.c)0
-rw-r--r--src/modules/demos/catserv/catserv_messages.h (renamed from src/modules/catserv/catserv_messages.h)0
-rw-r--r--src/modules/demos/catserv/ircd_catserv.c (renamed from src/modules/catserv/ircd_catserv.c)2
-rw-r--r--src/modules/demos/catserv/makefile.win32 (renamed from src/modules/catserv/makefile.win32)0
-rw-r--r--src/modules/demos/catserv/meow.c (renamed from src/modules/catserv/meow.c)0
-rw-r--r--src/modules/demos/catserv/meow.h (renamed from src/modules/catserv/meow.h)0
-rw-r--r--src/modules/demos/catserv/purr.c (renamed from src/modules/catserv/purr.c)0
-rw-r--r--src/modules/demos/catserv/purr.h (renamed from src/modules/catserv/purr.h)0
-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.c (renamed from src/modules/hs_moo.c)2
-rw-r--r--src/modules/events.c53
-rw-r--r--src/modules/makefile.inc.win324
-rw-r--r--src/modules/makefile.win321
-rw-r--r--src/modules/module.h10
-rw-r--r--src/modules/ns_maxemail.c190
-rw-r--r--src/modules/ns_noop.c483
-rw-r--r--src/modules/os_info.c639
25 files changed, 2185 insertions, 78 deletions
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 <geniusdex@anope.org>
+ *
+ * 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 <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 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 <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 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/catserv/Makefile b/src/modules/demos/catserv/Makefile
index 5b2f4efa3..5b2f4efa3 100644
--- a/src/modules/catserv/Makefile
+++ b/src/modules/demos/catserv/Makefile
diff --git a/src/modules/catserv/README b/src/modules/demos/catserv/README
index c3d3f7084..c3d3f7084 100644
--- a/src/modules/catserv/README
+++ b/src/modules/demos/catserv/README
diff --git a/src/modules/catserv/catserv_extern.h b/src/modules/demos/catserv/catserv_extern.h
index 02c21addb..02c21addb 100644
--- a/src/modules/catserv/catserv_extern.h
+++ b/src/modules/demos/catserv/catserv_extern.h
diff --git a/src/modules/catserv/catserv_messages.c b/src/modules/demos/catserv/catserv_messages.c
index e11235b4e..e11235b4e 100644
--- a/src/modules/catserv/catserv_messages.c
+++ b/src/modules/demos/catserv/catserv_messages.c
diff --git a/src/modules/catserv/catserv_messages.h b/src/modules/demos/catserv/catserv_messages.h
index bb3f82dd0..bb3f82dd0 100644
--- a/src/modules/catserv/catserv_messages.h
+++ b/src/modules/demos/catserv/catserv_messages.h
diff --git a/src/modules/catserv/ircd_catserv.c b/src/modules/demos/catserv/ircd_catserv.c
index 2fa7b52b3..ae34d6161 100644
--- a/src/modules/catserv/ircd_catserv.c
+++ b/src/modules/demos/catserv/ircd_catserv.c
@@ -10,7 +10,7 @@
#include "catserv_messages.h"
#define AUTHOR "Anope"
-#define VERSION "1.2"
+#define VERSION "$Id$"
int my_privmsg(char *source, int ac, char **av);
diff --git a/src/modules/catserv/makefile.win32 b/src/modules/demos/catserv/makefile.win32
index 638704440..638704440 100644
--- a/src/modules/catserv/makefile.win32
+++ b/src/modules/demos/catserv/makefile.win32
diff --git a/src/modules/catserv/meow.c b/src/modules/demos/catserv/meow.c
index 9279eec0b..9279eec0b 100644
--- a/src/modules/catserv/meow.c
+++ b/src/modules/demos/catserv/meow.c
diff --git a/src/modules/catserv/meow.h b/src/modules/demos/catserv/meow.h
index 0f28673a0..0f28673a0 100644
--- a/src/modules/catserv/meow.h
+++ b/src/modules/demos/catserv/meow.h
diff --git a/src/modules/catserv/purr.c b/src/modules/demos/catserv/purr.c
index 5a39dc26e..5a39dc26e 100644
--- a/src/modules/catserv/purr.c
+++ b/src/modules/demos/catserv/purr.c
diff --git a/src/modules/catserv/purr.h b/src/modules/demos/catserv/purr.h
index a92e421f6..a92e421f6 100644
--- a/src/modules/catserv/purr.h
+++ b/src/modules/demos/catserv/purr.h
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/hs_moo.c b/src/modules/demos/hs_moo.c
index 0c3070036..b65e83bb6 100644
--- a/src/modules/hs_moo.c
+++ b/src/modules/demos/hs_moo.c
@@ -9,7 +9,7 @@
#include "module.h"
#define AUTHOR "Anope" /* Set the Author for a modinfo reply */
-#define VERSION "1.1" /* Set the version 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);
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/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 <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$"
+
+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 <rob@anope.org>
+ * Included in the Anope module pack since Anope 1.7.9
+ * Anope Coder: DrStein <drstein@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 "Rob"
+#define VERSION "$Id$"
+
+/* The name of the default database to save info to */
+#define DEFAULT_DB_NAME "autoop.db"
+
+/* Multi-language stuff */
+#define LANG_NUM_STRINGS 8
+
+#define AUTOOP_SYNTAX 0
+#define AUTOOP_STATUS_ON 1
+#define AUTOOP_STATUS_OFF 2
+#define AUTOOP_NO_NICK 3
+#define AUTOOP_ON 4
+#define AUTOOP_OFF 5
+#define AUTOOP_DESC 6
+#define AUTOOP_HELP 7
+
+/*************************************************************************/
+
+User *currentUser;
+int m_isIRCop = 0;
+
+char *NSAutoOPDBName;
+
+int myNickServAutoOpHelp(User * u);
+void myNickServHelp(User * u);
+
+int noop(User * u);
+int mEventJoin(int argc, char **argv);
+int setAutoOp(User * u);
+int UnsetAutoOp(User * u);
+
+int mLoadData(void);
+int mSaveData(int argc, char **argv);
+int mLoadConfig(int argc, char **argv);
+
+void m_AddLanguages(void);
+void delete_ignore(const char *nick);
+
+/*************************************************************************/
+
+/**
+ * AnopeInit is called when the module is loaded
+ * @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)
+{
+ Command *c = NULL;
+ EvtHook *hook = NULL;
+
+ int status;
+
+ NSAutoOPDBName = NULL;
+
+ moduleAddAuthor(AUTHOR);
+ moduleAddVersion(VERSION);
+ moduleSetType(SUPPORTED);
+
+ alog("ns_noop: Loading configuration directives");
+ if (mLoadConfig(0, NULL))
+ return MOD_STOP;
+
+ c = createCommand("autoop", noop, NULL, -1, -1, -1, -1, -1);
+ status = moduleAddCommand(NICKSERV, c, MOD_HEAD);
+
+ hook = createEventHook(EVENT_JOIN_CHANNEL, mEventJoin);
+ status = moduleAddEventHook(hook);
+
+ hook = createEventHook(EVENT_DB_SAVING, mSaveData);
+ status = moduleAddEventHook(hook);
+
+ hook = createEventHook(EVENT_RELOAD, mLoadConfig);
+ status = moduleAddEventHook(hook);
+
+ moduleAddHelp(c, myNickServAutoOpHelp);
+ moduleSetNickHelp(myNickServHelp);
+
+ mLoadData();
+ m_AddLanguages();
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+ char *av[1];
+
+ av[0] = sstrdup(EVENT_START);
+ mSaveData(1, av);
+ free(av[0]);
+
+ if (NSAutoOPDBName)
+ free(NSAutoOPDBName);
+}
+
+/*************************************************************************/
+
+/**
+ * Provide de user interface to set autoop on/off
+ * @param u The user who executed this command
+ * @return MOD_CONT
+ **/
+int noop(User * u)
+{
+ NickAlias *na = NULL;
+ char *toggleStr = strtok(NULL, "");
+
+ if (!nick_identified(u)) {
+ moduleNoticeLang(s_NickServ, u, AUTOOP_NO_NICK);
+ } else if (!toggleStr) {
+ if ((na = findnick(u->nick))) {
+ if (moduleGetData(&na->nc->moduleData, "autoop")) {
+ moduleNoticeLang(s_NickServ, u, AUTOOP_STATUS_OFF);
+ } else {
+ moduleNoticeLang(s_NickServ, u, AUTOOP_STATUS_ON);
+ }
+ } else {
+ moduleNoticeLang(s_NickServ, u, AUTOOP_SYNTAX);
+ }
+ } else {
+ if (strcasecmp(toggleStr, "on") == 0) {
+ setAutoOp(u);
+ moduleNoticeLang(s_NickServ, u, AUTOOP_ON);
+ } else if (strcasecmp(toggleStr, "off") == 0) {
+ UnsetAutoOp(u);
+ moduleNoticeLang(s_NickServ, u, AUTOOP_OFF);
+ } else {
+ moduleNoticeLang(s_NickServ, u, AUTOOP_SYNTAX);
+ }
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Toggle on/off the autoop feature by adding or
+ * deleting moduleData.
+ * @param u The user who executed this command
+ * @return 0 On success
+ **/
+int setAutoOp(User * u)
+{
+ NickAlias *na = NULL;
+
+ if ((na = findnick(u->nick))) {
+ /* Remove the module data */
+ moduleDelData(&na->nc->moduleData, "autoop");
+ /* NickCore not found! */
+ } else {
+ alog("ns_autoop.so: WARNING: Can not find NickAlias for %s",
+ u->nick);
+ }
+
+ return 0;
+}
+
+int UnsetAutoOp(User * u)
+{
+ NickAlias *na = NULL;
+
+ if ((na = findnick(u->nick))) {
+ /* Add the module data to the user */
+ moduleAddData(&na->nc->moduleData, "autoop", "off");
+ /* NickCore not found! */
+ } else {
+ alog("ns_autoop.so: WARNING: Can not find NickAlias for %s",
+ u->nick);
+ }
+
+ return 0;
+}
+
+/*************************************************************************/
+
+/**
+ * Manage the JOIN_CHANNEL EVENT
+ * @return MOD_CONT
+ **/
+int mEventJoin(int argc, char **argv)
+{
+ User *user;
+ NickAlias *na = NULL;
+
+ if (argc != 3)
+ return MOD_CONT;
+
+ user = finduser(argv[1]);
+ /* Blame Rob if this user->na should be findnick(user->nick); -GD */
+ if (user && (na = user->na)) {
+ if (strcmp(argv[0], EVENT_START) == 0) {
+ if (moduleGetData(&na->nc->moduleData, "autoop")) {
+ currentUser = user;
+ if (is_oper(user)) {
+ user->mode &= ~(anope_get_oper_mode());
+ m_isIRCop = 1;
+ }
+ add_ignore(user->nick, 120);
+ }
+ } else {
+ /* Does the user have the autoop info in his moduleData? */
+ if (moduleGetData(&na->nc->moduleData, "autoop")) {
+ /* The most dirty solution ever! - doc */
+ if (m_isIRCop)
+ user->mode |= anope_get_oper_mode();
+ delete_ignore(user->nick);
+ }
+ }
+ }
+
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+/**
+ * Load data from the db file, and populate the autoop setting
+ * @return 0 for success
+ **/
+int mLoadData(void)
+{
+ int ret = 0;
+ int len = 0;
+
+ char *name = NULL;
+
+ NickAlias *na = NULL;
+ FILE *in;
+
+ /* will _never_ be this big thanks to the 512 limit of a message */
+ char buffer[2000];
+ if ((in = fopen(NSAutoOPDBName, "r")) == NULL) {
+ alog("ns_noop: WARNING: Can not open database file! (it might not exist, this is not fatal)");
+ ret = 1;
+ } else {
+ while (!feof(in)) {
+ fgets(buffer, 1500, in);
+ name = myStrGetToken(buffer, ' ', 0);
+ if (name) {
+ len = strlen(name);
+ /* Take the \n from the end of the line */
+ name[len - 1] = '\0';
+ if ((na = findnick(name))) {
+ moduleAddData(&na->nc->moduleData, "autoop", "off");
+ }
+ free(name);
+ }
+ }
+ }
+ return ret;
+}
+
+/**
+ * Save all our data to our db file
+ * First walk through the nick CORE list, and any nick core which has
+ * the autoop setting, write to the file.
+ * @return 0 for success
+ **/
+int mSaveData(int argc, char **argv)
+{
+ NickCore *nc = NULL;
+ int i = 0;
+ int ret = 0;
+ FILE *out;
+
+ if (argc >= 1) {
+ if (stricmp(argv[0], EVENT_START) == 0) {
+ alog("ns_noop: Saving the databases has started!");
+ if ((out = fopen(NSAutoOPDBName, "w")) == NULL) {
+ alog("ns_noop: ERROR: can not open the database file!");
+ anope_cmd_global(s_NickServ,
+ "ns_noop: ERROR: can not open the database file!");
+ ret = 1;
+ } else {
+ for (i = 0; i < 1024; i++) {
+ for (nc = nclists[i]; nc; nc = nc->next) {
+ /* If we have any info on this user */
+ if (moduleGetData(&nc->moduleData, "autoop")) {
+ fprintf(out, "%s\n", nc->display);
+ }
+ }
+ }
+ fclose(out);
+ }
+ } else {
+ alog("ns_noop: Saving the databases is complete");
+ ret = 0;
+ }
+ }
+
+ return ret;
+}
+
+/*************************************************************************/
+
+/**
+ * Load the configuration directives from Services configuration file.
+ * @return 0 for success
+ **/
+int mLoadConfig(int argc, char **argv)
+{
+ char *tmp = NULL;
+
+ Directive d[] = {
+ {"NSAutoOPDBName", {{PARAM_STRING, PARAM_RELOAD, &tmp}}},
+ };
+
+ moduleGetConfigDirective(d);
+
+ if (NSAutoOPDBName)
+ free(NSAutoOPDBName);
+
+ if (tmp) {
+ NSAutoOPDBName = tmp;
+ } else {
+ NSAutoOPDBName = sstrdup(DEFAULT_DB_NAME);
+ alog("ns_noop: NSAutoOPDBName is not defined in Services configuration file, using default %s", NSAutoOPDBName);
+ }
+
+ if (!NSAutoOPDBName) {
+ alog("ns_noop: FATAL: Can't read required configuration directives!");
+ return MOD_STOP;
+ } else {
+ alog("ns_noop: Directive NSAutoOPDBName loaded (%s)...",
+ NSAutoOPDBName);
+ }
+
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+/**
+ * Below are the help funcitons :)
+ **/
+void myNickServHelp(User * u)
+{
+ moduleNoticeLang(s_NickServ, u, AUTOOP_DESC);
+}
+
+int myNickServAutoOpHelp(User * u)
+{
+ moduleNoticeLang(s_NickServ, u, AUTOOP_SYNTAX);
+ moduleNoticeLang(s_NickServ, u, AUTOOP_HELP, s_ChanServ);
+
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+/**
+ * manages the multilanguage stuff
+ **/
+void m_AddLanguages(void)
+{
+ /* English (US) */
+ char *langtable_en_us[] = {
+ /* AUTOOP_SYNTAX */
+ "Syntax: AUTOOP [ON|OFF]",
+ /* AUTOOP_STATUS_ON */
+ "Your current AUTOOP setting is ON",
+ /* AUTOOP_STATUS_OFF */
+ "Your current AUTOOP setting is OFF",
+ /* AUTOOP_NO_NICK */
+ "Only registered and identified nicknames can set this option",
+ /* AUTOOP_ON */
+ "You will now be auto op'ed in channels when you join",
+ /* AUTOOP_OFF */
+ "You will no longer be auto op'ed in channels when you join them",
+ /* AUTOOP_DESC */
+ " AUTOOP Toggles auto-op'ing when joining rooms",
+ /* AUTOOP_HELP */
+ "When set to ON, this command will prevent %s setting any\n"
+ "modes on you when you join any channel. This command requires\n"
+ "you to be identified."
+ };
+
+ /* Spanish */
+ char *langtable_es[] = {
+ /* AUTOOP_SYNTAX */
+ "Sintaxis: AUTOOP [ON|OFF]",
+ /* AUTOOP_STATUS_ON */
+ "Tu configuracion actual de AUTOOP es ON",
+ /* AUTOOP_STATUS_OFF */
+ "Tu configuracion actual de AUTOOP es OFF",
+ /* AUTOOP_NO_NICK */
+ "Solo nicknames registrados e identificados pueden usar esta opcion",
+ /* AUTOOP_ON */
+ "Recibiras OP automaticamente cuando entres a un canal.",
+ /* AUTOOP_OFF */
+ "Ya no recibiras OP automaticamente.",
+ /* AUTOOP_DESC */
+ " AUTOOP Cambia la opcion de auto-op cuando entras a un canal",
+ /* AUTOOP_HELP */
+ "Cuando esta en ON, evitaras que ChanServ/BotServ\n"
+ "cambien tus modos en el canal que tengas acceso.\n",
+ "(Debes estar identificado para usar esta opcion)"
+ };
+
+ /* Dutch */
+ char *langtable_nl[] = {
+ /* AUTOOP_SYNTAX */
+ "Gebruik: AUTOOP [ON|OFF]",
+ /* AUTOOP_STATUS_ON */
+ "Je huidige AUTOOP instelling is AAN",
+ /* AUTOOP_STATUS_OFF */
+ "Je huidige AUTOOP instelling is UIT",
+ /* AUTOOP_NO_NICK */
+ "Alleen geregistreerd en geidentificeerde nicks kunnen deze optie gebruiken",
+ /* AUTOOP_ON */
+ "Je zal nu kanaal-op worden in kanalen wanneer je die binnen komt",
+ /* AUTOOP_OFF */
+ "Je zal nu geen kanaal-op meer worden in kanalen wanneer je die binnen komt",
+ /* AUTOOP_DESC */
+ " AUTOOP Zet auto-op aan of uit",
+ /* AUTOOP_HELP */
+ "Wanner dit aan (ON) staat, zal dit commando er voor zorgen dat\n"
+ "%s geen kanaalmodes aan jou zal geven wanneer je een\n"
+ "kanaal binnen komt. Voor dit command is het vereist dat je\n"
+ "geidentificeerd bent."
+ };
+
+ moduleInsertLanguage(LANG_EN_US, LANG_NUM_STRINGS, langtable_en_us);
+ moduleInsertLanguage(LANG_ES, LANG_NUM_STRINGS, langtable_es);
+ moduleInsertLanguage(LANG_NL, LANG_NUM_STRINGS, langtable_nl);
+}
+
+/*************************************************************************/
+
+/**
+ * Deletes a nick from the ignore list
+ * @param nick nickname to unignore.
+ **/
+void delete_ignore(const char *nick)
+{
+ IgnoreData *ign, *prev;
+ IgnoreData **whichlist;
+
+ if (!nick || !*nick) {
+ return;
+ }
+
+ whichlist = &ignore[tolower(nick[0])];
+
+ for (ign = *whichlist, prev = NULL; ign; prev = ign, ign = ign->next) {
+ if (stricmp(ign->who, nick) == 0)
+ break;
+ }
+ if (ign) {
+ if (prev)
+ prev->next = ign->next;
+ else
+ *whichlist = ign->next;
+ free(ign);
+ ign = NULL;
+ }
+}
+
+/* EOF */
diff --git a/src/modules/os_info.c b/src/modules/os_info.c
new file mode 100644
index 000000000..1e29d0822
--- /dev/null
+++ b/src/modules/os_info.c
@@ -0,0 +1,639 @@
+/* os_info.c - Adds oper information lines to nicks/channels
+ *
+ * (C) 2003-2005 Anope Team
+ * Contact us at info@anope.org
+ *
+ * Based on the original module by Rob <rob@anope.org>
+ * Included in the Anope module pack since Anope 1.7.9
+ * Anope Coder: DrStein <drstein@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 "Rob"
+#define VERSION "$Id$"
+
+/* Default database name */
+#define DEFAULT_DB_NAME "os_info.db"
+
+/* Multi-language stuff */
+#define LANG_NUM_STRINGS 16
+
+#define OINFO_SYNTAX 0
+#define OINFO_ADD_SUCCESS 1
+#define OINFO_DEL_SUCCESS 2
+#define OCINFO_SYNTAX 3
+#define OCINFO_ADD_SUCCESS 4
+#define OCINFO_DEL_SUCCESS 5
+#define OINFO_HELP_1 6
+#define OINFO_HELP_2 7
+#define OINFO_HELP_3 8
+#define OINFO_HELP_4 9
+#define OCINFO_HELP_1 10
+#define OCINFO_HELP_2 11
+#define OCINFO_HELP_3 12
+#define OCINFO_HELP_4 13
+#define OINFO_HELP 14
+#define OCINFO_HELP 15
+
+/*************************************************************************/
+
+char *OSInfoDBName = NULL;
+
+int myAddNickInfo(User * u);
+int myAddChanInfo(User * u);
+int myNickInfo(User * u);
+int myChanInfo(User * u);
+
+int mNickHelp(User * u);
+int mChanHelp(User * u);
+void mMainChanHelp(User * u);
+void mMainNickHelp(User * u);
+void m_AddLanguages(void);
+
+int mLoadData(void);
+int mSaveData(int argc, char **argv);
+int mLoadConfig();
+int mEventReload(int argc, char **argv);
+
+/*************************************************************************/
+
+/**
+ * AnopeInit is called when the module is loaded
+ * @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)
+{
+ Command *c;
+ EvtHook *hook = NULL;
+
+ int status;
+
+ moduleAddAuthor(AUTHOR);
+ moduleAddVersion(VERSION);
+ moduleSetType(SUPPORTED);
+
+ alog("os_info: Loading configuration directives...");
+ if (mLoadConfig()) {
+ return MOD_STOP;
+ }
+
+ c = createCommand("oInfo", myAddNickInfo, is_oper, -1, -1, -1, -1, -1);
+ moduleAddHelp(c, mNickHelp);
+ status = moduleAddCommand(NICKSERV, c, MOD_HEAD);
+
+ c = createCommand("Info", myNickInfo, NULL, -1, -1, -1, -1, -1);
+ status = moduleAddCommand(NICKSERV, c, MOD_TAIL);
+
+ c = createCommand("oInfo", myAddChanInfo, is_oper, -1, -1, -1, -1, -1);
+ moduleAddHelp(c, mChanHelp);
+ status = moduleAddCommand(CHANSERV, c, MOD_HEAD);
+
+ c = createCommand("Info", myChanInfo, NULL, -1, -1, -1, -1, -1);
+ status = moduleAddCommand(CHANSERV, c, MOD_TAIL);
+
+ hook = createEventHook(EVENT_DB_SAVING, mSaveData);
+ status = moduleAddEventHook(hook);
+
+ hook = createEventHook(EVENT_RELOAD, mEventReload);
+ status = moduleAddEventHook(hook);
+
+ moduleSetNickHelp(mMainNickHelp);
+ moduleSetChanHelp(mMainChanHelp);
+
+ mLoadData();
+ m_AddLanguages();
+
+ return MOD_CONT;
+}
+
+/**
+ * Unload the module
+ **/
+void AnopeFini(void)
+{
+ if (OSInfoDBName)
+ free(OSInfoDBName);
+}
+
+/*************************************************************************/
+
+/**
+ * Provide the user interface to add/remove/update oper information
+ * about a nick.
+ * We are going to assume that anyone who gets this far is an oper;
+ * the createCommand should have handled this checking for us and its
+ * tedious / a waste to do it twice.
+ * @param u The user who executed this command
+ * @return MOD_CONT if we want to process other commands in this command
+ * stack, MOD_STOP if we dont
+ **/
+int myAddNickInfo(User * u)
+{
+ char *text = NULL;
+ char *cmd = NULL;
+ char *nick = NULL;
+ char *info = NULL;
+ NickAlias *na = NULL;
+
+ /* Get the last buffer anope recived */
+ text = moduleGetLastBuffer();
+ if (text) {
+ cmd = myStrGetToken(text, ' ', 0);
+ nick = myStrGetToken(text, ' ', 1);
+ info = myStrGetTokenRemainder(text, ' ', 2);
+ if (cmd && nick) {
+ if (strcasecmp(cmd, "ADD") == 0) {
+ /* Syntax error, again! */
+ if (info) {
+ /* ok we've found the user */
+ if ((na = findnick(nick))) {
+ /* Add the module data to the user */
+ moduleAddData(&na->nc->moduleData, "info", info);
+ moduleNoticeLang(s_NickServ, u,
+ OINFO_ADD_SUCCESS, nick);
+ /* NickCore not found! */
+ } else {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED,
+ nick);
+ }
+ free(info);
+ }
+ } else if (strcasecmp(cmd, "DEL") == 0) {
+ /* ok we've found the user */
+ if ((na = findnick(nick))) {
+ moduleDelData(&na->nc->moduleData, "info");
+ moduleNoticeLang(s_NickServ, u,
+ OINFO_DEL_SUCCESS, nick);
+ /* NickCore not found! */
+ } else {
+ notice_lang(s_NickServ, u, NICK_X_NOT_REGISTERED,
+ nick);
+ }
+ /* another syntax error! */
+ } else {
+ moduleNoticeLang(s_NickServ, u, OINFO_SYNTAX);
+ }
+ free(cmd);
+ free(nick);
+ /* Syntax error */
+ } else if (cmd) {
+ moduleNoticeLang(s_NickServ, u, OINFO_SYNTAX);
+ free(cmd);
+ /* Syntax error */
+ } else {
+ moduleNoticeLang(s_NickServ, u, OINFO_SYNTAX);
+ }
+ free(text);
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Provide the user interface to add/remove/update oper information
+ * about a channel.
+ * We are going to assume that anyone who gets this far is an oper;
+ * the createCommand should have handled this checking for us and
+ * its tedious / a waste to do it twice.
+ * @param u The user who executed this command
+ * @return MOD_CONT if we want to process other commands in this command
+ * stack, MOD_STOP if we dont
+ **/
+int myAddChanInfo(User * u)
+{
+ char *text = NULL;
+ char *cmd = NULL;
+ char *chan = NULL;
+ char *info = NULL;
+ ChannelInfo *ci = NULL;
+
+ /* Get the last buffer anope recived */
+ text = moduleGetLastBuffer();
+ if (text) {
+ cmd = myStrGetToken(text, ' ', 0);
+ chan = myStrGetToken(text, ' ', 1);
+ info = myStrGetTokenRemainder(text, ' ', 2);
+ if (cmd && chan) {
+ if (strcasecmp(cmd, "ADD") == 0) {
+ if (info) {
+ if ((ci = cs_findchan(chan))) {
+ /* Add the module data to the channel */
+ moduleAddData(&ci->moduleData, "info", info);
+ moduleNoticeLang(s_ChanServ, u,
+ OCINFO_ADD_SUCCESS, chan);
+ /* ChanInfo */
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED,
+ chan);
+ }
+ free(info);
+ }
+ } else if (strcasecmp(cmd, "DEL") == 0) {
+ if ((ci = cs_findchan(chan))) {
+ /* Del the module data from the channel */
+ moduleDelData(&ci->moduleData, "info");
+ moduleNoticeLang(s_ChanServ, u,
+ OCINFO_DEL_SUCCESS, chan);
+ /* ChanInfo */
+ } else {
+ notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED,
+ chan);
+ }
+ /* another syntax error! */
+ } else {
+ moduleNoticeLang(s_ChanServ, u, OCINFO_SYNTAX);
+ }
+ free(cmd);
+ free(chan);
+ /* Syntax error */
+ } else if (cmd) {
+ moduleNoticeLang(s_ChanServ, u, OCINFO_SYNTAX);
+ free(cmd);
+ /* Syntax error */
+ } else {
+ moduleNoticeLang(s_ChanServ, u, OCINFO_SYNTAX);
+ }
+ free(text);
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+/**
+ * Called after a user does a /msg nickserv info [nick]
+ * @param u The user who requested info
+ * @return MOD_CONT to continue processing commands or MOD_STOP to stop
+ **/
+int myNickInfo(User * u)
+{
+ char *text = NULL;
+ char *nick = NULL;
+ NickAlias *na = NULL;
+
+ /* Only show our goodies to opers */
+ if (is_oper(u)) {
+ /* Get the last buffer anope recived */
+ text = moduleGetLastBuffer();
+ if (text) {
+ nick = myStrGetToken(text, ' ', 0);
+ if (nick) {
+ /* ok we've found the user */
+ if ((na = findnick(nick))) {
+ /* If we have any info on this user */
+ if (moduleGetData(&na->nc->moduleData, "info")) {
+ notice_user(s_NickServ, u, " OperInfo: %s",
+ moduleGetData(&na->nc->moduleData,
+ "info"));
+ }
+ /* NickCore not found! */
+ } else {
+ /* we dont care! */
+ }
+ free(nick);
+ }
+ free(text);
+ }
+ }
+ return MOD_CONT;
+}
+
+/**
+ * Called after a user does a /msg chanserv info chan
+ * @param u The user who requested info
+ * @return MOD_CONT to continue processing commands or MOD_STOP to stop
+ **/
+int myChanInfo(User * u)
+{
+ char *text = NULL;
+ char *chan = NULL;
+ ChannelInfo *ci = NULL;
+
+ /* Only show our goodies to opers */
+ if (is_oper(u)) {
+ /* Get the last buffer anope recived */
+ text = moduleGetLastBuffer();
+ if (text) {
+ chan = myStrGetToken(text, ' ', 0);
+ if (chan) {
+ if ((ci = cs_findchan(chan))) {
+ /* If we have any info on this channel */
+ if (moduleGetData(&ci->moduleData, "info")) {
+ notice_user(s_ChanServ, u, " OperInfo: %s",
+ moduleGetData(&ci->moduleData,
+ "info"));
+ }
+ }
+ free(chan);
+ }
+ free(text);
+ }
+ }
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+/**
+ * Load data from the db file, and populate our OperInfo lines
+ * @return 0 for success
+ **/
+int mLoadData(void)
+{
+ int ret = 0;
+ FILE *in;
+
+ char *type = NULL;
+ char *name = NULL;
+ char *info = NULL;
+ int len = 0;
+
+ ChannelInfo *ci = NULL;
+ NickAlias *na = NULL;
+
+ /* will _never_ be this big thanks to the 512 limit of a message */
+ char buffer[2000];
+ if ((in = fopen(OSInfoDBName, "r")) == NULL) {
+ alog("os_info: WARNING: can not open the database file! (it might not exist, this is not fatal)");
+ ret = 1;
+ } else {
+ while (!feof(in)) {
+ fgets(buffer, 1500, in);
+ type = myStrGetToken(buffer, ' ', 0);
+ name = myStrGetToken(buffer, ' ', 1);
+ info = myStrGetTokenRemainder(buffer, ' ', 2);
+ if (type) {
+ if (name) {
+ if (info) {
+ len = strlen(info);
+ /* Take the \n from the end of the line */
+ info[len - 1] = '\0';
+ if (stricmp(type, "C") == 0) {
+ if ((ci = cs_findchan(name))) {
+ moduleAddData(&ci->moduleData, "info",
+ info);
+ }
+ } else if (stricmp(type, "N") == 0) {
+ if ((na = findnick(name))) {
+ moduleAddData(&na->nc->moduleData, "info",
+ info);
+ }
+ }
+ free(info);
+ }
+ free(name);
+ }
+ free(type);
+ }
+ }
+ }
+ return ret;
+}
+
+/**
+ * Save all our data to our db file
+ * First walk through the nick CORE list, and any nick core which has
+ * oper info attached to it, write to the file.
+ * Next do the same again for ChannelInfos
+ * @return 0 for success
+ **/
+int mSaveData(int argc, char **argv)
+{
+ ChannelInfo *ci = NULL;
+ NickCore *nc = NULL;
+ int i = 0;
+ int ret = 0;
+ FILE *out;
+
+ if (argc >= 1) {
+ if (!stricmp(argv[0], EVENT_START)) {
+ alog("os_info: Saving the databases has started!");
+ if ((out = fopen(OSInfoDBName, "w")) == NULL) {
+ alog("os_info: ERROR: can not open the database file!");
+ anope_cmd_global(s_OperServ,
+ "os_info: ERROR: can not open the database file!");
+ ret = 1;
+ } else {
+ for (i = 0; i < 1024; i++) {
+ for (nc = nclists[i]; nc; nc = nc->next) {
+ /* If we have any info on this user */
+ if (moduleGetData(&nc->moduleData, "info")) {
+ fprintf(out, "N %s %s\n", nc->display,
+ moduleGetData(&nc->moduleData,
+ "info"));
+ }
+ }
+ }
+
+
+ for (i = 0; i < 256; i++) {
+ for (ci = chanlists[i]; ci; ci = ci->next) {
+ /* If we have any info on this channel */
+ if (moduleGetData(&ci->moduleData, "info")) {
+ fprintf(out, "C %s %s\n", ci->name,
+ moduleGetData(&ci->moduleData,
+ "info"));
+ }
+ }
+ }
+ fclose(out);
+ }
+ } else {
+ alog("os_info: Saving the databases is complete");
+ ret = 0;
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * Load the configuration directives from Services configuration file.
+ * @return 0 for success
+ **/
+int mLoadConfig(void)
+{
+ char *tmp = NULL;
+
+ Directive directivas[] = {
+ {"OSInfoDBName", {{PARAM_SET, PARAM_RELOAD, &tmp}}},
+ };
+
+ Directive *d = &directivas[0];
+ moduleGetConfigDirective(d);
+
+ if (OSInfoDBName)
+ free(OSInfoDBName);
+
+ if (tmp) {
+ OSInfoDBName = tmp;
+ } else {
+ OSInfoDBName = sstrdup(DEFAULT_DB_NAME);
+ alog("os_info: OSInfoDBName is not defined in Services configuration file, using default %s", OSInfoDBName);
+ }
+
+ alog("os_info: Directive OSInfoDBName loaded (%s)...", OSInfoDBName);
+
+ return 0;
+}
+
+/**
+ * Manage the RELOAD EVENT
+ * @return MOD_CONT
+ **/
+int mEventReload(int argc, char **argv)
+{
+ int ret = 0;
+ if (argc >= 1) {
+ if (!stricmp(argv[0], EVENT_START)) {
+ alog("os_info: Reloading configuration directives...");
+ ret = mLoadConfig();
+ } else {
+ /* Nothing for now */
+ }
+ }
+
+ if (ret)
+ alog("os_info.c: ERROR: An error has occured while reloading the configuration file");
+
+ return MOD_CONT;
+}
+
+/*************************************************************************/
+
+/**
+ * manages the multilanguage stuff
+ **/
+void m_AddLanguages(void)
+{
+ char *langtable_en_us[] = {
+ /* OINFO_SYNTAX */
+ "Syntax: OINFO [ADD|DEL] nick <info>",
+ /* OINFO_ADD_SUCCESS */
+ "OperInfo line has been added to nick %s",
+ /* OINFO_DEL_SUCCESS */
+ "OperInfo line has been removed from nick %s",
+ /* OCINFO_SYNTAX */
+ "Syntax: OINFO [ADD|DEL] chan <info>",
+ /* OCINFO_ADD_SUCCESS */
+ "OperInfo line has been added to channel %s",
+ /* OCINFO_DEL_SUCCESS */
+ "OperInfo line has been removed from channel %s",
+ /* OINFO_HELP_1 */
+ "Syntax: OINFO [ADD|DEL] nick <info>",
+ /* OINFO_HELP_2 */
+ "Add or Delete Oper information for the given nick ",
+ /* OINFO_HELP_3 */
+ "This will show up when any oper /ns info nick's the user.",
+ /* OINFO_HELP_4 */
+ "and can be used for 'tagging' users etc....",
+ /* OCINFO_HELP_1 */
+ "Syntax: OINFO [ADD|DEL] chan <info>",
+ /* OCINFO_HELP_2 */
+ "Add or Delete Oper information for the given channel",
+ /* OCINFO_HELP_3 */
+ "This will show up when any oper /ns info's the channel.",
+ /* OCINFO_HELP_4 */
+ "and can be used for 'tagging' channels etc....",
+ /* OINFO_HELP */
+ " OINFO Add / Del an OperInfo line to a nick",
+ /* OCINFO_HELP */
+ " OINFO Add / Del an OperInfo line to a channel"
+ };
+
+ char *langtable_es[] = {
+ /* OINFO_SYNTAX */
+ "Sintaxis: OINFO [ADD|DEL] nick <info>",
+ /* OINFO_ADD_SUCCESS */
+ "Una linea OperInfo ha sido agregada al nick %s",
+ /* OINFO_DEL_SUCCESS */
+ "La linea OperInfo ha sido removida del nick %s",
+ /* OCINFO_SYNTAX */
+ "Sintaxis: OINFO [ADD|DEL] chan <info>",
+ /* OCINFO_ADD_SUCCESS */
+ "Linea OperInfo ha sido agregada al canal %s",
+ /* OCINFO_DEL_SUCCESS */
+ "La linea OperInfo ha sido removida del canal %s",
+ /* OINFO_HELP_1 */
+ "Sintaxis: OINFO [ADD|DEL] nick <info>",
+ /* OINFO_HELP_2 */
+ "Agrega o elimina informacion para Operadores al nick dado",
+ /* OINFO_HELP_3 */
+ "Esto se mostrara cuando cualquier operador haga /ns info nick",
+ /* OINFO_HELP_4 */
+ "y puede ser usado para 'marcado' de usuarios, etc....",
+ /* OCINFO_HELP_1 */
+ "Sintaxis: OINFO [ADD|DEL] chan <info>",
+ /* OCINFO_HELP_2 */
+ "Agrega o elimina informacion para Operadores al canal dado",
+ /* OCINFO_HELP_3 */
+ "Esto se mostrara cuando cualquier operador haga /cs info canal",
+ /* OCINFO_HELP_4 */
+ "y puede ser usado para 'marcado' de canales, etc....",
+ /* OINFO_HELP */
+ " OINFO Agrega / Elimina una linea OperInfo al nick",
+ /* OCINFO_HELP */
+ " OINFO Agrega / Elimina una linea OperInfo al canal"
+ };
+
+ moduleInsertLanguage(LANG_EN_US, LANG_NUM_STRINGS, langtable_en_us);
+ moduleInsertLanguage(LANG_ES, LANG_NUM_STRINGS, langtable_es);
+}
+
+/*************************************************************************/
+
+int mNickHelp(User * u)
+{
+ if (is_oper(u)) {
+ moduleNoticeLang(s_NickServ, u, OINFO_HELP_1);
+ moduleNoticeLang(s_NickServ, u, OINFO_HELP_2);
+ moduleNoticeLang(s_NickServ, u, OINFO_HELP_3);
+ moduleNoticeLang(s_NickServ, u, OINFO_HELP_4);
+ } else {
+ notice_lang(s_NickServ, u, NO_HELP_AVAILABLE, "OINFO");
+ }
+ return MOD_CONT;
+}
+
+int mChanHelp(User * u)
+{
+ if (is_oper(u)) {
+ moduleNoticeLang(s_ChanServ, u, OCINFO_HELP_1);
+ moduleNoticeLang(s_ChanServ, u, OCINFO_HELP_2);
+ moduleNoticeLang(s_ChanServ, u, OCINFO_HELP_3);
+ moduleNoticeLang(s_ChanServ, u, OCINFO_HELP_4);
+ } else {
+ notice_lang(s_ChanServ, u, NO_HELP_AVAILABLE, "OINFO");
+ }
+ return MOD_CONT;
+}
+
+/* This help will be added to the main NickServ list */
+void mMainNickHelp(User * u)
+{
+ if (is_oper(u)) {
+ moduleNoticeLang(s_NickServ, u, OINFO_HELP);
+ }
+}
+
+/* This help will be added to the main NickServ list */
+void mMainChanHelp(User * u)
+{
+ if (is_oper(u)) {
+ moduleNoticeLang(s_ChanServ, u, OCINFO_HELP);
+ }
+}
+
+/*************************************************************************/
+
+/* EOF */