From 26ac315192e0d8a04d50e910697ab794eedf0cc1 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 20 Apr 2014 14:35:14 -0400 Subject: New event system --- modules/bs_autoassign.cpp | 2 + modules/commands/bs_assign.cpp | 13 +++-- modules/commands/bs_badwords.cpp | 15 ++++-- modules/commands/bs_bot.cpp | 22 ++++---- modules/commands/bs_botlist.cpp | 4 +- modules/commands/bs_control.cpp | 4 +- modules/commands/bs_info.cpp | 15 ++++-- modules/commands/bs_kick.cpp | 45 +++++++++++----- modules/commands/bs_set.cpp | 10 ++-- modules/commands/cs_access.cpp | 32 +++++++---- modules/commands/cs_akick.cpp | 23 +++++--- modules/commands/cs_ban.cpp | 3 +- modules/commands/cs_clone.cpp | 5 +- modules/commands/cs_drop.cpp | 13 +++-- modules/commands/cs_enforce.cpp | 4 +- modules/commands/cs_entrymsg.cpp | 9 ++-- modules/commands/cs_flags.cpp | 11 ++-- modules/commands/cs_getkey.cpp | 3 +- modules/commands/cs_info.cpp | 13 +++-- modules/commands/cs_invite.cpp | 3 +- modules/commands/cs_kick.cpp | 3 +- modules/commands/cs_list.cpp | 13 +++-- modules/commands/cs_log.cpp | 19 ++++--- modules/commands/cs_mode.cpp | 27 +++++++--- modules/commands/cs_register.cpp | 6 +-- modules/commands/cs_seen.cpp | 20 ++++++- modules/commands/cs_set.cpp | 94 ++++++++++++++++++++++++--------- modules/commands/cs_set_misc.cpp | 11 ++-- modules/commands/cs_status.cpp | 3 +- modules/commands/cs_suspend.cpp | 36 +++++++++---- modules/commands/cs_sync.cpp | 5 +- modules/commands/cs_topic.cpp | 21 ++++++-- modules/commands/cs_unban.cpp | 4 +- modules/commands/cs_updown.cpp | 5 +- modules/commands/cs_xop.cpp | 13 ++--- modules/commands/gl_global.cpp | 20 +++---- modules/commands/greet.cpp | 23 +++++--- modules/commands/help.cpp | 18 ++++--- modules/commands/hs_del.cpp | 20 ++++--- modules/commands/hs_group.cpp | 11 ++-- modules/commands/hs_list.cpp | 4 +- modules/commands/hs_off.cpp | 4 +- modules/commands/hs_on.cpp | 4 +- modules/commands/hs_request.cpp | 27 +++++----- modules/commands/hs_set.cpp | 8 +-- modules/commands/ms_cancel.cpp | 8 +-- modules/commands/ms_check.cpp | 4 +- modules/commands/ms_del.cpp | 14 +++-- modules/commands/ms_ignore.cpp | 4 +- modules/commands/ms_info.cpp | 4 +- modules/commands/ms_list.cpp | 4 +- modules/commands/ms_read.cpp | 11 ++-- modules/commands/ms_rsend.cpp | 22 ++++---- modules/commands/ms_send.cpp | 24 ++++----- modules/commands/ms_sendall.cpp | 16 +++--- modules/commands/ms_set.cpp | 9 ++-- modules/commands/ms_staff.cpp | 16 +++--- modules/commands/ns_access.cpp | 7 ++- modules/commands/ns_ajoin.cpp | 8 +-- modules/commands/ns_alist.cpp | 4 +- modules/commands/ns_cert.cpp | 23 ++++++-- modules/commands/ns_drop.cpp | 13 +++-- modules/commands/ns_getemail.cpp | 5 +- modules/commands/ns_getpass.cpp | 4 +- modules/commands/ns_group.cpp | 27 ++++++---- modules/commands/ns_identify.cpp | 2 +- modules/commands/ns_info.cpp | 26 ++++++--- modules/commands/ns_list.cpp | 15 ++++-- modules/commands/ns_logout.cpp | 13 +++-- modules/commands/ns_recover.cpp | 22 ++++---- modules/commands/ns_register.cpp | 17 ++++-- modules/commands/ns_resetpass.cpp | 6 ++- modules/commands/ns_set.cpp | 85 +++++++++++++++++++---------- modules/commands/ns_set_misc.cpp | 13 +++-- modules/commands/ns_status.cpp | 4 +- modules/commands/ns_suspend.cpp | 38 +++++++++---- modules/commands/ns_update.cpp | 13 +++-- modules/commands/os_akill.cpp | 10 ++-- modules/commands/os_chankill.cpp | 4 +- modules/commands/os_config.cpp | 4 +- modules/commands/os_defcon.cpp | 57 ++++++++++++++------ modules/commands/os_dns.cpp | 18 +++++-- modules/commands/os_forbid.cpp | 65 ++++++++++++++--------- modules/commands/os_ignore.cpp | 8 ++- modules/commands/os_info.cpp | 12 ++++- modules/commands/os_jupe.cpp | 4 +- modules/commands/os_kick.cpp | 4 +- modules/commands/os_kill.cpp | 4 +- modules/commands/os_list.cpp | 5 +- modules/commands/os_login.cpp | 8 ++- modules/commands/os_logsearch.cpp | 4 +- modules/commands/os_mode.cpp | 5 +- modules/commands/os_modinfo.cpp | 5 +- modules/commands/os_module.cpp | 6 ++- modules/commands/os_news.cpp | 13 +++-- modules/commands/os_noop.cpp | 7 ++- modules/commands/os_oline.cpp | 4 +- modules/commands/os_oper.cpp | 5 +- modules/commands/os_reload.cpp | 4 +- modules/commands/os_session.cpp | 24 +++++++-- modules/commands/os_set.cpp | 4 +- modules/commands/os_stats.cpp | 5 +- modules/commands/os_sxline.cpp | 8 +-- modules/commands/os_update.cpp | 4 +- modules/cs_statusupdate.cpp | 4 ++ modules/database/db_flatfile.cpp | 15 +++++- modules/database/db_old.cpp | 13 +++-- modules/database/db_redis.cpp | 13 ++++- modules/database/db_sql.cpp | 21 +++++++- modules/database/db_sql_live.cpp | 16 +++++- modules/encryption/enc_bcrypt.cpp | 8 ++- modules/encryption/enc_md5.cpp | 8 ++- modules/encryption/enc_none.cpp | 6 +++ modules/encryption/enc_old.cpp | 8 ++- modules/encryption/enc_sha1.cpp | 8 ++- modules/encryption/enc_sha256.cpp | 8 ++- modules/extra/m_ldap.cpp | 2 + modules/extra/m_ldap_authentication.cpp | 23 +++++--- modules/extra/m_ldap_oper.cpp | 9 +++- modules/extra/m_mysql.cpp | 5 +- modules/extra/m_sasl_dh-aes.cpp | 6 +-- modules/extra/m_sasl_dh-blowfish.cpp | 6 +-- modules/extra/m_sql_authentication.cpp | 7 ++- modules/extra/m_sql_log.cpp | 2 + modules/extra/m_sql_oper.cpp | 4 +- modules/extra/m_sqlite.cpp | 1 + modules/extra/m_ssl_gnutls.cpp | 6 ++- modules/extra/m_ssl_openssl.cpp | 5 +- modules/extra/stats/cs_fantasy_top.cpp | 2 +- modules/extra/stats/m_chanstats.cpp | 4 +- modules/fantasy.cpp | 21 +++++--- modules/m_dns.cpp | 7 ++- modules/m_dnsbl.cpp | 2 + modules/m_helpchan.cpp | 2 + modules/m_httpd.cpp | 5 +- modules/m_proxyscan.cpp | 6 ++- modules/m_redis.cpp | 2 + modules/m_rewrite.cpp | 3 +- modules/m_sasl.cpp | 8 +-- modules/m_xmlrpc.cpp | 5 +- modules/m_xmlrpc_main.cpp | 2 +- modules/ns_maxemail.cpp | 2 + modules/protocol/bahamut.cpp | 39 ++++++++++---- modules/protocol/charybdis.cpp | 60 ++++++++++++++------- modules/protocol/hybrid.cpp | 49 +++++++++++++---- modules/protocol/inspircd20.cpp | 61 +++++++++++++++++---- modules/protocol/ngircd.cpp | 45 ++++++++++++---- modules/protocol/plexus.cpp | 51 ++++++++++++------ modules/protocol/ratbox.cpp | 48 ++++++++++++----- modules/protocol/unreal.cpp | 62 +++++++++++++++++----- modules/pseudoclients/botserv.cpp | 24 ++++++++- modules/pseudoclients/chanserv.cpp | 70 ++++++++++++++++++++---- modules/pseudoclients/global.cpp | 23 ++++++-- modules/pseudoclients/hostserv.cpp | 18 +++++++ modules/pseudoclients/memoserv.cpp | 34 ++++++++++-- modules/pseudoclients/nickserv.cpp | 68 ++++++++++++++++++++---- modules/pseudoclients/operserv.cpp | 54 +++++++++++++------ modules/webcpanel/pages/index.cpp | 2 +- modules/webcpanel/webcpanel.cpp | 33 +++++++++--- 159 files changed, 1744 insertions(+), 722 deletions(-) (limited to 'modules') diff --git a/modules/bs_autoassign.cpp b/modules/bs_autoassign.cpp index f13843648..e7543d646 100644 --- a/modules/bs_autoassign.cpp +++ b/modules/bs_autoassign.cpp @@ -10,9 +10,11 @@ #include "module.h" class BSAutoAssign : public Module + , public EventHook { public: BSAutoAssign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnChanRegistered") { } diff --git a/modules/commands/bs_assign.cpp b/modules/commands/bs_assign.cpp index 3bd00a372..90fb7ed56 100644 --- a/modules/commands/bs_assign.cpp +++ b/modules/commands/bs_assign.cpp @@ -10,6 +10,7 @@ */ #include "module.h" +#include "modules/bs_info.h" class CommandBSAssign : public Command { @@ -203,6 +204,8 @@ class CommandBSSetNoBot : public Command }; class BSAssign : public Module + , public EventHook + , public EventHook { ExtensibleItem nobot; @@ -211,9 +214,13 @@ class BSAssign : public Module CommandBSSetNoBot commandbssetnobot; public: - BSAssign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - nobot(this, "BS_NOBOT"), - commandbsassign(this), commandbsunassign(this), commandbssetnobot(this) + BSAssign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnInvite") + , EventHook("OnBotInfoEvent") + , nobot(this, "BS_NOBOT") + , commandbsassign(this) + , commandbsunassign(this) + , commandbssetnobot(this) { } diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp index 551e89987..082dae0bd 100644 --- a/modules/commands/bs_badwords.cpp +++ b/modules/commands/bs_badwords.cpp @@ -12,6 +12,8 @@ #include "module.h" #include "modules/bs_badwords.h" +static EventHandlers *bwevents; + struct BadWordImpl : BadWord, Serializable { BadWordImpl() : Serializable("BadWord") { } @@ -46,7 +48,7 @@ struct BadWordsImpl : BadWords this->badwords->push_back(bw); - FOREACH_MOD(OnBadWordAdd, (ci, bw)); + (*bwevents)(&Event::BadWordEvents::OnBadWordAdd, ci, bw); return bw; } @@ -71,7 +73,7 @@ struct BadWordsImpl : BadWords if (this->badwords->empty() || index >= this->badwords->size()) return; - FOREACH_MOD(OnBadWordDel, (ci, (*this->badwords)[index])); + (*bwevents)(&Event::BadWordEvents::OnBadWordDel, ci, (*this->badwords)[index]); delete this->badwords->at(index); } @@ -457,11 +459,16 @@ class BSBadwords : public Module CommandBSBadwords commandbsbadwords; ExtensibleItem badwords; Serialize::Type badword_type; + EventHandlers events; public: - BSBadwords(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandbsbadwords(this), badwords(this, "badwords"), badword_type("BadWord", BadWordImpl::Unserialize) + BSBadwords(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandbsbadwords(this) + , badwords(this, "badwords") + , badword_type("BadWord", BadWordImpl::Unserialize) + , events(this, "Badwords") { + bwevents = &events; } }; diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index 46550603d..9aa572f00 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -10,10 +10,14 @@ */ #include "module.h" +#include "modules/bs_bot.h" class CommandBSBot : public Command { - private: + EventHandlers OnBotCreate; + EventHandlers OnBotChange; + EventHandlers OnBotDelete; + void DoAdd(CommandSource &source, const std::vector ¶ms) { const Anope::string &nick = params[1]; @@ -81,8 +85,7 @@ class CommandBSBot : public Command source.Reply(_("%s!%s@%s (%s) added to the bot list."), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str()); - FOREACH_MOD(OnBotCreate, (bi)); - return; + this->OnBotCreate(&Event::BotCreate::OnBotCreate, bi); } void DoChange(CommandSource &source, const std::vector ¶ms) @@ -220,8 +223,7 @@ class CommandBSBot : public Command 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()); Log(LOG_ADMIN, source, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname; - FOREACH_MOD(OnBotChange, (bi)); - return; + this->OnBotChange(&Event::BotChange::OnBotChange, bi); } void DoDel(CommandSource &source, const std::vector ¶ms) @@ -247,16 +249,16 @@ class CommandBSBot : public Command return; } - FOREACH_MOD(OnBotDelete, (bi)); + this->OnBotDelete(&Event::BotDelete::OnBotDelete, bi); Log(LOG_ADMIN, source, this) << "DEL " << bi->nick; source.Reply(_("Bot \002%s\002 has been deleted."), nick.c_str()); delete bi; - return; } + public: - CommandBSBot(Module *creator) : Command(creator, "botserv/bot", 1, 6) + CommandBSBot(Module *creator) : Command(creator, "botserv/bot", 1, 6), OnBotCreate(creator, "OnBotCreate"), OnBotChange(creator, "OnBotChange"), OnBotDelete(creator, "OnBotDelete") { this->SetDesc(_("Maintains network bot list")); this->SetSyntax(_("\002ADD \037nick\037 \037user\037 \037host\037 \037real\037\002")); @@ -367,8 +369,8 @@ class BSBot : public Module CommandBSBot commandbsbot; public: - BSBot(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandbsbot(this) + BSBot(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandbsbot(this) { } diff --git a/modules/commands/bs_botlist.cpp b/modules/commands/bs_botlist.cpp index 2bab21881..2ee130aba 100644 --- a/modules/commands/bs_botlist.cpp +++ b/modules/commands/bs_botlist.cpp @@ -72,8 +72,8 @@ class BSBotList : public Module CommandBSBotList commandbsbotlist; public: - BSBotList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandbsbotlist(this) + BSBotList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandbsbotlist(this) { } diff --git a/modules/commands/bs_control.cpp b/modules/commands/bs_control.cpp index 0843c6150..38745c191 100644 --- a/modules/commands/bs_control.cpp +++ b/modules/commands/bs_control.cpp @@ -136,8 +136,8 @@ class BSControl : public Module CommandBSAct commandbsact; public: - BSControl(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandbssay(this), commandbsact(this) + BSControl(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandbssay(this), commandbsact(this) { } diff --git a/modules/commands/bs_info.cpp b/modules/commands/bs_info.cpp index b04a62c8f..49775a053 100644 --- a/modules/commands/bs_info.cpp +++ b/modules/commands/bs_info.cpp @@ -10,7 +10,9 @@ * * */ + #include "module.h" +#include "modules/bs_info.h" class CommandBSInfo : public Command { @@ -36,8 +38,10 @@ class CommandBSInfo : public Command buffers.push_back(buf); } + EventHandlers &onbotinfo; + public: - CommandBSInfo(Module *creator) : Command(creator, "botserv/info", 1, 1) + CommandBSInfo(Module *creator, EventHandlers &event) : Command(creator, "botserv/info", 1, 1), onbotinfo(event) { this->SetSyntax(_("{\037channel\037 | \037nickname\037}")); } @@ -59,7 +63,7 @@ class CommandBSInfo : public Command info[_("Options")] = bi->oper_only ? _("Private") : _("None"); info[_("Used on")] = stringify(bi->GetChannelCount()) + " channel(s)"; - FOREACH_MOD(OnBotInfo, (source, bi, ci, info)); + this->onbotinfo(&Event::BotInfoEvent::OnBotInfo, source, bi, ci, info); std::vector replies; info.Process(replies); @@ -90,7 +94,7 @@ class CommandBSInfo : public Command Anope::string enabled = Language::Translate(source.nc, _("Enabled")); Anope::string disabled = Language::Translate(source.nc, _("Disabled")); - FOREACH_MOD(OnBotInfo, (source, bi, ci, info)); + this->onbotinfo(&Event::BotInfoEvent::OnBotInfo, source, bi, ci, info); std::vector replies; info.Process(replies); @@ -123,10 +127,11 @@ class CommandBSInfo : public Command class BSInfo : public Module { CommandBSInfo commandbsinfo; + EventHandlers onbotinfo; public: - BSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandbsinfo(this) + BSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandbsinfo(this, onbotinfo), onbotinfo(this, "OnBotInfo") { } diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index 242043105..3a4d78c93 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -14,6 +14,7 @@ #include "module.h" #include "modules/bs_kick.h" #include "modules/bs_badwords.h" +#include "modules/bs_info.h" static Module *me; @@ -998,6 +999,8 @@ class BanDataPurger : public Timer }; class BSKick : public Module + , public EventHook + , public EventHook { ExtensibleItem bandata; ExtensibleItem userdata; @@ -1020,6 +1023,8 @@ class BSKick : public Module BanDataPurger purger; + EventHandlers onbotban; + BanData::Data &GetBanData(User *u, Channel *c) { BanData *bd = bandata.Require(c); @@ -1056,7 +1061,7 @@ class BSKick : public Module Anope::string mask = ci->GetIdealBan(u); ci->c->SetMode(NULL, "BAN", mask); - FOREACH_MOD(OnBotBan, (u, ci, mask)); + this->onbotban(&Event::BotBan::OnBotBan, u, ci, mask); } } @@ -1077,19 +1082,31 @@ class BSKick : public Module } public: - BSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - bandata(this, "bandata"), - userdata(this, "userdata"), - kickerdata(this, "kickerdata"), - - commandbskick(this), - commandbskickamsg(this), commandbskickbadwords(this), commandbskickbolds(this), commandbskickcaps(this), - commandbskickcolors(this), commandbskickflood(this), commandbskickitalics(this), commandbskickrepeat(this), - commandbskickreverse(this), commandbskickunderlines(this), - - commandbssetdontkickops(this), commandbssetdontkickvoices(this), - - purger(this) + BSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnBotInfoEvent") + , EventHook("OnPrivmsg") + , bandata(this, "bandata") + , userdata(this, "userdata") + , kickerdata(this, "kickerdata") + + , commandbskick(this) + , commandbskickamsg(this) + , commandbskickbadwords(this) + , commandbskickbolds(this) + , commandbskickcaps(this) + , commandbskickcolors(this) + , commandbskickflood(this) + , commandbskickitalics(this) + , commandbskickrepeat(this) + , commandbskickreverse(this) + , commandbskickunderlines(this) + + , commandbssetdontkickops(this) + , commandbssetdontkickvoices(this) + + , purger(this) + + , onbotban(this, "OnBotBan") { me = this; diff --git a/modules/commands/bs_set.cpp b/modules/commands/bs_set.cpp index a69ebb8cf..68aaf8d47 100644 --- a/modules/commands/bs_set.cpp +++ b/modules/commands/bs_set.cpp @@ -10,6 +10,7 @@ */ #include "module.h" +#include "modules/bs_kick.h" class CommandBSSet : public Command { @@ -192,15 +193,18 @@ class CommandBSSetPrivate : public Command }; class BSSet : public Module + , public EventHook { CommandBSSet commandbsset; CommandBSSetBanExpire commandbssetbanexpire; CommandBSSetPrivate commandbssetprivate; public: - BSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandbsset(this), commandbssetbanexpire(this), - commandbssetprivate(this) + BSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnBotBan") + , commandbsset(this) + , commandbssetbanexpire(this) + , commandbssetprivate(this) { } diff --git a/modules/commands/cs_access.cpp b/modules/commands/cs_access.cpp index 59e028d6c..3bfbde97d 100644 --- a/modules/commands/cs_access.cpp +++ b/modules/commands/cs_access.cpp @@ -10,6 +10,7 @@ */ #include "module.h" +#include "modules/cs_access.h" static std::map defaultLevels; @@ -212,7 +213,7 @@ class CommandCSAccess : public Command access->created = Anope::CurTime; ci->AddAccess(access); - FOREACH_MOD(OnAccessAdd, (ci, source, access)); + Event::OnAccessAdd(&Event::AccessAdd::OnAccessAdd, ci, source, access); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << " with level " << level; if (p != NULL) @@ -298,7 +299,7 @@ class CommandCSAccess : public Command ci->EraseAccess(Number - 1); - FOREACH_MOD(OnAccessDel, (ci, source, access)); + Event::OnAccessDel(&Event::AccessDel::OnAccessDel, ci, source, access); delete access; } } @@ -324,7 +325,7 @@ class CommandCSAccess : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->mask; ci->EraseAccess(i - 1); - FOREACH_MOD(OnAccessDel, (ci, source, access)); + Event::OnAccessDel(&Event::AccessDel::OnAccessDel, ci, source, access); delete access; } return; @@ -475,7 +476,7 @@ class CommandCSAccess : public Command source.Reply(ACCESS_DENIED); else { - FOREACH_MOD(OnAccessClear, (ci, source)); + Event::OnAccessClear(&Event::AccessClear::OnAccessClear, ci, source); ci->ClearAccess(); @@ -646,7 +647,7 @@ class CommandCSLevels : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to set " << p->name << " to level " << level; ci->SetLevel(p->name, level); - FOREACH_MOD(OnLevelChange, (source, ci, p->name, level)); + this->onlevelchange(&Event::LevelChange::OnLevelChange, source, ci, p->name, level); if (level == ACCESS_FOUNDER) source.Reply(_("Level for %s on channel %s changed to founder only."), p->name.c_str(), ci->name.c_str()); @@ -674,7 +675,7 @@ class CommandCSLevels : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable " << p->name; ci->SetLevel(p->name, ACCESS_INVALID); - FOREACH_MOD(OnLevelChange, (source, ci, p->name, ACCESS_INVALID)); + this->onlevelchange(&Event::LevelChange::OnLevelChange, source, ci, p->name, ACCESS_INVALID); source.Reply(_("\002%s\002 disabled on channel %s."), p->name.c_str(), ci->name.c_str()); return; @@ -723,14 +724,15 @@ class CommandCSLevels : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to reset all levels"; reset_levels(ci); - FOREACH_MOD(OnLevelChange, (source, ci, "ALL", 0)); + this->onlevelchange(&Event::LevelChange::OnLevelChange, source, ci, "ALL", 0); source.Reply(_("Access levels for \002%s\002 reset to defaults."), ci->name.c_str()); - return; } + EventHandlers &onlevelchange; + public: - CommandCSLevels(Module *creator) : Command(creator, "chanserv/levels", 2, 4) + CommandCSLevels(Module *creator, EventHandlers &event) : Command(creator, "chanserv/levels", 2, 4), onlevelchange(event) { this->SetDesc(_("Redefine the meanings of access levels")); this->SetSyntax(_("\037channel\037 SET \037type\037 \037level\037")); @@ -829,14 +831,22 @@ class CommandCSLevels : public Command }; class CSAccess : public Module + , public EventHook + , public EventHook { AccessAccessProvider accessprovider; CommandCSAccess commandcsaccess; CommandCSLevels commandcslevels; + EventHandlers onlevelchange; public: - CSAccess(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - accessprovider(this), commandcsaccess(this), commandcslevels(this) + CSAccess(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnCreateChan") + , EventHook("OnGroupCheckPriv") + , accessprovider(this) + , commandcsaccess(this) + , commandcslevels(this, onlevelchange) + , onlevelchange(this, "OnLevelChange") { this->SetPermanent(true); diff --git a/modules/commands/cs_akick.cpp b/modules/commands/cs_akick.cpp index 1aff37eb5..61bc23181 100644 --- a/modules/commands/cs_akick.cpp +++ b/modules/commands/cs_akick.cpp @@ -10,6 +10,7 @@ */ #include "module.h" +#include "modules/cs_akick.h" class CommandCSAKick : public Command { @@ -160,7 +161,7 @@ class CommandCSAKick : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << (reason == "" ? "" : ": ") << reason; - FOREACH_MOD(OnAkickAdd, (source, ci, akick)); + this->akickevents(&Event::Akick::OnAkickAdd, source, ci, akick); source.Reply(_("\002%s\002 added to %s autokick list."), mask.c_str(), ci->name.c_str()); @@ -185,11 +186,11 @@ class CommandCSAKick : public Command { CommandSource &source; ChannelInfo *ci; - Command *c; + CommandCSAKick *c; unsigned deleted; AccessGroup ag; public: - AkickDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), ag(source.AccessFor(ci)) + AkickDelCallback(CommandSource &_source, ChannelInfo *_ci, CommandCSAKick *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), ag(source.AccessFor(ci)) { } @@ -210,7 +211,7 @@ class CommandCSAKick : public Command const AutoKick *akick = ci->GetAkick(number - 1); - FOREACH_MOD(OnAkickDel, (source, ci, akick)); + c->akickevents(&Event::Akick::OnAkickDel, source, ci, akick); bool override = !ag.HasPriv("AKICK"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << (akick->nc ? akick->nc->display : akick->mask); @@ -244,7 +245,7 @@ class CommandCSAKick : public Command bool override = !source.AccessFor(ci).HasPriv("AKICK"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask; - FOREACH_MOD(OnAkickDel, (source, ci, ci->GetAkick(i))); + this->akickevents(&Event::Akick::OnAkickDel, source, ci, ci->GetAkick(i)); ci->EraseAkick(i); @@ -416,8 +417,10 @@ class CommandCSAKick : public Command source.Reply(_("Channel %s akick list has been cleared."), ci->name.c_str()); } + EventHandlers &akickevents; + public: - CommandCSAKick(Module *creator) : Command(creator, "chanserv/akick", 2, 4) + CommandCSAKick(Module *creator, EventHandlers &events) : Command(creator, "chanserv/akick", 2, 4), akickevents(events) { this->SetDesc(_("Maintain the AutoKick list")); this->SetSyntax(_("\037channel\037 ADD {\037nick\037 | \037mask\037} [\037reason\037]")); @@ -509,12 +512,16 @@ class CommandCSAKick : public Command }; class CSAKick : public Module + , public EventHook { CommandCSAKick commandcsakick; + EventHandlers akickevents; public: - CSAKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandcsakick(this) + CSAKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnCheckKick") + , commandcsakick(this, akickevents) + , akickevents(this, "Akick") { } diff --git a/modules/commands/cs_ban.cpp b/modules/commands/cs_ban.cpp index 3a5e335f1..a6a1f4af6 100644 --- a/modules/commands/cs_ban.cpp +++ b/modules/commands/cs_ban.cpp @@ -217,7 +217,8 @@ class CSBan : public Module CommandCSBan commandcsban; public: - CSBan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcsban(this) + CSBan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandcsban(this) { me = this; } diff --git a/modules/commands/cs_clone.cpp b/modules/commands/cs_clone.cpp index bfe21783b..e7102091a 100644 --- a/modules/commands/cs_clone.cpp +++ b/modules/commands/cs_clone.cpp @@ -100,7 +100,7 @@ public: else target_ci->last_topic_setter = source.service->nick; - FOREACH_MOD(OnChanRegistered, (target_ci)); + Event::OnChanRegistered(&Event::ChanRegistered::OnChanRegistered, target_ci); source.Reply(_("All settings from \002%s\002 have been cloned to \002%s\002."), channel.c_str(), target.c_str()); } @@ -204,7 +204,8 @@ class CSClone : public Module CommandCSClone commandcsclone; public: - CSClone(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcsclone(this) + CSClone(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandcsclone(this) { } diff --git a/modules/commands/cs_drop.cpp b/modules/commands/cs_drop.cpp index 03d24a18d..3b6c82ed0 100644 --- a/modules/commands/cs_drop.cpp +++ b/modules/commands/cs_drop.cpp @@ -10,11 +10,14 @@ */ #include "module.h" +#include "modules/cs_drop.h" class CommandCSDrop : public Command { + EventHandlers &onchandrop; + public: - CommandCSDrop(Module *creator) : Command(creator, "chanserv/drop", 1, 2) + CommandCSDrop(Module *creator, EventHandlers &event) : Command(creator, "chanserv/drop", 1, 2), onchandrop(event) { this->SetDesc(_("Cancel the registration of a channel")); this->SetSyntax(_("\037channel\037 \037channel\037")); @@ -49,8 +52,7 @@ class CommandCSDrop : public Command return; } - EventReturn MOD_RESULT; - FOREACH_RESULT(OnChanDrop, MOD_RESULT, (source, ci)); + EventReturn MOD_RESULT = this->onchandrop(&Event::ChanDrop::OnChanDrop, source, ci); if (MOD_RESULT == EVENT_STOP) return; @@ -84,9 +86,12 @@ class CommandCSDrop : public Command class CSDrop : public Module { CommandCSDrop commandcsdrop; + EventHandlers onchandrop; public: - CSDrop(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcsdrop(this) + CSDrop(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandcsdrop(this, onchandrop) + , onchandrop(this, "OnChanDrop") { } diff --git a/modules/commands/cs_enforce.cpp b/modules/commands/cs_enforce.cpp index 5ea267e6f..aa710ef03 100644 --- a/modules/commands/cs_enforce.cpp +++ b/modules/commands/cs_enforce.cpp @@ -282,8 +282,8 @@ class CSEnforce : public Module CommandCSEnforce commandcsenforce; public: - CSEnforce(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandcsenforce(this) + CSEnforce(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandcsenforce(this) { } diff --git a/modules/commands/cs_entrymsg.cpp b/modules/commands/cs_entrymsg.cpp index d9948a52f..676d7b74a 100644 --- a/modules/commands/cs_entrymsg.cpp +++ b/modules/commands/cs_entrymsg.cpp @@ -258,15 +258,18 @@ class CommandEntryMessage : public Command }; class CSEntryMessage : public Module + , public EventHook { CommandEntryMessage commandentrymsg; ExtensibleItem eml; Serialize::Type entrymsg_type; public: - CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandentrymsg(this), - eml(this, "entrymsg"), entrymsg_type("EntryMsg", EntryMsgImpl::Unserialize) + CSEntryMessage(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnJoinChannel") + , commandentrymsg(this) + , eml(this, "entrymsg") + , entrymsg_type("EntryMsg", EntryMsgImpl::Unserialize) { } diff --git a/modules/commands/cs_flags.cpp b/modules/commands/cs_flags.cpp index b2ade785f..1298f74c5 100644 --- a/modules/commands/cs_flags.cpp +++ b/modules/commands/cs_flags.cpp @@ -244,7 +244,7 @@ class CommandCSFlags : public Command if (current != NULL) { ci->EraseAccess(current_idx - 1); - FOREACH_MOD(OnAccessDel, (ci, source, current)); + Event::OnAccessDel(&Event::AccessDel::OnAccessDel, ci, source, current); delete current; Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask; source.Reply(_("\002%s\002 removed from the %s access list."), mask.c_str(), ci->name.c_str()); @@ -272,7 +272,7 @@ class CommandCSFlags : public Command ci->AddAccess(access); - FOREACH_MOD(OnAccessAdd, (ci, source, access)); + Event::OnAccessAdd(&Event::AccessAdd::OnAccessAdd, ci, source, access); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to modify " << mask << "'s flags to " << access->AccessSerialize(); if (p != NULL) @@ -356,7 +356,7 @@ class CommandCSFlags : public Command { ci->ClearAccess(); - FOREACH_MOD(OnAccessClear, (ci, source)); + Event::OnAccessClear(&Event::AccessClear::OnAccessClear, ci, source); source.Reply(_("Channel %s access list has been cleared."), ci->name.c_str()); @@ -457,8 +457,9 @@ class CSFlags : public Module CommandCSFlags commandcsflags; public: - CSFlags(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - accessprovider(this), commandcsflags(this) + CSFlags(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , accessprovider(this) + , commandcsflags(this) { this->SetPermanent(true); diff --git a/modules/commands/cs_getkey.cpp b/modules/commands/cs_getkey.cpp index 187c01c68..6b714d093 100644 --- a/modules/commands/cs_getkey.cpp +++ b/modules/commands/cs_getkey.cpp @@ -64,7 +64,8 @@ class CSGetKey : public Module CommandCSGetKey commandcsgetkey; public: - CSGetKey(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcsgetkey(this) + CSGetKey(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandcsgetkey(this) { } diff --git a/modules/commands/cs_info.cpp b/modules/commands/cs_info.cpp index 06130f15e..d0ae17a7e 100644 --- a/modules/commands/cs_info.cpp +++ b/modules/commands/cs_info.cpp @@ -10,11 +10,14 @@ */ #include "module.h" +#include "modules/cs_info.h" class CommandCSInfo : public Command { + EventHandlers &eventonchaninfo; + public: - CommandCSInfo(Module *creator) : Command(creator, "chanserv/info", 1, 2) + CommandCSInfo(Module *creator, EventHandlers &event) : Command(creator, "chanserv/info", 1, 2), eventonchaninfo(event) { this->SetDesc(_("Lists information about the named registered channel")); this->SetSyntax(_("\037channel\037")); @@ -60,7 +63,7 @@ class CommandCSInfo : public Command info[_("Ban type")] = stringify(ci->bantype); } - FOREACH_MOD(OnChanInfo, (source, ci, info, show_all)); + this->eventonchaninfo(&Event::ChanInfo::OnChanInfo, source, ci, info, show_all); std::vector replies; info.Process(replies); @@ -86,10 +89,12 @@ class CommandCSInfo : public Command class CSInfo : public Module { CommandCSInfo commandcsinfo; + EventHandlers eventonchaninfo; public: - CSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandcsinfo(this) + CSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandcsinfo(this, eventonchaninfo) + , eventonchaninfo(this, "OnChanInfo") { } diff --git a/modules/commands/cs_invite.cpp b/modules/commands/cs_invite.cpp index 0058f4ee6..6f19042cc 100644 --- a/modules/commands/cs_invite.cpp +++ b/modules/commands/cs_invite.cpp @@ -102,7 +102,8 @@ class CSInvite : public Module CommandCSInvite commandcsinvite; public: - CSInvite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcsinvite(this) + CSInvite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandcsinvite(this) { } diff --git a/modules/commands/cs_kick.cpp b/modules/commands/cs_kick.cpp index 55e0a6718..bfaec6a29 100644 --- a/modules/commands/cs_kick.cpp +++ b/modules/commands/cs_kick.cpp @@ -125,7 +125,8 @@ class CSKick : public Module CommandCSKick commandcskick; public: - CSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcskick(this) + CSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandcskick(this) { } diff --git a/modules/commands/cs_list.cpp b/modules/commands/cs_list.cpp index 735a836de..68cca6d42 100644 --- a/modules/commands/cs_list.cpp +++ b/modules/commands/cs_list.cpp @@ -10,6 +10,8 @@ */ #include "module.h" +#include "modules/cs_info.h" +#include "modules/cs_set.h" class CommandCSList : public Command { @@ -190,8 +192,7 @@ class CommandCSSetPrivate : public Command return; } - EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + EventReturn MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]); if (MOD_RESULT == EVENT_STOP) return; @@ -235,6 +236,7 @@ class CommandCSSetPrivate : public Command }; class CSList : public Module + , public EventHook { CommandCSList commandcslist; CommandCSSetPrivate commandcssetprivate; @@ -242,8 +244,11 @@ class CSList : public Module SerializableExtensibleItem priv; public: - CSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandcslist(this), commandcssetprivate(this), priv(this, "CS_PRIVATE") + CSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnChanInfo") + , commandcslist(this) + , commandcssetprivate(this) + , priv(this, "CS_PRIVATE") { } diff --git a/modules/commands/cs_log.cpp b/modules/commands/cs_log.cpp index 8fb253321..678a2fd5f 100644 --- a/modules/commands/cs_log.cpp +++ b/modules/commands/cs_log.cpp @@ -11,6 +11,7 @@ #include "module.h" #include "modules/cs_log.h" +#include "modules/memoserv.h" struct LogSettingImpl : LogSetting, Serializable { @@ -280,8 +281,9 @@ public: }; class CSLog : public Module + , public EventHook + , public EventHook { - ServiceReference MSService; CommandCSLog commandcslog; ExtensibleItem logsettings; Serialize::Type logsetting_type; @@ -294,9 +296,12 @@ class CSLog : public Module std::vector defaults; public: - CSLog(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - MSService("MemoServService", "MemoServ"), commandcslog(this), - logsettings(this, "logsettings"), logsetting_type("LogSetting", LogSettingImpl::Unserialize) + CSLog(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnChanRegistered") + , EventHook("OnLog") + , commandcslog(this) + , logsettings(this, "logsettings") + , logsetting_type("LogSetting", LogSettingImpl::Unserialize) { } @@ -353,7 +358,7 @@ class CSLog : public Module } } - void OnLog(Log *l) override + void OnLog(::Log *l) override { if (l->type != LOG_COMMAND || l->u == NULL || l->c == NULL || l->ci == NULL || !Me || !Me->IsSynced()) return; @@ -381,8 +386,8 @@ class CSLog : public Module Anope::string buffer = l->u->nick + " used " + l->source->command.upper() + " " + l->buf.str(); - if (log->method.equals_ci("MEMO") && MSService && l->ci->WhoSends() != NULL) - MSService->Send(l->ci->WhoSends()->nick, l->ci->name, buffer, true); + if (log->method.equals_ci("MEMO") && MemoServ::service && l->ci->WhoSends() != NULL) + MemoServ::service->Send(l->ci->WhoSends()->nick, l->ci->name, buffer, true); else if (l->source->c) /* Sending a channel message or notice in response to a fantasy command */; else if (log->method.equals_ci("MESSAGE") && l->ci->c) diff --git a/modules/commands/cs_mode.cpp b/modules/commands/cs_mode.cpp index ed54c5164..2e858b382 100644 --- a/modules/commands/cs_mode.cpp +++ b/modules/commands/cs_mode.cpp @@ -11,6 +11,9 @@ #include "module.h" #include "modules/cs_mode.h" +#include "modules/cs_info.h" + +static EventHandlers *events; struct ModeLockImpl : ModeLock, Serializable { @@ -87,7 +90,7 @@ struct ModeLocksImpl : ModeLocks ml->created = created; EventReturn MOD_RESULT; - FOREACH_RESULT(OnMLock, MOD_RESULT, (this->ci, ml)); + MOD_RESULT = (*events)(&Event::MLockEvents::OnMLock, this->ci, ml); if (MOD_RESULT == EVENT_STOP) { delete ml; @@ -115,7 +118,7 @@ struct ModeLocksImpl : ModeLocks continue; EventReturn MOD_RESULT; - FOREACH_RESULT(OnUnMLock, MOD_RESULT, (this->ci, m)); + MOD_RESULT = (*events)(&Event::MLockEvents::OnUnMLock, this->ci, m); if (MOD_RESULT == EVENT_STOP) break; @@ -863,19 +866,29 @@ class CommandCSModes : public Command }; class CSMode : public Module + , public EventHook + , public EventHook + , public EventHook { CommandCSMode commandcsmode; CommandCSModes commandcsmodes; ExtensibleItem modelocks; Serialize::Type modelocks_type; + EventHandlers modelockevents; + public: - CSMode(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandcsmode(this), commandcsmodes(this), - modelocks(this, "modelocks"), - modelocks_type("ModeLock", ModeLockImpl::Unserialize) + CSMode(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnCheckModes") + , EventHook("OnCreateChan") + , EventHook("OnChanInfo") + , commandcsmode(this) + , commandcsmodes(this) + , modelocks(this, "modelocks") + , modelocks_type("ModeLock", ModeLockImpl::Unserialize) + , modelockevents(this, "MLock") { - + events = &modelockevents; } void OnReload(Configuration::Conf *conf) override diff --git a/modules/commands/cs_register.cpp b/modules/commands/cs_register.cpp index dda906fcd..7b2899939 100644 --- a/modules/commands/cs_register.cpp +++ b/modules/commands/cs_register.cpp @@ -75,7 +75,7 @@ class CommandCSRegister : public Command c->SetCorrectModes(u, true); } - FOREACH_MOD(OnChanRegistered, (ci)); + Event::OnChanRegistered(&Event::ChanRegistered::OnChanRegistered, ci); } } @@ -115,8 +115,8 @@ class CSRegister : public Module CommandCSRegister commandcsregister; public: - CSRegister(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandcsregister(this) + CSRegister(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandcsregister(this) { } }; diff --git a/modules/commands/cs_seen.cpp b/modules/commands/cs_seen.cpp index db0195aa3..595b999c9 100644 --- a/modules/commands/cs_seen.cpp +++ b/modules/commands/cs_seen.cpp @@ -367,12 +367,30 @@ class CommandSeen : public Command }; class CSSeen : public Module + , public EventHook + , public EventHook + , public EventHook + , public EventHook + , public EventHook + , public EventHook + , public EventHook { Serialize::Type seeninfo_type; CommandSeen commandseen; CommandOSSeen commandosseen; + public: - CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), seeninfo_type("SeenInfo", SeenInfo::Unserialize), commandseen(this), commandosseen(this) + CSSeen(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnExpireTick") + , EventHook("OnUserConnect") + , EventHook("OnUserNickChange") + , EventHook("OnUserQuit") + , EventHook("OnJoinChannel") + , EventHook("OnPartChannel") + , EventHook("OnPreUserKicked") + , seeninfo_type("SeenInfo", SeenInfo::Unserialize) + , commandseen(this) + , commandosseen(this) { } diff --git a/modules/commands/cs_set.cpp b/modules/commands/cs_set.cpp index 503941c82..4beb54070 100644 --- a/modules/commands/cs_set.cpp +++ b/modules/commands/cs_set.cpp @@ -11,6 +11,9 @@ #include "module.h" #include "modules/cs_mode.h" +#include "modules/chanserv.h" +#include "modules/cs_info.h" +#include "modules/cs_set.h" class CommandCSSet : public Command { @@ -87,8 +90,7 @@ class CommandCSSetAutoOp : public Command return; } - EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + EventReturn MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]); if (MOD_RESULT == EVENT_STOP) return; @@ -151,7 +153,7 @@ class CommandCSSetBanType : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]); if (MOD_RESULT == EVENT_STOP) return; @@ -219,7 +221,7 @@ class CommandCSSetDescription : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, param)); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, param); if (MOD_RESULT == EVENT_STOP) return; @@ -280,7 +282,7 @@ class CommandCSSetFounder : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]); if (MOD_RESULT == EVENT_STOP) return; @@ -349,7 +351,7 @@ class CommandCSSetKeepModes : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]); if (MOD_RESULT == EVENT_STOP) return; @@ -414,7 +416,7 @@ class CommandCSSetPeace : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]); if (MOD_RESULT == EVENT_STOP) return; @@ -486,7 +488,7 @@ class CommandCSSetPersist : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]); if (MOD_RESULT == EVENT_STOP) return; @@ -649,7 +651,7 @@ class CommandCSSetRestricted : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]); if (MOD_RESULT == EVENT_STOP) return; @@ -711,7 +713,7 @@ class CommandCSSetSecure : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]); if (MOD_RESULT == EVENT_STOP) return; @@ -775,7 +777,7 @@ class CommandCSSetSecureFounder : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]); if (MOD_RESULT == EVENT_STOP) return; @@ -839,7 +841,7 @@ class CommandCSSetSecureOps : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]); if (MOD_RESULT == EVENT_STOP) return; @@ -901,7 +903,7 @@ class CommandCSSetSignKick : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]); if (MOD_RESULT == EVENT_STOP) return; @@ -979,7 +981,7 @@ class CommandCSSetSuccessor : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, param)); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, param); if (MOD_RESULT == EVENT_STOP) return; @@ -1098,6 +1100,18 @@ class CommandCSSetNoexpire : public Command }; class CSSet : public Module + , public EventHook + , public EventHook + , public EventHook + , public EventHook + , public EventHook + , public EventHook + , public EventHook + , public EventHook + , public EventHook + , public EventHook + , public EventHook + , public EventHook { SerializableExtensibleItem noautoop, peace, securefounder, restricted, secure, secureops, signkick, signkick_level, noexpire; @@ -1210,18 +1224,46 @@ class CSSet : public Module bool persist_lower_ts; public: - CSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - noautoop(this, "NOAUTOOP"), peace(this, "PEACE"), - securefounder(this, "SECUREFOUNDER"), restricted(this, "RESTRICTED"), - secure(this, "CS_SECURE"), secureops(this, "SECUREOPS"), signkick(this, "SIGNKICK"), - signkick_level(this, "SIGNKICK_LEVEL"), noexpire(this, "CS_NO_EXPIRE"), - keep_modes(this, "CS_KEEP_MODES"), persist(this, "PERSIST"), - - commandcsset(this), commandcssetautoop(this), commandcssetbantype(this), - commandcssetdescription(this), commandcssetfounder(this), commandcssetkeepmodes(this), - commandcssetpeace(this), commandcssetpersist(this), commandcssetrestricted(this), - commandcssetsecure(this), commandcssetsecurefounder(this), commandcssetsecureops(this), commandcssetsignkick(this), - commandcssetsuccessor(this), commandcssetnoexpire(this) + CSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnCreateChan") + , EventHook("OnChannelCreate") + , EventHook("OnChannelSync") + , EventHook("OnCheckKick") + , EventHook("OnDelChan") + , EventHook("OnChannelModeSet") + , EventHook("OnChannelModeUnset") + , EventHook("OnCheckDelete") + , EventHook("OnJoinChannel") + , EventHook("OnSetCorrectModes") + , EventHook("OnPreChanExpire") + , EventHook("OnChanInfo") + , noautoop(this, "NOAUTOOP") + , peace(this, "PEACE") + , securefounder(this, "SECUREFOUNDER") + , restricted(this, "RESTRICTED") + , secure(this, "CS_SECURE") + , secureops(this, "SECUREOPS") + , signkick(this, "SIGNKICK") + , signkick_level(this, "SIGNKICK_LEVEL") + , noexpire(this, "CS_NO_EXPIRE") + , keep_modes(this, "CS_KEEP_MODES") + , persist(this, "PERSIST") + + , commandcsset(this) + , commandcssetautoop(this) + , commandcssetbantype(this) + , commandcssetdescription(this) + , commandcssetfounder(this) + , commandcssetkeepmodes(this) + , commandcssetpeace(this) + , commandcssetpersist(this) + , commandcssetrestricted(this) + , commandcssetsecure(this) + , commandcssetsecurefounder(this) + , commandcssetsecureops(this) + , commandcssetsignkick(this) + , commandcssetsuccessor(this) + , commandcssetnoexpire(this) { } diff --git a/modules/commands/cs_set_misc.cpp b/modules/commands/cs_set_misc.cpp index 41abd6138..3d8dbb0dd 100644 --- a/modules/commands/cs_set_misc.cpp +++ b/modules/commands/cs_set_misc.cpp @@ -10,6 +10,8 @@ #include "module.h" #include "modules/set_misc.h" +#include "modules/cs_info.h" +#include "modules/cs_set.h" static Module *me; @@ -112,7 +114,7 @@ class CommandCSSetMisc : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, param)); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, param); if (MOD_RESULT == EVENT_STOP) return; @@ -163,13 +165,16 @@ class CommandCSSetMisc : public Command }; class CSSetMisc : public Module + , public EventHook { CommandCSSetMisc commandcssetmisc; Serialize::Type csmiscdata_type; public: - CSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandcssetmisc(this), csmiscdata_type("CSMiscData", CSMiscData::Unserialize) + CSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnChanInfo") + , commandcssetmisc(this) + , csmiscdata_type("CSMiscData", CSMiscData::Unserialize) { me = this; } diff --git a/modules/commands/cs_status.cpp b/modules/commands/cs_status.cpp index 659119d06..bd707d537 100644 --- a/modules/commands/cs_status.cpp +++ b/modules/commands/cs_status.cpp @@ -102,7 +102,8 @@ class CSStatus : public Module CommandCSStatus commandcsstatus; public: - CSStatus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandcsstatus(this) + CSStatus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandcsstatus(this) { } }; diff --git a/modules/commands/cs_suspend.cpp b/modules/commands/cs_suspend.cpp index b7d22ae41..7b604b250 100644 --- a/modules/commands/cs_suspend.cpp +++ b/modules/commands/cs_suspend.cpp @@ -11,6 +11,9 @@ #include "module.h" #include "modules/suspend.h" +#include "modules/cs_drop.h" +#include "modules/chanserv.h" +#include "modules/cs_info.h" struct CSSuspendInfo : SuspendInfo, Serializable { @@ -52,8 +55,9 @@ struct CSSuspendInfo : SuspendInfo, Serializable class CommandCSSuspend : public Command { + EventHandlers &onchansuspend; public: - CommandCSSuspend(Module *creator) : Command(creator, "chanserv/suspend", 2, 3) + CommandCSSuspend(Module *creator, EventHandlers &event) : Command(creator, "chanserv/suspend", 2, 3), onchansuspend(event) { this->SetDesc(_("Prevent a channel from being used preserving channel data and settings")); this->SetSyntax(_("\037channel\037 [+\037expiry\037] [\037reason\037]")); @@ -124,7 +128,7 @@ class CommandCSSuspend : public Command Log(LOG_ADMIN, source, this, ci) << "(" << (!reason.empty() ? reason : "No reason") << "), expires on " << (expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); source.Reply(_("Channel \002%s\002 is now suspended."), ci->name.c_str()); - FOREACH_MOD(OnChanSuspend, (ci)); + this->onchansuspend(&Event::ChanSuspend::OnChanSuspend, ci); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -145,8 +149,10 @@ class CommandCSSuspend : public Command class CommandCSUnSuspend : public Command { + EventHandlers &onchanunsuspend; + public: - CommandCSUnSuspend(Module *creator) : Command(creator, "chanserv/unsuspend", 1, 1) + CommandCSUnSuspend(Module *creator, EventHandlers &event) : Command(creator, "chanserv/unsuspend", 1, 1), onchanunsuspend(event) { this->SetDesc(_("Releases a suspended channel")); this->SetSyntax(_("\037channel\037")); @@ -179,9 +185,7 @@ class CommandCSUnSuspend : public Command source.Reply(_("Channel \002%s\002 is now released."), ci->name.c_str()); - FOREACH_MOD(OnChanUnsuspend, (ci)); - - return; + this->onchanunsuspend(&Event::ChanUnsuspend::OnChanUnsuspend, ci); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -195,16 +199,30 @@ class CommandCSUnSuspend : public Command }; class CSSuspend : public Module + , public EventHook + , public EventHook + , public EventHook + , public EventHook { CommandCSSuspend commandcssuspend; CommandCSUnSuspend commandcsunsuspend; ExtensibleItem suspend; Serialize::Type suspend_type; + EventHandlers onchansuspend; + EventHandlers onchanunsuspend; public: - CSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandcssuspend(this), commandcsunsuspend(this), suspend(this, "CS_SUSPENDED"), - suspend_type("CSSuspendInfo", CSSuspendInfo::Unserialize) + CSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnChanInfo") + , EventHook("OnPreChanExpire") + , EventHook("OnCheckKick") + , EventHook("OnChanDrop") + , commandcssuspend(this, onchansuspend) + , commandcsunsuspend(this, onchanunsuspend) + , suspend(this, "CS_SUSPENDED") + , suspend_type("CSSuspendInfo", CSSuspendInfo::Unserialize) + , onchansuspend(this, "OnChanSuspend") + , onchanunsuspend(this, "OnChanUnsuspend") { } diff --git a/modules/commands/cs_sync.cpp b/modules/commands/cs_sync.cpp index 0251b95be..d26ff6a7a 100644 --- a/modules/commands/cs_sync.cpp +++ b/modules/commands/cs_sync.cpp @@ -55,9 +55,10 @@ class CommandCSSync : public Command class CSSync : public Module { CommandCSSync commandcssync; + public: - CSSync(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandcssync(this) + CSSync(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandcssync(this) { } diff --git a/modules/commands/cs_topic.cpp b/modules/commands/cs_topic.cpp index 9b4752d20..2fd1b0a81 100644 --- a/modules/commands/cs_topic.cpp +++ b/modules/commands/cs_topic.cpp @@ -11,6 +11,8 @@ #include "module.h" #include "modules/cs_mode.h" +#include "modules/cs_info.h" +#include "modules/cs_set.h" class CommandCSSetKeepTopic : public Command { @@ -37,7 +39,7 @@ class CommandCSSetKeepTopic : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, params[1])); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, params[1]); if (MOD_RESULT == EVENT_STOP) return; @@ -89,7 +91,7 @@ class CommandCSTopic : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, "topiclock on")); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, "topiclock on"); if (MOD_RESULT == EVENT_STOP) return; @@ -106,7 +108,7 @@ class CommandCSTopic : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetChannelOption, MOD_RESULT, (source, this, ci, "topiclock off")); + MOD_RESULT = Event::OnSetChannelOption(&Event::SetChannelOption::OnSetChannelOption, source, this, ci, "topiclock off"); if (MOD_RESULT == EVENT_STOP) return; @@ -198,6 +200,9 @@ class CommandCSTopic : public Command }; class CSTopic : public Module + , public EventHook + , public EventHook + , public EventHook { CommandCSTopic commandcstopic; CommandCSSetKeepTopic commandcssetkeeptopic; @@ -205,8 +210,14 @@ class CSTopic : public Module SerializableExtensibleItem topiclock, keeptopic; public: - CSTopic(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandcstopic(this), commandcssetkeeptopic(this), topiclock(this, "TOPICLOCK"), keeptopic(this, "KEEPTOPIC") + CSTopic(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook("OnChannelSync") + , EventHook("OnTopicUpdated") + , EventHook("OnChanInfo") + , commandcstopic(this) + , commandcssetkeeptopic(this) + , topiclock(this, "TOPICLOCK") + , keeptopic(this, "KEEPTOPIC") { } diff --git a/modules/commands/cs_unban.cpp b/modules/commands/cs_unban.cpp index 936de6b41..f5e2a6460 100644 --- a/modules/commands/cs_unban.cpp +++ b/modules/commands/cs_unban.cpp @@ -107,8 +107,8 @@ class CSUnban : public Module CommandCSUnban commandcsunban; public: - CSUnban(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandcsunban(this) + CSUnban(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandcsunban(this) { } diff --git a/modules/commands/cs_updown.cpp b/modules/commands/cs_updown.cpp index 294d46680..282eb1479 100644 --- a/modules/commands/cs_updown.cpp +++ b/modules/commands/cs_updown.cpp @@ -221,8 +221,9 @@ class CSUpDown : public Module CommandCSDown commandcsdown; public: - CSUpDown(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandcsup(this), commandcsdown(this) + CSUpDown(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandcsup(this) + , commandcsdown(this) { } diff --git a/modules/commands/cs_xop.cpp b/modules/commands/cs_xop.cpp index 49cb96eb4..84a8fbfb7 100644 --- a/modules/commands/cs_xop.cpp +++ b/modules/commands/cs_xop.cpp @@ -216,7 +216,7 @@ class CommandCSXOP : public Command Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask; - FOREACH_MOD(OnAccessAdd, (ci, source, acc)); + Event::OnAccessAdd(&Event::AccessAdd::OnAccessAdd, ci, source, acc); source.Reply(_("\002%s\002 added to %s %s list."), acc->mask.c_str(), ci->name.c_str(), source.command.c_str()); } @@ -325,7 +325,7 @@ class CommandCSXOP : public Command nicks = caccess->mask; ci->EraseAccess(number - 1); - FOREACH_MOD(OnAccessDel, (ci, source, caccess)); + Event::OnAccessDel(&Event::AccessDel::OnAccessDel, ci, source, caccess); delete caccess; } } @@ -348,7 +348,7 @@ class CommandCSXOP : public Comm