From 8b9ba9676736d00c8fb97889b875420b641659a7 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 20 Jun 2010 14:04:17 -0400 Subject: Added m_helpchan to replace the cores helpchannel functionality --- data/example.conf | 16 ++++++++++------ src/config.c | 1 - src/modules/m_helpchan.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 src/modules/m_helpchan.cpp diff --git a/data/example.conf b/data/example.conf index c03a82040..3c14f9e2a 100644 --- a/data/example.conf +++ b/data/example.conf @@ -195,12 +195,6 @@ serverinfo */ networkinfo { - /* - * For the given channel, every user that has or gets op status of the channel - * will automatically receive the +h user mode. This directive is optional. - */ - helpchannel = "#help" - /* * If set, Services will output log messages to the given channel. This * directive is optional. @@ -1520,6 +1514,16 @@ db_plain database = "anope.db" } +modules { name = "m_helpchan" } +m_helpchan +{ + /* + * For the given channel, every user that has or gets op status of the channel + * will automatically receive the +h user mode. This directive is optional. + */ + helpchannel = "#help" +} + hs_request { /* diff --git a/src/config.c b/src/config.c index 1846edfe5..33873bc20 100644 --- a/src/config.c +++ b/src/config.c @@ -608,7 +608,6 @@ int ServerConfig::Read(bool bail) {"serverinfo", "hostname", "", new ValueContainerChar(&Config.ServiceHost), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, {"serverinfo", "pid", "services.pid", new ValueContainerChar(&Config.PIDFilename), DT_CHARPTR | DT_NORELOAD, ValidateNotEmpty}, {"serverinfo", "motd", "services.motd", new ValueContainerChar(&Config.MOTDFilename), DT_CHARPTR, ValidateNotEmpty}, - {"networkinfo", "helpchannel", "", new ValueContainerChar(&Config.HelpChannel), DT_CHARPTR, NoValidation}, {"networkinfo", "logchannel", "", new ValueContainerChar(&Config.LogChannel), DT_CHARPTR, NoValidation}, {"networkinfo", "logbot", "no", new ValueContainerBool(&Config.LogBot), DT_BOOLEAN, NoValidation}, {"networkinfo", "networkname", "", new ValueContainerChar(&Config.NetworkName), DT_CHARPTR, ValidateNotEmpty}, diff --git a/src/modules/m_helpchan.cpp b/src/modules/m_helpchan.cpp new file mode 100644 index 000000000..6255d5012 --- /dev/null +++ b/src/modules/m_helpchan.cpp @@ -0,0 +1,48 @@ +/* + * (C) 2003-2010 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + */ + +#include "module.h" + +class HelpChannel : public Module +{ + ci::string HelpChan; + + public: + HelpChannel(const std::string &modname, const std::string &creator) : Module(modname, creator) + { + this->SetAuthor("Anope"); + this->SetVersion(VERSION_STRING); + this->SetType(SUPPORTED); + + Implementation i[] = { I_OnChannelModeSet, I_OnReload }; + ModuleManager::Attach(i, this, 2); + + OnReload(true); + } + + EventReturn OnChannelModeSet(Channel *c, ChannelModeName Name, const std::string ¶m) + { + if (Name == CMODE_OP && c && c->ci && c->name == this->HelpChan) + { + User *u = finduser(param); + + if (u) + u->SetMode(OperServ, UMODE_HELPOP); + } + + return EVENT_CONTINUE; + } + + void OnReload(bool) + { + ConfigReader config; + + this->HelpChan = config.ReadValue("m_helpchan", "helpchannel", "", 0).c_str(); + } +}; + +MODULE_INIT(HelpChannel) -- cgit