From 1d0bb9b26b7ad58ab0bf979ac046f4511b3bf12b Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 5 May 2013 01:55:04 -0400 Subject: Rework the config file reader to be much more flexible and move many configuration directives to the actual modules they are used in. --- modules/bs_autoassign.cpp | 17 +- modules/commands/bs_badwords.cpp | 18 +- modules/commands/bs_bot.cpp | 38 ++-- modules/commands/bs_kick.cpp | 38 ++-- modules/commands/bs_set.cpp | 7 +- modules/commands/cs_access.cpp | 23 ++- modules/commands/cs_akick.cpp | 16 +- modules/commands/cs_ban.cpp | 5 +- modules/commands/cs_clone.cpp | 22 +-- modules/commands/cs_entrymsg.cpp | 11 +- modules/commands/cs_fantasy_stats.cpp | 9 +- modules/commands/cs_fantasy_top.cpp | 9 +- modules/commands/cs_flags.cpp | 16 +- modules/commands/cs_info.cpp | 7 +- modules/commands/cs_kick.cpp | 7 +- modules/commands/cs_list.cpp | 10 +- modules/commands/cs_mode.cpp | 2 +- modules/commands/cs_register.cpp | 15 +- modules/commands/cs_seen.cpp | 24 +-- modules/commands/cs_set.cpp | 34 ++-- modules/commands/cs_set_misc.cpp | 12 +- modules/commands/cs_suspend.cpp | 11 +- modules/commands/cs_xop.cpp | 29 +-- modules/commands/help.cpp | 9 +- modules/commands/hs_list.cpp | 11 +- modules/commands/hs_request.cpp | 56 +++--- modules/commands/hs_set.cpp | 8 +- modules/commands/ms_read.cpp | 7 +- modules/commands/ms_rsend.cpp | 26 +-- modules/commands/ms_send.cpp | 4 +- modules/commands/ms_set.cpp | 27 ++- modules/commands/ns_access.cpp | 21 ++- modules/commands/ns_ajoin.cpp | 2 +- modules/commands/ns_cert.cpp | 10 +- modules/commands/ns_drop.cpp | 4 +- modules/commands/ns_getpass.cpp | 4 +- modules/commands/ns_group.cpp | 34 ++-- modules/commands/ns_info.cpp | 14 +- modules/commands/ns_list.cpp | 11 +- modules/commands/ns_recover.cpp | 13 +- modules/commands/ns_register.cpp | 78 ++++---- modules/commands/ns_resetpass.cpp | 13 +- modules/commands/ns_set.cpp | 77 ++++---- modules/commands/ns_set_misc.cpp | 14 +- modules/commands/ns_suspend.cpp | 7 +- modules/commands/ns_update.cpp | 2 +- modules/commands/os_akill.cpp | 24 ++- modules/commands/os_chankill.cpp | 5 +- modules/commands/os_config.cpp | 154 ++-------------- modules/commands/os_defcon.cpp | 66 ++++--- modules/commands/os_dns.cpp | 18 +- modules/commands/os_forbid.cpp | 35 ++-- modules/commands/os_ignore.cpp | 5 +- modules/commands/os_kill.cpp | 4 +- modules/commands/os_list.cpp | 10 +- modules/commands/os_login.cpp | 12 +- modules/commands/os_logsearch.cpp | 10 +- modules/commands/os_news.cpp | 21 +-- modules/commands/os_noop.cpp | 4 +- modules/commands/os_reload.cpp | 4 +- modules/commands/os_session.cpp | 125 ++++++++----- modules/commands/os_set.cpp | 16 +- modules/commands/os_stats.cpp | 7 +- modules/commands/os_svs.cpp | 9 +- modules/commands/os_sxline.cpp | 55 +++--- modules/database/db_flatfile.cpp | 31 ++-- modules/database/db_old.cpp | 3 +- modules/database/db_plain.cpp | 14 +- modules/database/db_sql.cpp | 10 +- modules/database/db_sql_live.cpp | 11 +- modules/extra/m_chanstats.cpp | 29 +-- modules/extra/m_httpd.cpp | 21 ++- modules/extra/m_ldap.cpp | 24 +-- modules/extra/m_ldap_authentication.cpp | 36 ++-- modules/extra/m_ldap_oper.cpp | 16 +- modules/extra/m_mysql.cpp | 26 ++- modules/extra/m_proxyscan.cpp | 43 +++-- modules/extra/m_sql_authentication.cpp | 22 +-- modules/extra/m_sql_oper.cpp | 8 +- modules/extra/m_sqlite.cpp | 16 +- modules/extra/m_ssl.cpp | 12 +- modules/extra/m_xmlrpc_main.cpp | 9 +- modules/extra/webcpanel/pages/chanserv/access.cpp | 8 +- modules/extra/webcpanel/pages/chanserv/akick.cpp | 4 +- modules/extra/webcpanel/pages/chanserv/drop.cpp | 2 +- modules/extra/webcpanel/pages/confirm.cpp | 2 +- modules/extra/webcpanel/pages/hostserv/request.cpp | 2 +- modules/extra/webcpanel/pages/memoserv/memos.cpp | 4 +- modules/extra/webcpanel/pages/nickserv/access.cpp | 4 +- modules/extra/webcpanel/pages/nickserv/cert.cpp | 4 +- modules/extra/webcpanel/pages/operserv/akill.cpp | 4 +- modules/extra/webcpanel/pages/register.cpp | 2 +- modules/extra/webcpanel/webcpanel.cpp | 37 ++-- modules/ldap.h | 173 ----------------- modules/ldapapi.h | 173 +++++++++++++++++ modules/m_dns.cpp | 19 +- modules/m_dnsbl.cpp | 28 +-- modules/m_helpchan.cpp | 11 +- modules/m_rewrite.cpp | 17 +- modules/ns_maxemail.cpp | 20 +- modules/protocol/bahamut.cpp | 6 +- modules/protocol/charybdis.cpp | 29 ++- modules/protocol/hybrid.cpp | 18 +- modules/protocol/inspircd11.cpp | 8 +- modules/protocol/inspircd12.cpp | 18 +- modules/protocol/inspircd20.cpp | 39 ++-- modules/protocol/ngircd.cpp | 11 +- modules/protocol/plexus.cpp | 6 +- modules/protocol/ratbox.cpp | 7 +- modules/protocol/unreal.cpp | 50 +++-- modules/pseudoclients/botserv.cpp | 144 ++++++++++++--- modules/pseudoclients/chanserv.cpp | 205 ++++++++++++++++++--- modules/pseudoclients/chanserv.h | 18 ++ modules/pseudoclients/global.cpp | 48 +++-- modules/pseudoclients/global.h | 4 +- modules/pseudoclients/hostserv.cpp | 24 ++- modules/pseudoclients/memoserv.cpp | 64 ++++--- modules/pseudoclients/memoserv.h | 4 +- modules/pseudoclients/nickserv.cpp | 136 +++++++++----- modules/pseudoclients/nickserv.h | 4 +- modules/pseudoclients/operserv.cpp | 29 ++- 121 files changed, 1734 insertions(+), 1399 deletions(-) delete mode 100644 modules/ldap.h create mode 100644 modules/ldapapi.h create mode 100644 modules/pseudoclients/chanserv.h (limited to 'modules') diff --git a/modules/bs_autoassign.cpp b/modules/bs_autoassign.cpp index 134904925..3604fe69b 100644 --- a/modules/bs_autoassign.cpp +++ b/modules/bs_autoassign.cpp @@ -11,35 +11,28 @@ class BSAutoAssign : public Module { - Anope::string bot; - public: BSAutoAssign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) { - - Implementation i[] = { I_OnChanRegistered, I_OnReload }; + Implementation i[] = { I_OnChanRegistered }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } void OnChanRegistered(ChannelInfo *ci) anope_override { - if (this->bot.empty()) + const Anope::string &bot = Config->GetModule(this)->Get("bot"); + if (bot.empty()) return; - BotInfo *bi = BotInfo::Find(this->bot); + BotInfo *bi = BotInfo::Find(bot); if (bi == NULL) { - Log(this) << "bs_autoassign is configured to assign bot " << this->bot << ", but it does not exist?"; + Log(this) << "bs_autoassign is configured to assign bot " << bot << ", but it does not exist?"; return; } bi->Assign(NULL, ci); } - - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override - { - this->bot = reader.ReadValue("bs_autoassign", "bot", "", 0); - } }; MODULE_INIT(BSAutoAssign) diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp index 90fbb875d..31dee8f8e 100644 --- a/modules/commands/bs_badwords.cpp +++ b/modules/commands/bs_badwords.cpp @@ -9,11 +9,8 @@ * Based on the original code of Services by Andy Church. */ -/*************************************************************************/ - #include "module.h" - class BadwordsDelCallback : public NumberList { CommandSource &source; @@ -146,17 +143,20 @@ class CommandBSBadwords : public Command realword = word.substr(0, pos); } - if (ci->GetBadWordCount() >= Config->BSBadWordsMax) + unsigned badwordsmax = Config->GetModule(this->module)->Get("badwordsmax"); + if (ci->GetBadWordCount() >= badwordsmax) { - source.Reply(_("Sorry, you can only have %d bad words entries on a channel."), Config->BSBadWordsMax); + source.Reply(_("Sorry, you can only have %d bad words entries on a channel."), badwordsmax); return; } + bool casesensitive = Config->GetModule("botserv")->Get("casesensitive"); + for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i) { const BadWord *bw = ci->GetBadWord(i); - if (!bw->word.empty() && ((Config->BSCaseSensitive && realword.equals_cs(bw->word)) || (!Config->BSCaseSensitive && realword.equals_ci(bw->word)))) + if ((casesensitive && realword.equals_cs(bw->word)) || (!casesensitive && realword.equals_ci(bw->word))) { source.Reply(_("\002%s\002 already exists in %s bad words list."), bw->word.c_str(), ci->name.c_str()); return; @@ -168,8 +168,6 @@ class CommandBSBadwords : public Command ci->AddBadWord(realword, bwtype); source.Reply(_("\002%s\002 added to %s bad words list."), realword.c_str(), ci->name.c_str()); - - return; } void DoDelete(CommandSource &source, ChannelInfo *ci, const Anope::string &word) @@ -219,6 +217,7 @@ class CommandBSBadwords : public Command source.Reply(_("Bad words list is now empty.")); return; } + public: CommandBSBadwords(Module *creator) : Command(creator, "botserv/badwords", 2, 3) { @@ -289,7 +288,7 @@ class CommandBSBadwords : public Command "will be done if a user says a word that ends with\n" "\037word\037. If you don't specify anything, a kick will\n" "be issued every time \037word\037 is said by a user.\n" - " \n"), Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str(), source.command.c_str()); + " \n"), Config->StrictPrivmsg.c_str(), source.service->nick.c_str(), source.command.c_str()); source.Reply(_("The \002DEL\002 command removes the given word from the\n" "bad words list. If a list of entry numbers is given, those\n" "entries are deleted. (See the example for LIST below.)\n" @@ -316,7 +315,6 @@ class BSBadwords : public Module BSBadwords(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandbsbadwords(this) { - } }; diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index f8ecb1a1d..16fd9f2f2 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -29,21 +29,23 @@ class CommandBSBot : public Command return; } - if (nick.length() > Config->NickLen) + Configuration::Block *networkinfo = Config->GetBlock("networkinfo"); + + if (nick.length() > networkinfo->Get("nicklen")) { - source.Reply(_("Bot nicks may only be %d characters long."), Config->NickLen); + source.Reply(_("Bot nicks may only be %d characters long."), networkinfo->Get("nicklen")); return; } - if (user.length() > Config->UserLen) + if (user.length() > networkinfo->Get("userlen")) { - source.Reply(_("Bot idents may only be %d characters long."), Config->UserLen); + source.Reply(_("Bot idents may only be %d characters long."), networkinfo->Get("userlen")); return; } - if (host.length() > Config->HostLen) + if (host.length() > networkinfo->Get("hostlen")) { - source.Reply(_("Bot hosts may only be %d characters long."), Config->HostLen); + source.Reply(_("Bot hosts may only be %d characters long."), networkinfo->Get("hostlen")); return; } @@ -112,21 +114,23 @@ class CommandBSBot : public Command return; } - if (nick.length() > Config->NickLen) + Configuration::Block *networkinfo = Config->GetBlock("networkinfo"); + + if (nick.length() > networkinfo->Get("nicklen")) { - source.Reply(_("Bot nicks may only be %d characters long."), Config->NickLen); + source.Reply(_("Bot nicks may only be %d characters long."), networkinfo->Get("nicklen")); return; } - if (!user.empty() && user.length() > Config->UserLen) + if (user.length() > networkinfo->Get("userlen")) { - source.Reply(_("Bot idents may only be %d characters long."), Config->UserLen); + source.Reply(_("Bot idents may only be %d characters long."), networkinfo->Get("userlen")); return; } - if (!host.empty() && host.length() > Config->HostLen) + if (host.length() > networkinfo->Get("hostlen")) { - source.Reply(_("Bot hosts may only be %d characters long."), Config->HostLen); + source.Reply(_("Bot hosts may only be %d characters long."), networkinfo->Get("hostlen")); return; } @@ -204,7 +208,15 @@ class CommandBSBot : public Command if (!user.empty()) { IRCD->SendClientIntroduction(bi); - bi->RejoinAll(); + unsigned minusers = Config->GetBlock("botserv")->Get("minusers"); + const std::set &channels = bi->GetChannels(); + for (std::set::const_iterator it = channels.begin(), it_end = channels.end(); it != it_end; ++it) + { + const ChannelInfo *ci = *it; + + if (ci->c && ci->c->users.size() >= minusers) + bi->Join(ci->c); + } } source.Reply(_("Bot \002%s\002 has been changed to %s!%s@%s (%s)."), oldnick.c_str(), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index 86248ae80..5c1bdc6a8 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -13,6 +13,8 @@ #include "module.h" +static Module *me; + class CommandBSKick : public Command { public: @@ -54,7 +56,7 @@ class CommandBSKick : public Command "on a specific option.\n" " \n" "Note: access to this command is controlled by the\n" - "level SET."), Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str(), this_name.c_str()); + "level SET."), Config->StrictPrivmsg.c_str(), source.service->nick.c_str(), this_name.c_str()); return true; } @@ -199,7 +201,7 @@ class CommandBSKickBadwords : public CommandBSKickBase "more information.\n" "ttb is the number of times a user can be kicked\n" "before it get banned. Don't give ttb to disable\n" - "the ban system once activated."), Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str()); + "the ban system once activated."), Config->StrictPrivmsg.c_str(), source.service->nick.c_str()); return true; } }; @@ -406,8 +408,8 @@ class CommandBSKickFlood : public CommandBSKickBase catch (const ConvertException &) { } if (ci->floodsecs < 1) ci->floodsecs = 10; - if (ci->floodsecs > Config->BSKeepData) - ci->floodsecs = Config->BSKeepData; + if (ci->floodsecs > Config->GetModule(me)->Get("keepdata")) + ci->floodsecs = Config->GetModule(me)->Get("keepdata"); ci->ExtendMetadata("BS_KICK_FLOOD"); if (ci->ttb[TTB_FLOOD]) @@ -639,13 +641,14 @@ struct BanData : ExtensibleItem void purge() { + time_t keepdata = Config->GetModule(me)->Get("keepdata"); for (data_type::iterator it = data_map.begin(), it_end = data_map.end(); it != it_end;) { const Anope::string &user = it->first; Data &bd = it->second; ++it; - if (Anope::CurTime - bd.last_use > Config->BSKeepData) + if (Anope::CurTime - bd.last_use > keepdata) data_map.erase(user); } } @@ -797,8 +800,10 @@ class BSKick : public Module purger(this) { + me = this; - ModuleManager::Attach(I_OnPrivmsg, this); + Implementation i[] = { I_OnPrivmsg }; + ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } ~BSKick() @@ -920,30 +925,31 @@ class BSKick : public Module /* Normalize the buffer */ Anope::string nbuf = Anope::NormalizeBuffer(realbuf); + bool casesensitive = Config->GetModule("botserv")->Get("casesensitive"); for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i) { const BadWord *bw = ci->GetBadWord(i); - if (bw->type == BW_ANY && ((Config->BSCaseSensitive && nbuf.find(bw->word) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(bw->word) != Anope::string::npos))) + if (bw->type == BW_ANY && ((casesensitive && nbuf.find(bw->word) != Anope::string::npos) || (!casesensitive && nbuf.find_ci(bw->word) != Anope::string::npos))) mustkick = true; else if (bw->type == BW_SINGLE) { size_t len = bw->word.length(); - if ((Config->BSCaseSensitive && bw->word.equals_cs(nbuf)) || (!Config->BSCaseSensitive && bw->word.equals_ci(nbuf))) + if ((casesensitive && bw->word.equals_cs(nbuf)) || (!casesensitive && bw->word.equals_ci(nbuf))) mustkick = true; - else if (nbuf.find(' ') == len && ((Config->BSCaseSensitive && bw->word.equals_cs(nbuf)) || (!Config->BSCaseSensitive && bw->word.equals_ci(nbuf)))) + else if (nbuf.find(' ') == len && ((casesensitive && bw->word.equals_cs(nbuf)) || (!casesensitive && bw->word.equals_ci(nbuf)))) mustkick = true; else { - if (nbuf.rfind(' ') == nbuf.length() - len - 1 && ((Config->BSCaseSensitive && nbuf.find(bw->word) == nbuf.length() - len) || (!Config->BSCaseSensitive && nbuf.find_ci(bw->word) == nbuf.length() - len))) + if (nbuf.rfind(' ') == nbuf.length() - len - 1 && ((casesensitive && nbuf.find(bw->word) == nbuf.length() - len) || (!casesensitive && nbuf.find_ci(bw->word) == nbuf.length() - len))) mustkick = true; else { Anope::string wordbuf = " " + bw->word + " "; - if ((Config->BSCaseSensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(wordbuf) != Anope::string::npos)) + if ((casesensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!casesensitive && nbuf.find_ci(wordbuf) != Anope::string::npos)) mustkick = true; } } @@ -952,13 +958,13 @@ class BSKick : public Module { size_t len = bw->word.length(); - if ((Config->BSCaseSensitive && nbuf.substr(0, len).equals_cs(bw->word)) || (!Config->BSCaseSensitive && nbuf.substr(0, len).equals_ci(bw->word))) + if ((casesensitive && nbuf.substr(0, len).equals_cs(bw->word)) || (!casesensitive && nbuf.substr(0, len).equals_ci(bw->word))) mustkick = true; else { Anope::string wordbuf = " " + bw->word; - if ((Config->BSCaseSensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(wordbuf) != Anope::string::npos)) + if ((casesensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!casesensitive && nbuf.find_ci(wordbuf) != Anope::string::npos)) mustkick = true; } } @@ -966,13 +972,13 @@ class BSKick : public Module { size_t len = bw->word.length(); - if ((Config->BSCaseSensitive && nbuf.substr(nbuf.length() - len).equals_cs(bw->word)) || (!Config->BSCaseSensitive && nbuf.substr(nbuf.length() - len).equals_ci(bw->word))) + if ((casesensitive && nbuf.substr(nbuf.length() - len).equals_cs(bw->word)) || (!casesensitive && nbuf.substr(nbuf.length() - len).equals_ci(bw->word))) mustkick = true; else { Anope::string wordbuf = bw->word + " "; - if ((Config->BSCaseSensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(wordbuf) != Anope::string::npos)) + if ((casesensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!casesensitive && nbuf.find_ci(wordbuf) != Anope::string::npos)) mustkick = true; } } @@ -980,7 +986,7 @@ class BSKick : public Module if (mustkick) { check_ban(ci, u, TTB_BADWORDS); - if (Config->BSGentleBWReason) + if (Config->GetModule(me)->Get("gentlebadwordreason")) bot_kick(ci, u, _("Watch your language!")); else bot_kick(ci, u, _("Don't use the word \"%s\" on this channel!"), bw->word.c_str()); diff --git a/modules/commands/bs_set.cpp b/modules/commands/bs_set.cpp index 6d764c665..20a53faf3 100644 --- a/modules/commands/bs_set.cpp +++ b/modules/commands/bs_set.cpp @@ -48,7 +48,7 @@ class CommandBSSet : public Command } } source.Reply(_("Type \002%s%s HELP %s \037option\037\002 for more information on a\n" - "particular option."), Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str(), this_name.c_str()); + "particular option."), Config->StrictPrivmsg.c_str(), source.service->nick.c_str(), this_name.c_str()); return true; } @@ -309,13 +309,13 @@ class CommandBSSetFantasy : public Command source.Reply(_(" \n" "Enables or disables \002fantasy\002 mode on a channel.\n" "When it is enabled, users will be able to use\n" - "%s commands on a channel when prefixed\n" + "fantasy commands on a channel when prefixed\n" "with one of the following fantasy characters: \002%s\002\n" " \n" "Note that users wanting to use fantaisist\n" "commands MUST have enough access for both\n" "the FANTASIA and the command they are executing."), - Config->ChanServ.c_str(), Config->BSFantasyCharacter.c_str()); + Config->GetModule("botserv")->Get("fantasycharacter", "!")); return true; } }; @@ -495,7 +495,6 @@ class BSSet : public Module commandbsset(this), commandbssetbanexpire(this), commandbssetdontkickops(this), commandbssetdontkickvoices(this), commandbssetfantasy(this), commandbssetgreet(this), commandbssetnobot(this), commandbssetprivate(this) { - ModuleManager::Attach(I_OnBotBan, this); } diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index 90e17eeed..de434337b 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -158,9 +158,10 @@ class CommandCSAccess : public Command } } - if (ci->GetAccessCount() >= Config->CSAccessMax) + unsigned access_max = Config->GetModule("chanserv")->Get("accessmax", "1024"); + if (access_max && ci->GetAccessCount() >= access_max) { - source.Reply(_("Sorry, you can only have %d access entries on a channel."), Config->CSAccessMax); + source.Reply(_("Sorry, you can only have %d access entries on a channel."), access_max); return; } @@ -555,7 +556,7 @@ class CommandCSAccess : public Command source.Reply(" "); source.Reply(_("\002User access levels\002 can be seen by using the\n" "\002LEVELS\002 command; type \002%s%s HELP LEVELS\002 for\n" - "information."), source.service->nick.c_str(), Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str()); + "information."), source.service->nick.c_str(), Config->StrictPrivmsg.c_str(), source.service->nick.c_str()); return true; } }; @@ -590,7 +591,7 @@ class CommandCSLevels : public Command { Privilege *p = PrivilegeManager::FindPrivilege(what); if (p == NULL) - source.Reply(_("Setting \002%s\002 not known. Type \002%s%s HELP LEVELS\002 for a list of valid settings."), what.c_str(), Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str()); + source.Reply(_("Setting \002%s\002 not known. Type \002%s%s HELP LEVELS\002 for a list of valid settings."), what.c_str(), Config->StrictPrivmsg.c_str(), source.service->nick.c_str()); else { ci->SetLevel(p->name, level); @@ -628,7 +629,7 @@ class CommandCSLevels : public Command } } - source.Reply(_("Setting \002%s\002 not known. Type \002%s%s HELP LEVELS\002 for a list of valid settings."), what.c_str(), Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str()); + source.Reply(_("Setting \002%s\002 not known. Type \002%s%s HELP LEVELS\002 for a list of valid settings."), what.c_str(), Config->StrictPrivmsg.c_str(), source.service->nick.c_str()); return; } @@ -792,19 +793,21 @@ class CSAccess : public Module ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { defaultLevels.clear(); - for (int i = 0; i < reader.Enumerate("privilege"); ++i) + for (int i = 0; i < conf->CountBlock("privilege"); ++i) { - const Anope::string &pname = reader.ReadValue("privilege", "name", "", i); + Configuration::Block *priv = conf->GetBlock("privilege", i); + + const Anope::string &pname = priv->Get("name"); Privilege *p = PrivilegeManager::FindPrivilege(pname); if (p == NULL) continue; - const Anope::string &value = reader.ReadValue("privilege", "level", "", i); + const Anope::string &value = priv->Get("level"); if (value.empty()) continue; else if (value.equals_ci("founder")) @@ -812,7 +815,7 @@ class CSAccess : public Module else if (value.equals_ci("disabled")) defaultLevels[p->name] = ACCESS_INVALID; else - defaultLevels[p->name] = reader.ReadInteger("privilege", "level", i, false); + defaultLevels[p->name] = priv->Get("level"); } } diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index b2b1c7579..bb1e6ecd6 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -23,8 +23,9 @@ class CommandCSAKick : public Command NickCore *nc = NULL; const AutoKick *akick; - if (reason.length() > Config->CSReasonMax) - reason = reason.substr(0, Config->CSReasonMax); + unsigned reasonmax = Config->GetModule("chanserv")->Get("reasonmax", "200"); + if (reason.length() > reasonmax) + reason = reason.substr(0, reasonmax); if (IRCD->IsExtbanValid(mask)) ; /* If this is an extban don't try to complete the mask */ @@ -148,9 +149,9 @@ class CommandCSAKick : public Command } } - if (ci->GetAkickCount() >= Config->CSAutokickMax) + if (ci->GetAkickCount() >= Config->GetModule(this->owner)->Get("autokickmax")) { - source.Reply(_("Sorry, you can only have %d autokick masks on a channel."), Config->CSAutokickMax); + source.Reply(_("Sorry, you can only have %d autokick masks on a channel."), Config->GetModule(this->owner)->Get("autokickmax")); return; } @@ -513,7 +514,6 @@ class CSAKick : public Module CSAKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcsakick(this) { - Implementation i[] = { I_OnCheckKick }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } @@ -544,7 +544,11 @@ class CSAKick : public Module autokick->last_used = Anope::CurTime; if (!autokick->nc && autokick->mask.find('#') == Anope::string::npos) mask = autokick->mask; - reason = autokick->reason.empty() ? Config->CSAutokickReason : autokick->reason; + reason = autokick->reason; + if (reason.empty()) + reason = Config->GetModule(this)->Get("autokickreason"); + if (reason.empty()) + reason = "User has been banned from the channel"; return EVENT_STOP; } } diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp index 7d441f14d..c3fffecd9 100644 --- a/modules/commands/cs_ban.cpp +++ b/modules/commands/cs_ban.cpp @@ -91,8 +91,9 @@ class CommandCSBan : public Command reason += " " + params[3]; } - if (reason.length() > Config->CSReasonMax) - reason = reason.substr(0, Config->CSReasonMax); + unsigned reasonmax = Config->GetModule("chanserv")->Get("reasonmax", "200"); + if (reason.length() > reasonmax) + reason = reason.substr(0, reasonmax); User *u = source.GetUser(); User *u2 = User::Find(target, true); diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp index da8c82647..e4c1ac7f6 100644 --- a/modules/commands/cs_clone.cpp +++ b/modules/commands/cs_clone.cpp @@ -64,31 +64,25 @@ public: target_ci->name = target; (*RegisteredChannelList)[target_ci->name] = target_ci; target_ci->c = Channel::Find(target_ci->name); + + target_ci->bi = NULL; + if (ci->bi) + ci->bi->Assign(u, target_ci); + if (target_ci->c) { target_ci->c->ci = target_ci; target_ci->c->CheckModes(); - ChannelMode *cm; - if (u && u->FindChannel(target_ci->c) != NULL) - { - /* On most ircds you do not receive the admin/owner mode till its registered */ - if ((cm = ModeManager::FindChannelModeByName("OWNER"))) - target_ci->c->SetMode(NULL, cm, u->GetUID()); - else if ((cm = ModeManager::FindChannelModeByName("PROTECT"))) - target_ci->c->RemoveMode(NULL, cm, u->GetUID()); - } + target_ci->c->SetCorrectModes(u, true, true); /* Mark the channel as persistent */ if (target_ci->c->HasMode("PERM")) target_ci->ExtendMetadata("PERSIST"); /* Persist may be in def cflags, set it here */ - else if (target_ci->HasExt("PERSIST") && (cm = ModeManager::FindChannelModeByName("PERM"))) - target_ci->c->SetMode(NULL, cm); - - if (target_ci->bi && target_ci->c->FindUser(target_ci->bi) == NULL) - target_ci->bi->Join(target_ci->c, &ModeManager::DefaultBotModes); + else if (target_ci->HasExt("PERSIST")) + target_ci->c->SetMode(NULL, "PERM"); } if (target_ci->c && !target_ci->c->topic.empty()) diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index 961cf1895..da764d81c 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -39,8 +39,6 @@ struct EntryMsg : Serializable static Serializable* Unserialize(Serializable *obj, Serialize::Data &data); }; -static unsigned MaxEntries = 0; - struct EntryMessageList : Serialize::Checker >, ExtensibleItem { EntryMessageList() : Serialize::Checker >("EntryMsg") { } @@ -140,7 +138,7 @@ class CommandEntryMessage : public Command ci->Extend("cs_entrymsg", messages); } - if (MaxEntries && (*messages)->size() >= MaxEntries) + if ((*messages)->size() >= Config->GetModule(this->owner)->Get("maxentries")) source.Reply(_("The entry message list for \002%s\002 is full."), ci->name.c_str()); else { @@ -276,7 +274,7 @@ class CSEntryMessage : public Module CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), entrymsg_type("EntryMsg", EntryMsg::Unserialize), commandentrymsg(this) { - Implementation i[] = { I_OnReload, I_OnJoinChannel }; + Implementation i[] = { I_OnJoinChannel }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } @@ -291,11 +289,6 @@ class CSEntryMessage : public Module u->SendMessage(c->ci->WhoSends(), "[%s] %s", c->ci->name.c_str(), (*messages)->at(i)->message.c_str()); } } - - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override - { - MaxEntries = reader.ReadInteger("cs_entrymsg", "maxentries", "5", 0, true); - } }; MODULE_INIT(CSEntryMessage) diff --git a/modules/commands/cs_fantasy_stats.cpp b/modules/commands/cs_fantasy_stats.cpp index df24710a0..7709a38d3 100644 --- a/modules/commands/cs_fantasy_stats.cpp +++ b/modules/commands/cs_fantasy_stats.cpp @@ -77,11 +77,12 @@ class CSStats : public Module ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { - prefix = reader.ReadValue("chanstats", "prefix", "anope_", 0); - Anope::string engine = reader.ReadValue("chanstats", "engine", "", 0); - this->sql = ServiceReference("SQL::Provider", engine); + prefix = conf->GetModule(this)->Get("prefix"); + if (prefix.empty()) + prefix = "anope_"; + this->sql = ServiceReference("SQL::Provider", conf->GetModule(this)->Get("engine")); } SQL::Result RunQuery(const SQL::Query &query) diff --git a/modules/commands/cs_fantasy_top.cpp b/modules/commands/cs_fantasy_top.cpp index 9baceeda3..ef87cd87f 100644 --- a/modules/commands/cs_fantasy_top.cpp +++ b/modules/commands/cs_fantasy_top.cpp @@ -102,11 +102,12 @@ class CSTop : public Module ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { - prefix = reader.ReadValue("chanstats", "prefix", "anope_", 0); - Anope::string engine = reader.ReadValue("chanstats", "engine", "", 0); - this->sql = ServiceReference("SQL::Provider", engine); + prefix = conf->GetModule(this)->Get("prefix"); + if (prefix.empty()) + prefix = "anope_"; + this->sql = ServiceReference("SQL::Provider", conf->GetModule(this)->Get("engine")); } SQL::Result RunQuery(const SQL::Query &query) diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index cd1a14e83..8ed4cc8c6 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -13,6 +13,7 @@ #include "module.h" +static ServiceReference chanserv("ChanServService", "ChanServ"); static std::map defaultFlags; class FlagsChanAccess : public ChanAccess @@ -113,9 +114,10 @@ class CommandCSFlags : public Command } } - if (ci->GetAccessCount() >= Config->CSAccessMax) + unsigned access_max = Config->GetModule("chanserv")->Get("accessmax", "1024"); + if (access_max && ci->GetAccessCount() >= access_max) { - source.Reply(_("Sorry, you can only have %d access entries on a channel."), Config->CSAccessMax); + source.Reply(_("Sorry, you can only have %d access entries on a channel."), access_max); return; } @@ -396,19 +398,21 @@ class CSFlags : public Module ModuleManager::Attach(i, this, 1); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { defaultFlags.clear(); - for (int i = 0; i < reader.Enumerate("privilege"); ++i) + for (int i = 0; i < conf->CountBlock("privilege"); ++i) { - const Anope::string &pname = reader.ReadValue("privilege", "name", "", i); + Configuration::Block *priv = conf->GetBlock("privilege", i); + + const Anope::string &pname = priv->Get("name"); Privilege *p = PrivilegeManager::FindPrivilege(pname); if (p == NULL) continue; - const Anope::string &value = reader.ReadValue("privilege", "flag", "", i); + const Anope::string &value = priv->Get("flag"); if (value.empty()) continue; diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp index a686541be..e26dc1970 100644 --- a/modules/commands/cs_info.cpp +++ b/modules/commands/cs_info.cpp @@ -13,6 +13,8 @@ #include "module.h" +static ServiceReference chanserv("ChanServService", "ChanServ"); + class CommandCSInfo : public Command { void CheckOptStr(Anope::string &buf, const Anope::string &opt, const char *str, const ChannelInfo *ci, const NickCore *nc) @@ -102,8 +104,9 @@ class CommandCSInfo : public Command if (!ml.empty()) info["Mode lock"] = ml; - if (!ci->HasExt("NO_EXPIRE")) - info["Expires on"] = Anope::strftime(ci->last_used + Config->CSExpire); + time_t chanserv_expire = Config->GetModule("chanserv")->Get("expire", "14d"); + if (!ci->HasExt("NO_EXPIRE") && chanserv_expire && !Anope::NoExpire) + info["Expires on"] = Anope::strftime(ci->last_used + chanserv_expire); } if (ci->HasExt("SUSPENDED")) { diff --git a/modules/commands/cs_kick.cpp b/modules/commands/cs_kick.cpp index d7251ec6b..f1a632af3 100644 --- a/modules/commands/cs_kick.cpp +++ b/modules/commands/cs_kick.cpp @@ -13,6 +13,8 @@ #include "module.h" +static ServiceReference chanserv("ChanServService", "ChanServ"); + class CommandCSKick : public Command { public: @@ -45,8 +47,9 @@ class CommandCSKick : public Command return; } - if (reason.length() > Config->CSReasonMax) - reason = reason.substr(0, Config->CSReasonMax); + unsigned reasonmax = Config->GetModule("chanserv")->Get("reasonmax", "200"); + if (reason.length() > reasonmax) + reason = reason.substr(0, reasonmax); AccessGroup u_access = source.AccessFor(ci); diff --git a/modules/commands/cs_list.cpp b/modules/commands/cs_list.cpp index 72f3e35dc..5d0f16f60 100644 --- a/modules/commands/cs_list.cpp +++ b/modules/commands/cs_list.cpp @@ -68,6 +68,7 @@ class CommandCSList : public Command } Anope::string spattern = "#" + pattern; + unsigned listmax = Config->GetModule(this->owner)->Get("listmax"); source.Reply(_("List of entries matching \002%s\002:"), pattern.c_str()); @@ -91,7 +92,7 @@ class CommandCSList : public Command if (pattern.equals_ci(ci->name) || ci->name.equals_ci(spattern) || Anope::Match(ci->name, pattern, false, true) || Anope::Match(ci->name, spattern, false, true)) { - if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nchans <= Config->CSListMax) + if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nchans <= listmax) { bool isnoexpire = false; if (is_servadmin && (ci->HasExt("NO_EXPIRE"))) @@ -115,7 +116,7 @@ class CommandCSList : public Command for (unsigned i = 0; i < replies.size(); ++i) source.Reply(replies[i]); - source.Reply(_("End of list - %d/%d matches shown."), nchans > Config->CSListMax ? Config->CSListMax : nchans, nchans); + source.Reply(_("End of list - %d/%d matches shown."), nchans > listmax ? listmax : nchans, nchans); return; } @@ -150,11 +151,11 @@ class CommandCSList : public Command " \002LIST #51-100\002\n" " Lists all registered channels within the given range (51-100).")); - if (!Config->RegexEngine.empty()) + if (!Config->GetBlock("options")->Get("regexengine").empty()) { source.Reply(" "); source.Reply(_("Regex matches are also supported using the %s engine.\n" - "Enclose your pattern in // if this is desired."), Config->RegexEngine.c_str()); + "Enclose your pattern in // if this is desired."), Config->GetBlock("options")->Get("regexengine")); } return true; @@ -168,7 +169,6 @@ class CSList : public Module public: CSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcslist(this) { - } }; diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index f1d700cfa..38390251b 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -391,7 +391,7 @@ class CommandCSMode : public Command new_params.push_back("-*"); this->DoSet(source, ci, new_params); } - else if (param.equals_ci("BANS") || param.equals_ci("EXCEPTS") || param.equals_ci("INVITEOVERRIDES") || param.equals_ci("VOICES") || param.equals_ci("HALFOPS") || param.equals_ci("OPS")) + else if (param.equals_ci("BANS") || param.equals_ci("EXEMPTS") || param.equals_ci("INVITEOVERRIDES") || param.equals_ci("VOICES") || param.equals_ci("HALFOPS") || param.equals_ci("OPS")) { const Anope::string &mname = param.upper().substr(0, param.length() - 1); ChannelMode *cm = ModeManager::FindChannelModeByName(mname); diff --git a/modules/commands/cs_register.cpp b/modules/commands/cs_register.cpp index 5f31d823c..feeb605bc 100644 --- a/modules/commands/cs_register.cpp +++ b/modules/commands/cs_register.cpp @@ -26,6 +26,7 @@ class CommandCSRegister : public Command { const Anope::string &chan = params[0]; const Anope::string &chdesc = params.size() > 1 ? params[1] : ""; + unsigned maxregistered = Config->GetModule("chanserv")->Get("maxregistered"); User *u = source.GetUser(); NickCore *nc = source.nc; @@ -48,19 +49,14 @@ class CommandCSRegister : public Command source.Reply(_("Channel \002%s\002 is already registered!"), chan.c_str()); else if (c && !c->HasUserStatus(u, "OP")) source.Reply(_("You must be a channel operator to register the channel.")); - else if (Config->CSMaxReg && nc->channelcount >= Config->CSMaxReg && !source.HasPriv("chanserv/no-register-limit")) - source.Reply(nc->channelcount > Config->CSMaxReg ? CHAN_EXCEEDED_CHANNEL_LIMIT : CHAN_REACHED_CHANNEL_LIMIT, Config->CSMaxReg); + else if (maxregistered && nc->channelcount >= maxregistered && !source.HasPriv("chanserv/no-register-limit")) + source.Reply(nc->channelcount > maxregistered ? CHAN_EXCEEDED_CHANNEL_LIMIT : CHAN_REACHED_CHANNEL_LIMIT, maxregistered); else { ci = new ChannelInfo(chan); ci->SetFounder(nc); ci->desc = chdesc; - for (std::list >::const_iterator it = ModeManager::ModeLockOn.begin(), it_end = ModeManager::ModeLockOn.end(); it != it_end; ++it) - ci->SetMLock(ModeManager::FindChannelModeByName(it->first), true, it->second, source.GetNick()); - for (std::list::const_iterator it = ModeManager::ModeLockOff.begin(), it_end = ModeManager::ModeLockOff.end(); it != it_end; ++it) - ci->SetMLock(ModeManager::FindChannelModeByName(*it), false, "", source.GetNick()); - if (c && !c->topic.empty()) { ci->last_topic = c->topic; @@ -113,9 +109,8 @@ class CommandCSRegister : public Command "other channel users.\n" " \n" "NOTICE: In order to register a channel, you must have\n" - "first registered your nickname. If you haven't,\n" - "\002%s%s HELP\002 for information on how to do so."), - source.service->nick.c_str(), source.service->nick.c_str(), Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->NickServ.c_str()); + "first registered your nickname."), + source.service->nick.c_str(), source.service->nick.c_str(), Config->StrictPrivmsg.c_str(), source.service->nick.c_str()); return true; } }; diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index 2d45f9a15..610ad4475 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -82,9 +82,6 @@ struct SeenInfo : Serializable } }; -static time_t purgetime; -static time_t expiretimeout; - static SeenInfo *FindInfo(const Anope::string &nick) { database_map::iterator iter = database.find(nick); @@ -192,9 +189,9 @@ class CommandSeen : public Command { const Anope::string &target = params[0]; - if (target.length() > Config->NickLen) + if (target.length() > Config->GetBlock("networkinfo")->Get("nicklen")) { - source.Reply(_("Nick too long, max length is %u characters."), Config->NickLen); + source.Reply(_("Nick too long, max length is %u characters."), Config->GetBlock("networkinfo")->Get("nicklen")); return; } @@ -300,7 +297,9 @@ class DataBasePurger : public Timer void Tick(time_t) anope_override { - size_t previous_size = database.size(); + size_t previous_size = database.size(), purgetime = Config->GetModule(this->GetOwner())->Get("purgetime"); + if (!purgetime) + purgetime = Anope::DoTime("30d"); for (database_map::iterator it = database.begin(), it_end = database.end(); it != it_end;) { database_map::iterator cur = it; @@ -333,14 +332,15 @@ class CSSeen : public Module I_OnUserQuit, I_OnJoinChannel, I_OnPartChannel, - I_OnUserKicked }; + I_OnPreUserKicked }; ModuleManager::Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { - purgetime = Anope::DoTime(reader.ReadValue("cs_seen", "purgetime", "30d", 0)); - expiretimeout = Anope::DoTime(reader.ReadValue("cs_seen", "expiretimeout", "1d", 0)); + time_t expiretimeout = conf->GetModule(this)->Get("expiretimeout"); + if (!expiretimeout) + expiretimeout = Anope::DoTime("1d"); if (purger.GetSecs() != expiretimeout) purger.SetSecs(expiretimeout); @@ -373,9 +373,9 @@ class CSSeen : public Module UpdateUser(u, PART, u->nick, "", channel, msg); } - void OnUserKicked(Channel *c, User *target, MessageSource &source, const Anope::string &msg) anope_override + void OnPreUserKicked(MessageSource &source, ChanUserContainer *cu, const Anope::string &msg) anope_override { - UpdateUser(target, KICK, target->nick, source.GetSource(), c->name, msg); + UpdateUser(cu->user, KICK, cu->user->nick, source.GetSource(), cu->chan->name, msg); } private: diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp index 99b3e3ec5..0de1a39ad 100644 --- a/modules/commands/cs_set.cpp +++ b/modules/commands/cs_set.cpp @@ -50,7 +50,7 @@ class CommandCSSet : public Command } } source.Reply(_("Type \002%s%s HELP %s \037option\037\002 for more information on a\n" - "particular option."), Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str(), this_name.c_str()); + "particular option."), Config->StrictPrivmsg.c_str(), source.service->nick.c_str(), this_name.c_str()); return true; } }; @@ -106,8 +106,8 @@ class CommandCSSetAutoOp : public Command source.Reply(" "); source.Reply(_("Enables or disables %s's autoop feature for a\n" "channel. When disabled, users who join the channel will\n" - "not automatically gain any status from %s."), Config->ChanServ.c_str(), - Config->ChanServ.c_str(), this->name.c_str()); + "not automatically gain any status from %s."), ChanServ->nick.c_str(), + ChanServ->nick.c_str(), this->name.c_str()); return true; } }; @@ -319,7 +319,8 @@ class CommandCSSetFounder : public Command } NickCore *nc = na->nc; - if (Config->CSMaxReg && nc->channelcount >= Config->CSMaxReg && !source.HasPriv("chanserv/no-register-limit")) + unsigned max_reg = Config->GetModule("chanserv")->Get("maxregistered"); + if (max_reg && nc->channelcount >= max_reg && !source.HasPriv("chanserv/no-register-limit")) { source.Reply(_("\002%s\002 has too many channels registered."), na->nick.c_str()); return; @@ -552,7 +553,7 @@ class CommandCSSetPersist : public Command /* No channel mode, no BotServ, but using ChanServ as the botserv bot * which was assigned when persist was set on */ - if (!cm && Config->BotServ.empty() && ci->bi) + if (!cm && !BotServ && ci->bi) { if (!ChanServ) { @@ -654,7 +655,7 @@ class CommandCSSetPrivate : public Command source.Reply(_("Enables or disables the \002private\002 option for a channel.\n" "When \002private\002 is set, a \002%s%s LIST\002 will not\n" "include the channel in any lists."), - Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str()); + Config->StrictPrivmsg.c_str(), source.service->nick.c_str()); return true; } }; @@ -1027,10 +1028,12 @@ class CommandCSSetSuccessor : public Command source.Reply(_("Changes the successor of a channel. If the founder's\n" "nickname expires or is dropped while the channel is still\n" "registered, the successor will become the new founder of the\n" - "channel. However, if the successor already has too many\n" + "channel. The new nickname must be a registered one.")); + unsigned max_reg = Config->GetModule("chanserv")->Get("maxregistered"); + if (max_reg) + source.Reply(_("However, if the successor already has too many\n" "channels registered (%d), the channel will be dropped\n" - "instead, just as if no successor had been set. The new\n" - "nickname must be a registered one."), Config->CSMaxReg); + "instead, just as if no successor had been set."), max_reg); return true; } }; @@ -1117,21 +1120,10 @@ class CSSet : public Module commandcssetsuccessor(this), commandcssetnoexpire(this) { - Implementation i[] = { I_OnReload, I_OnChanRegistered, I_OnCheckKick, I_OnDelChan }; + Implementation i[] = { I_OnCheckKick, I_OnDelChan }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override - { - CSDefChanstats = reader.ReadFlag("chanstats", "CSDefChanstats", "0", 0); - } - - void OnChanRegistered(ChannelInfo *ci) anope_override - { - if (CSDefChanstats) - ci->ExtendMetadata("STATS"); - } - EventReturn OnCheckKick(User *u, ChannelInfo *ci, Anope::string &mask, Anope::string &reason) anope_override { if (!ci->HasExt("RESTRICTED") || ci->c->MatchesList(u, "EXCEPT")) diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index e74587be1..325b652cd 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -142,17 +142,19 @@ class CSSetMisc : public Module ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { descriptions.clear(); - for (int i = 0; i < reader.Enumerate("command"); ++i) + for (int i = 0; i < conf->CountBlock("command"); ++i) { - if (reader.ReadValue("command", "command", "", i) != "chanserv/set/misc") + Configuration::Block *block = conf->GetBlock("command", i); + + if (block->Get("command") != "chanserv/set/misc") continue; - Anope::string cname = reader.ReadValue("command", "name", "", i); - Anope::string desc = reader.ReadValue("command", "misc_description", "", i); + Anope::string cname = block->Get("name"); + Anope::string desc = block->Get("misc_description"); if (cname.empty() || desc.empty()) continue; diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index 4927737f6..a26cbacd5 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -27,8 +27,7 @@ class CommandCSSuspend : public Command const Anope::string &chan = params[0]; Anope::string expiry = params.size() > 1 ? params[1] : ""; Anope::string reason = params.size() > 2 ? params[2] : ""; - time_t expiry_secs = Config->CSSuspendExpire; - + time_t expiry_secs = Config->GetModule(this->owner)->Get("expire"); if (!expiry.empty() && expiry[0] != '+') { @@ -39,12 +38,6 @@ class CommandCSSuspend : public Command else expiry_secs = Anope::DoTime(expiry); - if (Config->ForceForbidReason && reason.empty()) - { - this->OnSyntaxError(source, ""); - return; - } - if (Anope::ReadOnly) source.Reply(READ_ONLY_MODE); @@ -172,6 +165,8 @@ class CSSuspend : public Module ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } + // cs info output? + void OnPreChanExpire(ChannelInfo *ci, bool &expire) anope_override { if (!ci->HasExt("SUSPENDED")) diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index 8b6bc4bb7..5d0fe9f21 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -13,6 +13,7 @@ namespace { + ServiceReference chanserv("ChanServService", "ChanServ"); std::vector order; std::map > permissions; } @@ -161,9 +162,10 @@ class CommandCSXOP : public Command } } - if (ci->GetAccessCount() >= Config->CSAccessMax) + unsigned access_max = Config->GetModule("chanserv")->Get("accessmax", "1024"); + if (access_max && ci->GetAccessCount() >= access_max) { - source.Reply(_("Sorry, you can only have %d %s entries on a channel."), Config->CSAccessMax, source.command.c_str()); + source.Reply(_("Sorry, you can only have %d %s entries on a channel."), access_max, source.command.c_str()); return; } @@ -527,8 +529,8 @@ class CommandCSXOP : public Command "available. See \002%s%s HELP ACCESS\002 for information\n" "about the access list, and \002%s%s HELP FLAGS\002 for\n" "information about the flags based system."), - Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str(), - Config->UseStrictPrivMsgString.c_str(), source.service->nick.c_str()); + Config->StrictPrivmsg.c_str(), source.service->nick.c_str(), + Config->StrictPrivmsg.c_str(), source.service->nick.c_str()); return true; } }; @@ -548,31 +550,32 @@ class CSXOP : public Module ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); } - void OnReload(ServerConfig *conf, ConfigReader &reader) anope_override + void OnReload(Configuration::Conf *conf) anope_override { order.clear(); permissions.clear(); - - for (int i = 0; i < reader.Enumerate("privilege"); ++i) + for (int i = 0; i < conf->CountBlock("privilege"); ++i) { - const Anope::string &pname = reader.ReadValue("privilege", "name", "", i); + Configuration::Block *block = conf->GetBlock("privilege", i); + const Anope::string &pname = block->Get("name"); Privilege *p = PrivilegeManager::FindPrivilege(pname); if (p == NULL) continue; - const Anope::string &xop = reader.ReadValue("privilege", "xop", "", i); - if (xop.empty()) + const Anope::string &xop = block->Get("xop"); + if (pname.empty() || xop.empty()) continue; permissions[xop].push_back(pname); } - for (int i = 0; i < reader.Enumerate("command"); ++i) + for (int i = 0; i < conf->CountBlock("command"); ++i) { - const Anope::string &cname = reader.ReadValue("command", "name", "", i), - &cserv = reader.ReadValue("command", "command", "", i); + Configuration::Block *block = conf->GetBlock("command", i); + const Anope::string &cname = block->Get("name"), + &cserv = block->Get("command"); if (cname.empty() || cserv != "chanserv/xop") continue; diff --git a/modules/commands/help.cpp b/modules/commands/help.cpp index a55af89ff..eaf45ebf4 100644 --- a/modules/commands/help.cpp +++ b/modules/commands/help.cpp @@ -46,6 +46,7 @@ class CommandHelp : public Command Anope::string source_command = source.command; const BotInfo *bi = source.service; const CommandInfo::map &map = source.c ? Config->Fantasy : bi->commands; + bool hide_privileged_commands = Config->GetBlock("options")->Get("hideprivilegedcommands"); if (params.empty() || params[0].equals_ci("ALL")) { @@ -73,8 +74,8 @@ class CommandHelp : public Command ServiceReference c("Command", info.name); if (!c) continue; - else if (!Config->HidePrivilegedCommands) - ; // Always show with HidePrivilegedCommands disabled + else if (!hide_privileged_commands) + ; // Always show with hide_privileged_commands disabled else if (!c->AllowUnregistered() && !source.GetAccount()) continue; else if (!info.permission.empty() && !source.HasCommand(info.permission)) @@ -146,8 +147,8 @@ class CommandHelp : public Command ServiceReference c("Command", info.name); if (!c) continue; - else if (!Config->HidePrivilegedCommands) - ; // Always show with HidePrivilegedCommands disabled + else if (!hide_privileged_commands) + ; // Always show with hide_privileged_commands disabled else if (!info.permission.empty() && !source.HasCommand(info.permission)) continue; diff --git a/modules/commands/hs_list.cpp b/modules/commands/hs_list.cpp index 94533e73d..6bf6d49a9 100644 --- a/modules/commands/hs_list.cpp +++ b/modules/commands/hs_list.cpp @@ -55,7 +55,7 @@ class CommandHSList : public Command } } - unsigned display_counter = 0; + unsigned display_counter = 0, listmax = Config->GetModule(this->owner)->Get("listmax"); ListFormatter list; list.AddColumn("Number").AddColumn("Nick").AddColumn("Vhost").AddColumn("Creator").AddColumn("Created"); @@ -68,7 +68,7 @@ class CommandHSList : public Command if (!key.empty() && key[0] != '#') { - if ((Anope::Match(na->nick, key) || Anope::Match(na->GetVhostHost(), key)) && display_counter < Config->NSListMax) + if ((Anope::Match(na->nick, key) || Anope::Match(na->GetVhostHost(), key)) && display_counter < listmax) { ++display_counter; @@ -90,7 +90,7 @@ class CommandHSList : public Command * List the host if its in the display range, and not more * than NSListMax records have been displayed... **/ - if (((counter >= from && counter <= to) || (!from && !to)) && display_counter < Config->NSListMax) + if (((counter >= from && counter <= to) || (!from && !to)) && display_counter < listmax) { ++display_counter; ListFormatter::ListEntry entry; @@ -141,9 +141,7 @@ class CommandHSList : public Command "entries beginning with \"Rob\"\n" "If a \037#X-Y\037 style is used, only entries between the range of \002X\002\n" "and \002Y\002 will be displayed, e.g. \002#1-3\002 will display the first 3\n" - "nick/vhost entries.\n" - "The list uses the value of NSListMax as a hard limit for the\n" - "number of items to display to a operator at any one time.")); + "nick/vhost entries.")); return true; } }; @@ -156,7 +154,6 @@ class HSList : public Module HSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandhslist(this) { - } }; diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index 1e8f2aa82..0c29705ef 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -18,12 +18,9 @@ #include "module.h" #include "memoserv.h" -static ServiceReference MemoServService("MemoServService", "MemoServ"); +static ServiceReference memoserv("MemoServService", "MemoServ"); -static bool HSRequestMemoUser = false; -static bool HSRequestMemoOper = false; - -void req_send_memos(CommandSource &source, const Anope::string &vIdent, const Anope::string &vHost); +static void req_send_memos(Module *me, CommandSource &source, const Anope::string &vIdent, const Anope::string &vHost); struct HostRequest : ExtensibleItem, Serializable { @@ -114,9 +111,9 @@ class CommandHSRequest : public Command if (!user.empty()) { - if (user.length() > Config->UserLen) + if (user.length() > Config->GetBlock("networkinfo")->Get("userlen")) { - source.Reply(HOST_SET_IDENTTOOLONG, Config->UserLen); + source.Reply(HOST_SET_IDENTTOOLONG, Config->GetBlock("networkinfo")->Get("userlen")); return; } else if (!IRCD->CanSetVIdent) @@ -132,9 +129,9 @@ class CommandHSRequest : public Command } } - if (host.length() > Config->HostLen) + if (host.length() > Config->GetBlock("networkinfo")->Get("hostlen")) { - source.Reply(HOST_SET_TOOLONG, Config->HostLen); + source.Reply(HOST_SET_TOOLONG, Config->GetBlock("networkinfo")->Get("hostlen")); return; } @@ -144,14 +141,14 @@ class CommandHSRequest : public Command return; } - if (HSRequestMemoOper && Config->MSSendDelay > 0 && u && u->lastmemosend + Config->MSSendDelay > Anope::CurTime) + time_t send_delay = Config->GetModule("memoserv")->Get("senddelay"); + if (Config->GetModule(this->owner)->Get("memooper") && send_delay > 0 && u && u->lastmemosend + send_delay > Anope::CurTime) { - source.Reply(_("Please wait %d seconds before requesting a new vHost."), Config->MSSendDelay); + source.Reply(_("Please wait %d seconds before requesting a new vHost."), send_delay); u->lastmemosend = Anope::CurTime; return; } - HostRequest *req = new HostRequest; req->nick = source.GetNick(); req->ident = user; @@ -160,10 +157,8 @@ class CommandHSRequest : public Command na->Extend("hs_request", req); source.Reply(_("Your vHost has been requested.")); - req_send_memos(source, user, host); + req_send_memos(owner, source, user, host); Log(LOG_COMMAND, source, this) << "to request new vhost " << (!user.empty() ? user + "@" : "") << host; - - return; } bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override @@ -198,8 +193,8 @@ class CommandHSActivate : public Command na->SetVhost(req->ident, req->host, source.GetNick(), req->time); FOREACH_MOD(I_OnSetVhost, OnSetVhost(na)); - if (HSRequestMemoUser && MemoServService) - MemoServService->Send(Config->HostServ, na->nick, _("[auto memo] Your requested vHost has been approved."), true); + if (Config->GetModule(this->owner)->Get("memouser") && memoserv) + memoserv->Send(HostServ->nick, na->nick, _("[auto memo] Your requested vHost has been approved."), true); source.Reply(_("vHost for %s has been activated."), na->nick.c_str()); Log(LOG_COMMAND, source, this) << "for " << na->nick << " for vhost " << (!req->ident.empty() ? req->ident + "@" : "") << req->host; @@ -214,7 +209,7 @@ class CommandHSActivate : public Command this->SendSyntax(source); source.Reply(" "); source.Reply(_("Activate the requested vHost for the given nick.")); - if (HSRequestMemoUser) + if (Config->GetModule(this->owner)->Get("memouser")) source.Reply(_("A memo informing the user will also be sent.")); return true; @@ -242,7 +237,7 @@ class CommandHSReject : public Command { na->Shrink("hs_request"); - if (HSRequestMemoUser && MemoServService) + if (Config->GetModule(this->owner)->Get("memouser") && memoserv) { Anope::string message; if (!reason.empty()) @@ -250,7 +245,7 @@ class CommandHSReject : public Command else message = _("[auto memo] Your requested vHost has been rejected."); - MemoServService->Send(Config->HostServ, nick, message, true); + memoserv->Send(HostServ->nick, nick, message, true); } source.Reply(_("vHost for %s has been rejected."), nick.c_str()); @@ -267,7 +262,7 @@ class CommandHSReject : public Command this->SendSyntax(source); source.Reply(" "); source.Reply(_("Reject the requested vHost for the given nick.")); - if (HSRequestMemoUser) + if (Config->GetModule(this->owner)->Get("memouser")) source.Reply(_("A memo informing the user will also be sent.")); return true; @@ -280,7 +275,7 @@ class CommandHSWaiting : public Command { int counter = 1; int from = 0, to = 0; - unsigned display_counter = 0; + unsigned display_counter = 0, listmax = Config->GetModule(this->owner)->Get("listmax"); ListFormatter list; list.AddColumn("Number").AddColumn("Nick").AddColumn("Vhost").AddColumn("Created"); @@ -292,7 +287,7 @@ class CommandHSWaiting : public Command if (!hr) continue; - if (((counter >= from && counter <= to) || (!from && !to)) && display_counter < Config->NSListMax) + if (((counter >= from && counter <= to) || (!from && !to)) && display_counter < listmax) { ++display_counter; @@ -353,9 +348,6 @@ class HSReq