diff options
Diffstat (limited to 'modules')
159 files changed, 1744 insertions, 722 deletions
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<Event::ChanRegistered> { public: BSAutoAssign(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::ChanRegistered>("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<Event::Invite> + , public EventHook<Event::BotInfoEvent> { ExtensibleItem<bool> 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<Event::Invite>("OnInvite") + , EventHook<Event::BotInfoEvent>("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<Event::BadWordEvents> *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<BadWordsImpl> badwords; Serialize::Type badword_type; + EventHandlers<Event::BadWordEvents> 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<Event::BotCreate> OnBotCreate; + EventHandlers<Event::BotChange> OnBotChange; + EventHandlers<Event::BotDelete> OnBotDelete; + void DoAdd(CommandSource &source, const std::vector<Anope::string> ¶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<Anope::string> ¶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<Anope::string> ¶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<Event::BotInfoEvent> &onbotinfo; + public: - CommandBSInfo(Module *creator) : Command(creator, "botserv/info", 1, 1) + CommandBSInfo(Module *creator, EventHandlers<Event::BotInfoEvent> &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<Anope::string> 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<Anope::string> replies; info.Process(replies); @@ -123,10 +127,11 @@ class CommandBSInfo : public Command class BSInfo : public Module { CommandBSInfo commandbsinfo; + EventHandlers<Event::BotInfoEvent> 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<Event::BotInfoEvent> + , public EventHook<Event::Privmsg> { ExtensibleItem<BanData> bandata; ExtensibleItem<UserData> userdata; @@ -1020,6 +1023,8 @@ class BSKick : public Module BanDataPurger purger; + EventHandlers<Event::BotBan> 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<Event::BotInfoEvent>("OnBotInfoEvent") + , EventHook<Event::Privmsg>("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<Event::BotBan> { 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<Event::BotBan>("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<Anope::string, int16_t, ci::less> 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<Event::LevelChange> &onlevelchange; + public: - CommandCSLevels(Module *creator) : Command(creator, "chanserv/levels", 2, 4) + CommandCSLevels(Module *creator, EventHandlers<Event::LevelChange> &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<Event::CreateChan> + , public EventHook<Event::GroupCheckPriv> { AccessAccessProvider accessprovider; CommandCSAccess commandcsaccess; CommandCSLevels commandcslevels; + EventHandlers<Event::LevelChange> 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<Event::CreateChan>("OnCreateChan") + , EventHook<Event::GroupCheckPriv>("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<Event::Akick> &akickevents; + public: - CommandCSAKick(Module *creator) : Command(creator, "chanserv/akick", 2, 4) + CommandCSAKick(Module *creator, EventHandlers<Event::Akick> &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<Event::CheckKick> { CommandCSAKick commandcsakick; + EventHandlers<Event::Akick> 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<Event::CheckKick>("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<Event::ChanDrop> &onchandrop; + public: - CommandCSDrop(Module *creator) : Command(creator, "chanserv/drop", 1, 2) + CommandCSDrop(Module *creator, EventHandlers<Event::ChanDrop> &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<Event::ChanDrop> 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<Event::JoinChannel> { CommandEntryMessage commandentrymsg; ExtensibleItem<EntryMessageListImpl> 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<Event::JoinChannel>("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<Event::ChanInfo> &eventonchaninfo; + public: - CommandCSInfo(Module *creator) : Command(creator, "chanserv/info", 1, 2) + CommandCSInfo(Module *creator, EventHandlers<Event::ChanInfo> &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<Anope::string> replies; info.Process(replies); @@ -86,10 +89,12 @@ class CommandCSInfo : public Command class CSInfo : public Module { CommandCSInfo commandcsinfo; + EventHandlers<Event::ChanInfo> 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<Event::ChanInfo> { CommandCSList commandcslist; CommandCSSetPrivate commandcssetprivate; @@ -242,8 +244,11 @@ class CSList : public Module SerializableExtensibleItem<bool> 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<Event::ChanInfo>("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<Event::ChanRegistered> + , public EventHook<Event::Log> { - ServiceReference<MemoServService> MSService; CommandCSLog commandcslog; ExtensibleItem<LogSettingsImpl> logsettings; Serialize::Type logsetting_type; @@ -294,9 +296,12 @@ class CSLog : public Module std::vector<LogDefault> 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<Event::ChanRegistered>("OnChanRegistered") + , EventHook<Event::Log>("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<Event::MLockEvents> *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<Event::CheckModes> + , public EventHook<Event::CreateChan> + , public EventHook<Event::ChanInfo> { CommandCSMode commandcsmode; CommandCSModes commandcsmodes; ExtensibleItem<ModeLocksImpl> modelocks; Serialize::Type modelocks_type; + EventHandlers<Event::MLockEvents> 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<Event::CheckModes>("OnCheckModes") + , EventHook<Event::CreateChan>("OnCreateChan") + , EventHook<Event::ChanInfo>("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<Event::ExpireTick> + , public EventHook<Event::UserConnect> + , public EventHook<Event::UserNickChange> + , public EventHook<Event::UserQuit> + , public EventHook<Event::JoinChannel> + , public EventHook<Event::PartChannel> + , public EventHook<Event::PreUserKicked> { 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<Event::ExpireTick>("OnExpireTick") + , EventHook<Event::UserConnect>("OnUserConnect") + , EventHook<Event::UserNickChange>("OnUserNickChange") + , EventHook<Event::UserQuit>("OnUserQuit") + , EventHook<Event::JoinChannel>("OnJoinChannel") + , EventHook<Event::PartChannel>("OnPartChannel") + , EventHook<Event::PreUserKicked>("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<Event::CreateChan> + , public EventHook<Event::ChannelCreate> + , public EventHook<Event::ChannelSync> + , public EventHook<Event::CheckKick> + , public EventHook<Event::DelChan> + , public EventHook<Event::ChannelModeSet> + , public EventHook<Event::ChannelModeUnset> + , public EventHook<Event::CheckDelete> + , public EventHook<Event::JoinChannel> + , public EventHook<Event::SetCorrectModes> + , public EventHook<ChanServ::Event::PreChanExpire> + , public EventHook<Event::ChanInfo> { SerializableExtensibleItem<bool> 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<Event::CreateChan>("OnCreateChan") + , EventHook<Event::ChannelCreate>("OnChannelCreate") + , EventHook<Event::ChannelSync>("OnChannelSync") + , EventHook<Event::CheckKick>("OnCheckKick") + , EventHook<Event::DelChan>("OnDelChan") + , EventHook<Event::ChannelModeSet>("OnChannelModeSet") + , EventHook<Event::ChannelModeUnset>("OnChannelModeUnset") + , EventHook<Event::CheckDelete>("OnCheckDelete") + , EventHook<Event::JoinChannel>("OnJoinChannel") + , EventHook<Event::SetCorrectModes>("OnSetCorrectModes") + , EventHook<ChanServ::Event::PreChanExpire>("OnPreChanExpire") + , EventHook<Event::ChanInfo>("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<Event::ChanInfo> { 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<Event::ChanInfo>("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<Event::ChanSuspend> &onchansuspend; public: - CommandCSSuspend(Module *creator) : Command(creator, "chanserv/suspend", 2, 3) + CommandCSSuspend(Module *creator, EventHandlers<Event::ChanSuspend> &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<Event::ChanUnsuspend> &onchanunsuspend; + public: - CommandCSUnSuspend(Module *creator) : Command(creator, "chanserv/unsuspend", 1, 1) + CommandCSUnSuspend(Module *creator, EventHandlers<Event::ChanUnsuspend> &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<Event::ChanInfo> + , public EventHook<ChanServ::Event::PreChanExpire> + , public EventHook<Event::CheckKick> + , public EventHook<Event::ChanDrop> { CommandCSSuspend commandcssuspend; CommandCSUnSuspend commandcsunsuspend; ExtensibleItem<CSSuspendInfo> suspend; Serialize::Type suspend_type; + EventHandlers<Event::ChanSuspend> onchansuspend; + EventHandlers<Event::ChanUnsuspend> 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<Event::ChanInfo>("OnChanInfo") + , EventHook<ChanServ::Event::PreChanExpire>("OnPreChanExpire") + , EventHook<Event::CheckKick>("OnCheckKick") + , EventHook<Event::ChanDrop>("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<Event::ChannelSync> + , public EventHook<Event::TopicUpdated> + , public EventHook<Event::ChanInfo> { CommandCSTopic commandcstopic; CommandCSSetKeepTopic commandcssetkeeptopic; @@ -205,8 +210,14 @@ class CSTopic : public Module SerializableExtensibleItem<bool> 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<Event::ChannelSync>("OnChannelSync") + , EventHook<Event::TopicUpdated>("OnTopicUpdated") + , EventHook<Event::ChanInfo>("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 Command source.Reply(_("\002%s\002 deleted from %s %s list."), a->mask.c_str(), ci->name.c_str(), source.command.c_str()); ci->EraseAccess(i); - FOREACH_MOD(OnAccessDel, (ci, source, a)); + Event::OnAccessDel(&Event::AccessDel::OnAccessDel, ci, source, a); delete a; return; @@ -475,7 +475,7 @@ class CommandCSXOP : public Command delete ci->EraseAccess(i - 1); } - FOREACH_MOD(OnAccessClear, (ci, source)); + Event::OnAccessClear(&Event::AccessClear::OnAccessClear, ci, source); source.Reply(_("Channel %s %s list has been cleared."), ci->name.c_str(), source.command.c_str()); } @@ -593,8 +593,9 @@ class CSXOP : public Module CommandCSXOP commandcsxop; public: - CSXOP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - accessprovider(this), commandcsxop(this) + CSXOP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , accessprovider(this) + , commandcsxop(this) { this->SetPermanent(true); diff --git a/modules/commands/gl_global.cpp b/modules/commands/gl_global.cpp index 48152cd0b..5d2d6b61b 100644 --- a/modules/commands/gl_global.cpp +++ b/modules/commands/gl_global.cpp @@ -10,13 +10,12 @@ */ #include "module.h" +#include "modules/global.h" class CommandGLGlobal : public Command { - ServiceReference<GlobalService> GService; - public: - CommandGLGlobal(Module *creator) : Command(creator, "global/global", 1, 1), GService("GlobalService", "Global") + CommandGLGlobal(Module *creator) : Command(creator, "global/global", 1, 1) { this->SetDesc(_("Send a message to all users")); this->SetSyntax(_("\037message\037")); @@ -26,13 +25,14 @@ class CommandGLGlobal : public Command { const Anope::string &msg = params[0]; - if (!GService) - source.Reply("No global reference, is global loaded?"); - else + if (!Global::service) { - Log(LOG_ADMIN, source, this); - GService->SendGlobal(NULL, source.GetNick(), msg); + source.Reply("No global reference, is global loaded?"); + return; } + + Log(LOG_ADMIN, source, this); + Global::service->SendGlobal(NULL, source.GetNick(), msg); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -50,8 +50,8 @@ class GLGlobal : public Module CommandGLGlobal commandglglobal; public: - GLGlobal(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandglglobal(this) + GLGlobal(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandglglobal(this) { } diff --git a/modules/commands/greet.cpp b/modules/commands/greet.cpp index 52213acec..cacda2d3c 100644 --- a/modules/commands/greet.cpp +++ b/modules/commands/greet.cpp @@ -10,6 +10,9 @@ */ #include "module.h" +#include "modules/ns_info.h" +#include "modules/bs_info.h" +#include "modules/ns_set.h" class CommandBSSetGreet : public Command { @@ -100,8 +103,7 @@ class CommandNSSetGreet : public Command } NickCore *nc = na->nc; - EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); + EventReturn MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) return; @@ -163,6 +165,9 @@ class CommandNSSASetGreet : public CommandNSSetGreet }; class Greet : public Module + , public EventHook<Event::JoinChannel> + , public EventHook<Event::NickInfo> + , public EventHook<Event::BotInfoEvent> { /* channel setting for whether or not greet should be shown */ SerializableExtensibleItem<bool> bs_greet; @@ -174,11 +179,15 @@ class Greet : public Module CommandNSSASetGreet commandnssasetgreet; public: - Greet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - bs_greet(this, "BS_GREET"), - ns_greet(this, "greet"), - commandbssetgreet(this), - commandnssetgreet(this), commandnssasetgreet(this) + Greet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::JoinChannel>("OnJoinChannel") + , EventHook<Event::NickInfo>("OnNickInfo") + , EventHook<Event::BotInfoEvent>("OnBotInfoEvent") + , bs_greet(this, "BS_GREET") + , ns_greet(this, "greet") + , commandbssetgreet(this) + , commandnssetgreet(this) + , commandnssasetgreet(this) { } diff --git a/modules/commands/help.cpp b/modules/commands/help.cpp index 33ac00a60..c23454c25 100644 --- a/modules/commands/help.cpp +++ b/modules/commands/help.cpp @@ -10,6 +10,7 @@ */ #include "module.h" +#include "modules/help.h" class CommandHelp : public Command { @@ -27,8 +28,10 @@ class CommandHelp : public Command return NULL; } + EventHandlers<Event::Help> &onhelp; + public: - CommandHelp(Module *creator) : Command(creator, "generic/help", 0) + CommandHelp(Module *creator, EventHandlers<Event::Help> &event) : Command(creator, "generic/help", 0), onhelp(event) { this->SetDesc(_("Displays this list and give information about commands")); this->AllowUnregistered(true); @@ -36,8 +39,7 @@ class CommandHelp : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - EventReturn MOD_RESULT; - FOREACH_RESULT(OnPreHelp, MOD_RESULT, (source, params)); + EventReturn MOD_RESULT = this->onhelp(&Event::Help::OnPreHelp, source, params); if (MOD_RESULT == EVENT_STOP) return; @@ -184,19 +186,19 @@ class CommandHelp : public Command source.Reply(_("No help available for \002%s\002."), params[0].c_str()); } - FOREACH_MOD(OnPostHelp, (source, params)); - - return; + this->onhelp(&Event::Help::OnPostHelp, source, params); } }; class Help : public Module { CommandHelp commandhelp; + EventHandlers<Event::Help> onhelp; public: - Help(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandhelp(this) + Help(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandhelp(this, onhelp) + , onhelp(this, "Help") { } diff --git a/modules/commands/hs_del.cpp b/modules/commands/hs_del.cpp index 5c74eb8ac..ae0e2e6c2 100644 --- a/modules/commands/hs_del.cpp +++ b/modules/commands/hs_del.cpp @@ -10,11 +10,14 @@ */ #include "module.h" +#include "modules/hs_del.h" class CommandHSDel : public Command { + EventHandlers<Event::DeleteVhost> &OnDeleteVhost; + public: - CommandHSDel(Module *creator) : Command(creator, "hostserv/del", 1, 1) + CommandHSDel(Module *creator, EventHandlers<Event::DeleteVhost> &onDeleteVhost) : Command(creator, "hostserv/del", 1, 1), OnDeleteVhost(onDeleteVhost) { this->SetDesc(_("Delete the vhost of another user")); this->SetSyntax(_("\037nick\037")); @@ -33,7 +36,7 @@ class CommandHSDel : public Command if (na) { Log(LOG_ADMIN, source, this) << "for user " << na->nick; - FOREACH_MOD(OnDeleteVhost, (na)); + this->OnDeleteVhost(&Event::DeleteVhost::OnDeleteVhost, na); na->RemoveVhost(); source.Reply(_("Vhost for \002%s\002 removed."), nick.c_str()); } @@ -53,8 +56,10 @@ class CommandHSDel : public Command class CommandHSDelAll : public Command { + EventHandlers<Event::DeleteVhost> &ondeletevhost; + public: - CommandHSDelAll(Module *creator) : Command(creator, "hostserv/delall", 1, 1) + CommandHSDelAll(Module *creator, EventHandlers<Event::DeleteVhost> &event) : Command(creator, "hostserv/delall", 1, 1), ondeletevhost(event) { this->SetDesc(_("Delete the vhost for all nicks in a group")); this->SetSyntax(_("\037nick\037")); @@ -72,7 +77,7 @@ class CommandHSDelAll : public Command NickAlias *na = NickAlias::Find(nick); if (na) { - FOREACH_MOD(OnDeleteVhost, (na)); + this->ondeletevhost(&Event::DeleteVhost::OnDeleteVhost, na); const NickCore *nc = na->nc; for (unsigned i = 0; i < nc->aliases->size(); ++i) { @@ -100,10 +105,13 @@ class HSDel : public Module { CommandHSDel commandhsdel; CommandHSDelAll commandhsdelall; + EventHandlers<Event::DeleteVhost> ondeletevhost; public: - HSDel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandhsdel(this), commandhsdelall(this) + HSDel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandhsdel(this, ondeletevhost) + , commandhsdelall(this, ondeletevhost) + , ondeletevhost(this, "OnDeleteVhost") { } diff --git a/modules/commands/hs_group.cpp b/modules/commands/hs_group.cpp index ca3aa9742..eb1c6d299 100644 --- a/modules/commands/hs_group.cpp +++ b/modules/commands/hs_group.cpp @@ -10,6 +10,7 @@ */ #include "module.h" +#include "modules/ns_group.h" class CommandHSGroup : public Command { @@ -31,7 +32,7 @@ class CommandHSGroup : public Command if (nick) { nick->SetVhost(na->GetVhostIdent(), na->GetVhostHost(), na->GetVhostCreator()); - FOREACH_MOD(OnSetVhost, (nick)); + Event::OnSetVhost(&Event::SetVhost::OnSetVhost, nick); } } setting = false; @@ -77,14 +78,18 @@ class CommandHSGroup : public Command }; class HSGroup : public Module + , public EventHook<Event::SetVhost> + , public EventHook<Event::NickGroup> { CommandHSGroup commandhsgroup; bool syncongroup; bool synconset; public: - HSGroup(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandhsgroup(this) + HSGroup(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::SetVhost>("OnSetVhost") + , EventHook<Event::NickGroup>("OnNickGroup") + , commandhsgroup(this) { } diff --git a/modules/commands/hs_list.cpp b/modules/commands/hs_list.cpp index 5f9a60110..b5b8aa76a 100644 --- a/modules/commands/hs_list.cpp +++ b/modules/commands/hs_list.cpp @@ -149,8 +149,8 @@ class HSList : public Module CommandHSList commandhslist; public: - HSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandhslist(this) + HSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandhslist(this) { } }; diff --git a/modules/commands/hs_off.cpp b/modules/commands/hs_off.cpp index 93060432a..c0d51f884 100644 --- a/modules/commands/hs_off.cpp +++ b/modules/commands/hs_off.cpp @@ -53,8 +53,8 @@ class HSOff : public Module CommandHSOff commandhsoff; public: - HSOff(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandhsoff(this) + HSOff(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandhsoff(this) { } diff --git a/modules/commands/hs_on.cpp b/modules/commands/hs_on.cpp index 182e1013e..4b92bf0be 100644 --- a/modules/commands/hs_on.cpp +++ b/modules/commands/hs_on.cpp @@ -62,8 +62,8 @@ class HSOn : public Module CommandHSOn commandhson; public: - HSOn(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandhson(this) + HSOn(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandhson(this) { } diff --git a/modules/commands/hs_request.cpp b/modules/commands/hs_request.cpp index f5eb5317d..1e5c98e31 100644 --- a/modules/commands/hs_request.cpp +++ b/modules/commands/hs_request.cpp @@ -16,8 +16,7 @@ */ #include "module.h" - -static ServiceReference<MemoServService> memoserv("MemoServService", "MemoServ"); +#include "modules/memoserv.h" static void req_send_memos(Module *me, CommandSource &source, const Anope::string &vIdent, const Anope::string &vHost); @@ -202,10 +201,10 @@ class CommandHSActivate : public Command if (req) { na->SetVhost(req->ident, req->host, source.GetNick(), req->time); - FOREACH_MOD(OnSetVhost, (na)); + Event::OnSetVhost(&Event::SetVhost::OnSetVhost, na); - if (Config->GetModule(this->owner)->Get<bool>("memouser") && memoserv) - memoserv->Send(source.service->nick, na->nick, _("[auto memo] Your requested vHost has been approved."), true); + if (Config->GetModule(this->owner)->Get<bool>("memouser") && MemoServ::service) + MemoServ::service->Send(source.service->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; @@ -253,7 +252,7 @@ class CommandHSReject : public Command { na->Shrink<HostRequest>("hostrequest"); - if (Config->GetModule(this->owner)->Get<bool>("memouser") && memoserv) + if (Config->GetModule(this->owner)->Get<bool>("memouser") && MemoServ::service) { Anope::string message; if (!reason.empty()) @@ -261,7 +260,7 @@ class CommandHSReject : public Command else message = _("[auto memo] Your requested vHost has been rejected."); - memoserv->Send(source.service->nick, nick, Language::Translate(source.GetAccount(), message.c_str()), true); + MemoServ::service->Send(source.service->nick, nick, Language::Translate(source.GetAccount(), message.c_str()), true); } source.Reply(_("vHost for %s has been rejected."), nick.c_str()); @@ -352,9 +351,13 @@ class HSRequest : public Module Serialize::Type request_type; public: - HSRequest(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandhsrequest(this), commandhsactive(this), - commandhsreject(this), commandhswaiting(this), hostrequest(this, "hostrequest"), request_type("HostRequest", HostRequest::Unserialize) + HSRequest(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandhsrequest(this) + , commandhsactive(this) + , commandhsreject(this) + , commandhswaiting(this) + , hostrequest(this, "hostrequest") + , request_type("HostRequest", HostRequest::Unserialize) { if (!IRCD || !IRCD->CanSetVHost) @@ -372,7 +375,7 @@ static void req_send_memos(Module *me, CommandSource &source, const Anope::strin else host = vHost; - if (Config->GetModule(me)->Get<bool>("memooper") && memoserv) + if (Config->GetModule(me)->Get<bool>("memooper") && MemoServ::service) for (unsigned i = 0; i < Oper::opers.size(); ++i) { Oper *o = Oper::opers[i]; @@ -383,7 +386,7 @@ static void req_send_memos(Module *me, CommandSource &source, const Anope::strin Anope::string message = Anope::printf(_("[auto memo] vHost \002%s\002 has been requested by %s."), host.c_str(), source.GetNick().c_str()); - memoserv->Send(source.service->nick, na->nick, message, true); + MemoServ::service->Send(source.service->nick, na->nick, message, true); } } diff --git a/modules/commands/hs_set.cpp b/modules/commands/hs_set.cpp index 770aa6695..69281b6ec 100644 --- a/modules/commands/hs_set.cpp +++ b/modules/commands/hs_set.cpp @@ -85,7 +85,7 @@ class CommandHSSet : public Command Log(LOG_ADMIN, source, this) << "to set the vhost of " << na->nick << " to " << (!user.empty() ? user + "@" : "") << host; na->SetVhost(user, host, source.GetNick()); - FOREACH_MOD(OnSetVhost, (na)); + Event::OnSetVhost(&Event::SetVhost::OnSetVhost, na); if (!user.empty()) source.Reply(_("VHost for \002%s\002 set to \002%s\002@\002%s\002."), nick.c_str(), user.c_str(), host.c_str()); else @@ -192,7 +192,7 @@ class CommandHSSetAll : public Command na->SetVhost(user, host, source.GetNick()); this->Sync(na); - FOREACH_MOD(OnSetVhost, (na)); + Event::OnSetVhost(&Event::SetVhost::OnSetVhost, na); if (!user.empty()) source.Reply(_("VHost for group \002%s\002 set to \002%s\002@\002%s\002."), nick.c_str(), user.c_str(), host.c_str()); else @@ -219,7 +219,9 @@ class HSSet : public Module CommandHSSetAll commandhssetall; public: - HSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), commandhsset(this), commandhssetall(this) + HSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandhsset(this) + , commandhssetall(this) { } diff --git a/modules/commands/ms_cancel.cpp b/modules/commands/ms_cancel.cpp index 86d70732e..09746d0f2 100644 --- a/modules/commands/ms_cancel.cpp +++ b/modules/commands/ms_cancel.cpp @@ -10,6 +10,7 @@ */ #include "module.h" +#include "modules/memoserv.h" class CommandMSCancel : public Command { @@ -46,7 +47,8 @@ class CommandMSCancel : public Command for (int i = mi->memos->size() - 1; i >= 0; --i) if (mi->GetMemo(i)->unread && source.nc->display.equals_ci(mi->GetMemo(i)->sender)) { - FOREACH_MOD(OnMemoDel, (ischan ? ci->name : na->nc->display, mi, mi->GetMemo(i))); + if (MemoServ::Event::OnMemoDel) + MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ischan ? ci->name : na->nc->display, mi, mi->GetMemo(i)); mi->Del(i); source.Reply(_("Last memo to \002%s\002 has been cancelled."), nname.c_str()); return; @@ -72,8 +74,8 @@ class MSCancel : public Module CommandMSCancel commandmscancel; public: - MSCancel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandmscancel(this) + MSCancel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandmscancel(this) { } }; diff --git a/modules/commands/ms_check.cpp b/modules/commands/ms_check.cpp index 3cb116088..a534aaca3 100644 --- a/modules/commands/ms_check.cpp +++ b/modules/commands/ms_check.cpp @@ -77,8 +77,8 @@ class MSCheck : public Module CommandMSCheck commandmscheck; public: - MSCheck(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandmscheck(this) + MSCheck(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandmscheck(this) { } diff --git a/modules/commands/ms_del.cpp b/modules/commands/ms_del.cpp index 4b6c7d95f..e1d329921 100644 --- a/modules/commands/ms_del.cpp +++ b/modules/commands/ms_del.cpp @@ -10,6 +10,7 @@ */ #include "module.h" +#include "modules/memoserv.h" class MemoDelCallback : public NumberList { @@ -26,7 +27,8 @@ class MemoDelCallback : public NumberList if (!number || number > mi->memos->size()) return; - FOREACH_MOD(OnMemoDel, (ci ? ci->name : source.nc->display, mi, mi->GetMemo(number - 1))); + if (MemoServ::Event::OnMemoDel) + MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ci ? ci->name : source.nc->display, mi, mi->GetMemo(number - 1)); mi->Del(number - 1); source.Reply(_("Memo %d has been deleted."), number); @@ -93,7 +95,8 @@ class CommandMSDel : public Command else if (numstr.equals_ci("LAST")) { /* Delete last memo. */ - FOREACH_MOD(OnMemoDel, (ci ? ci->name : source.nc->display, mi, mi->GetMemo(mi->memos->size() - 1))); + if (MemoServ::Event::OnMemoDel) + MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ci ? ci->name : source.nc->display, mi, mi->GetMemo(mi->memos->size() - 1)); mi->Del(mi->memos->size() - 1); source.Reply(_("Memo %d has been deleted."), mi->memos->size() + 1); } @@ -102,7 +105,8 @@ class CommandMSDel : public Command /* Delete all memos. */ for (unsigned i = mi->memos->size(); i > 0; --i) { - FOREACH_MOD(OnMemoDel, (ci ? ci->name : source.nc->display, mi, mi->GetMemo(i))); + if (MemoServ::Event::OnMemoDel) + MemoServ::Event::OnMemoDel(&MemoServ::Event::MemoDel::OnMemoDel, ci ? ci->name : source.nc->display, mi, mi->GetMemo(i)); mi->Del(i - 1); } if (!chan.empty()) @@ -141,8 +145,8 @@ class MSDel : public Module CommandMSDel commandmsdel; public: - MSDel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandmsdel(this) + MSDel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandmsdel(this) { } diff --git a/modules/commands/ms_ignore.cpp b/modules/commands/ms_ignore.cpp index d7683d651..f73a27930 100644 --- a/modules/commands/ms_ignore.cpp +++ b/modules/commands/ms_ignore.cpp @@ -117,8 +117,8 @@ class MSIgnore : public Module CommandMSIgnore commandmsignore; public: - MSIgnore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandmsignore(this) + MSIgnore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandmsignore(this) { } }; diff --git a/modules/commands/ms_info.cpp b/modules/commands/ms_info.cpp index fe008b484..0e7506765 100644 --- a/modules/commands/ms_info.cpp +++ b/modules/commands/ms_info.cpp @@ -204,8 +204,8 @@ class MSInfo : public Module CommandMSInfo commandmsinfo; public: - MSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandmsinfo(this) + MSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandmsinfo(this) { } diff --git a/modules/commands/ms_list.cpp b/modules/commands/ms_list.cpp index 936dbc750..e5ca96770 100644 --- a/modules/commands/ms_list.cpp +++ b/modules/commands/ms_list.cpp @@ -154,8 +154,8 @@ class MSList : public Module CommandMSList commandmslist; public: - MSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandmslist(this) + MSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandmslist(this) { } diff --git a/modules/commands/ms_read.cpp b/modules/commands/ms_read.cpp index 9cc0be881..ba5eda863 100644 --- a/modules/commands/ms_read.cpp +++ b/modules/commands/ms_read.cpp @@ -10,13 +10,12 @@ */ #include "module.h" - -static ServiceReference<MemoServService> MemoServService("MemoServService", "MemoServ"); +#include "modules/memoserv.h" static void rsend_notify(CommandSource &source, MemoInfo *mi, Memo *m, const Anope::string &targ) { /* Only send receipt if memos are allowed */ - if (MemoServService && !Anope::ReadOnly) + if (MemoServ::service && !Anope::ReadOnly) { /* Get nick alias for sender */ const NickAlias *na = NickAlias::Find(m->sender); @@ -35,7 +34,7 @@ static void rsend_notify(CommandSource &source, MemoInfo *mi, Memo *m, const Ano Anope::string text = Anope::printf(Language::Translate(na->nc, _("\002[auto-memo]\002 The memo you sent to %s has been viewed.")), targ.c_str()); /* Send notification */ - MemoServService->Send(source.GetNick(), m->sender, text, true); + MemoServ::service->Send(source.GetNick(), m->sender, text, true); /* Notify recepient of the memo that a notification has been sent to the sender */ @@ -197,8 +196,8 @@ class MSRead : public Module CommandMSRead commandmsread; public: - MSRead(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandmsread(this) + MSRead(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandmsread(this) { } diff --git a/modules/commands/ms_rsend.cpp b/modules/commands/ms_rsend.cpp index 0ecdf5d7e..4cdeb132b 100644 --- a/modules/commands/ms_rsend.cpp +++ b/modules/commands/ms_rsend.cpp @@ -10,11 +10,7 @@ */ #include "module.h" - -namespace -{ - ServiceReference<MemoServService> memoserv("MemoServService", "MemoServ"); -} +#include "modules/memoserv.h" class CommandMSRSend : public Command { @@ -27,7 +23,7 @@ class CommandMSRSend : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - if (!memoserv) + if (!MemoServ::service) return; if (Anope::ReadOnly && !source.IsOper()) @@ -51,12 +47,12 @@ class CommandMSRSend : public Command source.Reply(ACCESS_DENIED); else { - MemoServService::MemoResult result = memoserv->Send(source.GetNick(), nick, text); - if (result == MemoServService::MEMO_INVALID_TARGET) + MemoServ::MemoServService::MemoResult result = MemoServ::service->Send(source.GetNick(), nick, text); + if (result == MemoServ::MemoServService::MEMO_INVALID_TARGET) source.Reply(_("\002%s\002 is not a registered unforbidden nick or channel."), nick.c_str()); - else if (result == MemoServService::MEMO_TOO_FAST) + else if (result == MemoServ::MemoServService::MEMO_TOO_FAST) source.Reply(_("Please wait %d seconds before using the %s command again."), Config->GetModule("memoserv")->Get<time_t>("senddelay"), source.command.c_str()); - else if (result == MemoServService::MEMO_TARGET_FULL) + else if (result == MemoServ::MemoServService::MEMO_TARGET_FULL) source.Reply(_("Sorry, %s currently has too many memos and cannot receive more."), nick.c_str()); else { @@ -93,10 +89,10 @@ class MSRSend : public Module CommandMSRSend commandmsrsend; public: - MSRSend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandmsrsend(this) + MSRSend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandmsrsend(this) { - if (!memoserv) + if (!MemoServ::service) throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ms_send.cpp b/modules/commands/ms_send.cpp index 2d796b505..2cf7d476e 100644 --- a/modules/commands/ms_send.cpp +++ b/modules/commands/ms_send.cpp @@ -10,11 +10,7 @@ */ #include "module.h" - -namespace -{ - ServiceReference<MemoServService> memoserv("MemoServService", "MemoServ"); -} +#include "modules/memoserv.h" class CommandMSSend : public Command { @@ -27,7 +23,7 @@ class CommandMSSend : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - if (!memoserv) + if (!MemoServ::service) return; const Anope::string &nick = params[0]; @@ -39,14 +35,14 @@ class CommandMSSend : public Command return; } - MemoServService::MemoResult result = memoserv->Send(source.GetNick(), nick, text); - if (result == MemoServService::MEMO_SUCCESS) + MemoServ::MemoServService::MemoResult result = MemoServ::service->Send(source.GetNick(), nick, text); + if (result == MemoServ::MemoServService::MEMO_SUCCESS) source.Reply(_("Memo sent to \002%s\002."), nick.c_str()); - else if (result == MemoServService::MEMO_INVALID_TARGET) + else if (result == MemoServ::MemoServService::MEMO_INVALID_TARGET) source.Reply(_("\002%s\002 is not a registered unforbidden nick or channel."), nick.c_str()); - else if (result == MemoServService::MEMO_TOO_FAST) + else if (result == MemoServ::MemoServService::MEMO_TOO_FAST) source.Reply(_("Please wait %d seconds before using the %s command again."), Config->GetModule("memoserv")->Get<time_t>("senddelay"), source.command.c_str()); - else if (result == MemoServService::MEMO_TARGET_FULL) + else if (result == MemoServ::MemoServService::MEMO_TARGET_FULL) source.Reply(_("Sorry, %s currently has too many memos and cannot receive more."), nick.c_str()); } @@ -67,11 +63,11 @@ class MSSend : public Module CommandMSSend commandmssend; public: - MSSend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandmssend(this) + MSSend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandmssend(this) { - if (!memoserv) + if (!MemoServ::service) throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ms_sendall.cpp b/modules/commands/ms_sendall.cpp index a48eb3fa5..c567b0ed3 100644 --- a/modules/commands/ms_sendall.cpp +++ b/modules/commands/ms_sendall.cpp @@ -10,11 +10,7 @@ */ #include "module.h" - -namespace -{ - ServiceReference<MemoServService> memoserv("MemoServService", "MemoServ"); -} +#include "modules/memoserv.h" class CommandMSSendAll : public Command { @@ -27,7 +23,7 @@ class CommandMSSendAll : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - if (!memoserv) + if (!MemoServ::service) return; const Anope::string &text = params[0]; @@ -39,7 +35,7 @@ class CommandMSSendAll : public Command const NickCore *nc = it->second; if (nc != source.nc) - memoserv->Send(source.GetNick(), nc->display, text); + MemoServ::service->Send(source.GetNick(), nc->display, text); } source.Reply(_("A massmemo has been sent to all registered users.")); @@ -59,10 +55,10 @@ class MSSendAll : public Module CommandMSSendAll commandmssendall; public: - MSSendAll(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandmssendall(this) + MSSendAll(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandmssendall(this) { - if (!memoserv) + if (!MemoServ::service) throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ms_set.cpp b/modules/commands/ms_set.cpp index 81388bc3d..5e5591471 100644 --- a/modules/commands/ms_set.cpp +++ b/modules/commands/ms_set.cpp @@ -304,9 +304,12 @@ class MSSet : public Module SerializableExtensibleItem<bool> memo_signon, memo_receive, memo_mail, memo_hardmax; public: - MSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandmsset(this), memo_signon(this, "MEMO_SIGNON"), memo_receive(this, "MEMO_RECEIVE"), memo_mail(this, "MEMO_MAIL"), - memo_hardmax(this, "MEMO_HARDMAX") + MSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandmsset(this) + , memo_signon(this, "MEMO_SIGNON") + , memo_receive(this, "MEMO_RECEIVE") + , memo_mail(this, "MEMO_MAIL") + , memo_hardmax(this, "MEMO_HARDMAX") { } diff --git a/modules/commands/ms_staff.cpp b/modules/commands/ms_staff.cpp index e0cfe3f5d..125ef60fc 100644 --- a/modules/commands/ms_staff.cpp +++ b/modules/commands/ms_staff.cpp @@ -10,11 +10,7 @@ */ #include "module.h" - -namespace -{ - ServiceReference<MemoServService> memoserv("MemoServService", "MemoServ"); -} +#include "modules/memoserv.h" class CommandMSStaff : public Command { @@ -27,7 +23,7 @@ class CommandMSStaff : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - if (!memoserv) + if (!MemoServ::service) return; const Anope::string &text = params[0]; @@ -37,7 +33,7 @@ class CommandMSStaff : public Command const NickCore *nc = it->second; if (source.nc != nc && nc->IsServicesOper()) - memoserv->Send(source.GetNick(), nc->display, text, true); + MemoServ::service->Send(source.GetNick(), nc->display, text, true); } } @@ -56,10 +52,10 @@ class MSStaff : public Module CommandMSStaff commandmsstaff; public: - MSStaff(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandmsstaff(this) + MSStaff(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandmsstaff(this) { - if (!memoserv) + if (!MemoServ::service) throw ModuleException("No MemoServ!"); } }; diff --git a/modules/commands/ns_access.cpp b/modules/commands/ns_access.cpp index facf7cf9c..1df0bbe0e 100644 --- a/modules/commands/ns_access.cpp +++ b/modules/commands/ns_access.cpp @@ -10,6 +10,7 @@ */ #include "module.h" +#include "modules/nickserv.h" class CommandNSAccess : public Command { @@ -187,12 +188,14 @@ class CommandNSAccess : public Command }; class NSAccess : public Module + , public EventHook<NickServ::Event::NickRegister> { CommandNSAccess commandnsaccess; public: - NSAccess(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsaccess(this) + NSAccess(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<NickServ::Event::NickRegister>("OnNickRegister") + , commandnsaccess(this) { } diff --git a/modules/commands/ns_ajoin.cpp b/modules/commands/ns_ajoin.cpp index cbbf544e6..0967dbf61 100644 --- a/modules/commands/ns_ajoin.cpp +++ b/modules/commands/ns_ajoin.cpp @@ -298,15 +298,17 @@ class CommandNSAJoin : public Command }; class NSAJoin : public Module + , public EventHook<Event::UserLogin> { CommandNSAJoin commandnsajoin; ExtensibleItem<AJoinList> ajoinlist; Serialize::Type ajoinentry_type; public: - NSAJoin(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsajoin(this), ajoinlist(this, "ajoinlist"), - ajoinentry_type("AJoinEntry", AJoinEntry::Unserialize) + NSAJoin(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::UserLogin>("OnUserLogin") + , commandnsajoin(this), ajoinlist(this, "ajoinlist") + , ajoinentry_type("AJoinEntry", AJoinEntry::Unserialize) { if (!IRCD || !IRCD->CanSVSJoin) diff --git a/modules/commands/ns_alist.cpp b/modules/commands/ns_alist.cpp index 51f87f156..54216b190 100644 --- a/modules/commands/ns_alist.cpp +++ b/modules/commands/ns_alist.cpp @@ -130,8 +130,8 @@ class NSAList : public Module CommandNSAList commandnsalist; public: - NSAList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsalist(this) + NSAList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandnsalist(this) { } diff --git a/modules/commands/ns_cert.cpp b/modules/commands/ns_cert.cpp index e8c858f42..bda723981 100644 --- a/modules/commands/ns_cert.cpp +++ b/modules/commands/ns_cert.cpp @@ -11,8 +11,10 @@ #include "module.h" #include "modules/ns_cert.h" +#include "modules/nickserv.h" static Anope::hash_map<NickCore *> certmap; +static EventHandlers<Event::NickCertEvents> *events; struct CertServiceImpl : CertService { @@ -50,7 +52,7 @@ struct NSCertListImpl : NSCertList { this->certs.push_back(entry); certmap[entry] = nc; - FOREACH_MOD(OnNickAddCert, (this->nc, entry)); + (*events)(&Event::NickCertEvents::OnNickAddCert, this->nc, entry); } /** Get an entry from the nick's cert list by index @@ -95,7 +97,7 @@ struct NSCertListImpl : NSCertList std::vector<Anope::string>::iterator it = std::find(this->certs.begin(), this->certs.end(), entry); if (it != this->certs.end()) { - FOREACH_MOD(OnNickEraseCert, (this->nc, entry)); + (*events)(&Event::NickCertEvents::OnNickEraseCert, this->nc, entry); certmap.erase(entry); this->certs.erase(it); } @@ -107,7 +109,7 @@ struct NSCertListImpl : NSCertList */ void ClearCert() override { - FOREACH_MOD(OnNickClearCert, (this->nc)); + (*events)(&Event::NickCertEvents::OnNickClearCert, this->nc); for (unsigned i = 0; i < certs.size(); ++i) certmap.erase(certs[i]); this->certs.clear(); @@ -339,17 +341,28 @@ class CommandNSCert : public Command }; class NSCert : public Module + , public EventHook<Event::Fingerprint> + , public EventHook<NickServ::Event::NickValidate> { CommandNSCert commandnscert; NSCertListImpl::ExtensibleItem certs; CertServiceImpl cs; + EventHandlers<Event::NickCertEvents> onnickservevents; + public: - NSCert(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnscert(this), certs(this, "certificates"), cs(this) + NSCert(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::Fingerprint>("OnFingerprint") + , EventHook<NickServ::Event::NickValidate>("OnNickValidate") + , commandnscert(this) + , certs(this, "certificates") + , cs(this) + , onnickservevents(this, "OnNickCert") { if (!IRCD || !IRCD->CanCertFP) throw ModuleException("Your IRCd does not support ssl client certificates"); + + events = &onnickservevents; } void OnFingerprint(User *u) override diff --git a/modules/commands/ns_drop.cpp b/modules/commands/ns_drop.cpp index dc6b00184..fef7682da 100644 --- a/modules/commands/ns_drop.cpp +++ b/modules/commands/ns_drop.cpp @@ -10,11 +10,14 @@ */ #include "module.h" +#include "modules/ns_drop.h" class CommandNSDrop : public Command { + EventHandlers<Event::NickDrop> &onnickdrop; + public: - CommandNSDrop(Module *creator) : Command(creator, "nickserv/drop", 1, 1) + CommandNSDrop(Module *creator, EventHandlers<Event::NickDrop> &event) : Command(creator, "nickserv/drop", 1, 1), onnickdrop(event) { this->SetSyntax(_("\037nickname\037")); this->SetDesc(_("Cancel the registration of a nickname")); @@ -45,7 +48,7 @@ class CommandNSDrop : public Command source.Reply(_("You may not drop other Services Operators' nicknames.")); else { - FOREACH_MOD(OnNickDrop, (source, na)); + this->onnickdrop(&Event::NickDrop::OnNickDrop, source, na); Log(!is_mine ? LOG_ADMIN : LOG_COMMAND, source, this) << "to drop nickname " << na->nick << " (group: " << na->nc->display << ") (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; delete na; @@ -74,10 +77,12 @@ class CommandNSDrop : public Command class NSDrop : public Module { CommandNSDrop commandnsdrop; + EventHandlers<Event::NickDrop> onnickdrop; public: - NSDrop(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsdrop(this) + NSDrop(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandnsdrop(this, onnickdrop) + , onnickdrop(this, "OnNickDrop") { } diff --git a/modules/commands/ns_getemail.cpp b/modules/commands/ns_getemail.cpp index 3790bca6a..96845571c 100644 --- a/modules/commands/ns_getemail.cpp +++ b/modules/commands/ns_getemail.cpp @@ -66,9 +66,10 @@ class CommandNSGetEMail : public Command class NSGetEMail : public Module { CommandNSGetEMail commandnsgetemail; + public: - NSGetEMail(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsgetemail(this) + NSGetEMail(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandnsgetemail(this) { } diff --git a/modules/commands/ns_getpass.cpp b/modules/commands/ns_getpass.cpp index 871b8a685..c9bfc0402 100644 --- a/modules/commands/ns_getpass.cpp +++ b/modules/commands/ns_getpass.cpp @@ -60,8 +60,8 @@ class NSGetPass : public Module CommandNSGetPass commandnsgetpass; public: - NSGetPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsgetpass(this) + NSGetPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandnsgetpass(this) { Anope::string tmp_pass = "plain:tmp"; diff --git a/modules/commands/ns_group.cpp b/modules/commands/ns_group.cpp index d8af7d18a..edd12f83d 100644 --- a/modules/commands/ns_group.cpp +++ b/modules/commands/ns_group.cpp @@ -11,16 +11,18 @@ #include "module.h" #include "modules/ns_cert.h" +#include "modules/ns_group.h" class NSGroupRequest : public IdentifyRequest { + EventHandlers<Event::NickGroup> &onnickgroup; CommandSource source; Command *cmd; Anope::string nick; Reference<NickAlias> target; public: - NSGroupRequest(Module *o, CommandSource &src, Command *c, const Anope::string &n, NickAlias *targ, const Anope::string &pass) : IdentifyRequest(o, targ->nc->display, pass), source(src), cmd(c), nick(n), target(targ) { } + NSGroupRequest(Module *o, EventHandlers<Event::NickGroup> &event, CommandSource &src, Command *c, const Anope::string &n, NickAlias *targ, const Anope::string &pass) : IdentifyRequest(o, targ->nc->display, pass), onnickgroup(event), source(src), cmd(c), nick(n), target(targ) { } void OnSuccess() override { @@ -32,7 +34,7 @@ class NSGroupRequest : public IdentifyRequest /* If the nick is already registered, drop it. */ if (na) { - FOREACH_MOD(OnChangeCoreDisplay, (na->nc, u->nick)); + Event::OnChangeCoreDisplay(&Event::ChangeCoreDisplay::OnChangeCoreDisplay, na->nc, u->nick); delete na; } @@ -44,7 +46,7 @@ class NSGroupRequest : public IdentifyRequest na->time_registered = na->last_seen = Anope::CurTime; u->Login(target->nc); - FOREACH_MOD(OnNickGroup, (u, target)); + this->onnickgroup(&Event::NickGroup::OnNickGroup, u, target); Log(LOG_COMMAND, source, cmd) << "to make " << nick << " join group of " << target->nick << " (" << target->nc->display << ") (email: " << (!target->nc->email.empty() ? target->nc->email : "none") << ")"; source.Reply(_("You are now in the group of \002%s\002."), target->nick.c_str()); @@ -71,8 +73,10 @@ class NSGroupRequest : public IdentifyRequest class CommandNSGroup : public Command { + EventHandlers<Event::NickGroup> &onnickgroup; + public: - CommandNSGroup(Module *creator) : Command(creator, "nickserv/group", 0, 2) + CommandNSGroup(Module *creator, EventHandlers<Event::NickGroup> &event) : Command(creator, "nickserv/group", 0, 2), onnickgroup(event) { this->SetDesc(_("Join a group")); this->SetSyntax(_("\037[target]\037 \037[password]\037")); @@ -165,13 +169,13 @@ class CommandNSGroup : public Command if (ok == false && !pass.empty()) { - NSGroupRequest *req = new NSGroupRequest(owner, source, this, u->nick, target, pass); - FOREACH_MOD(OnCheckAuthentication, (source.GetUser(), req)); + NSGroupRequest *req = new NSGroupRequest(owner, this->onnickgroup, source, this, u->nick, target, pass); + Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, source.GetUser(), req); req->Dispatch(); } else { - NSGroupRequest req(owner, source, this, u->nick, target, pass); + NSGroupRequest req(owner, this->onnickgroup, source, this, u->nick, target, pass); if (ok) req.OnSuccess(); @@ -372,9 +376,14 @@ class NSGroup : public Module CommandNSUngroup commandnsungroup; CommandNSGList commandnsglist; + EventHandlers<Event::NickGroup> onnickgroup; + public: - NSGroup(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsgroup(this), commandnsungroup(this), commandnsglist(this) + NSGroup(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandnsgroup(this, onnickgroup) + , commandnsungroup(this) + , commandnsglist(this) + , onnickgroup(this, "OnNickGroup") { if (Config->GetModule("nickserv")->Get<bool>("nonicknameownership")) throw ModuleException(modname + " can not be used with options:nonicknameownership enabled"); diff --git a/modules/commands/ns_identify.cpp b/modules/commands/ns_identify.cpp index 3404536e9..5d7ed4c95 100644 --- a/modules/commands/ns_identify.cpp +++ b/modules/commands/ns_identify.cpp @@ -83,7 +83,7 @@ class CommandNSIdentify : public Command else { NSIdentifyRequest *req = new NSIdentifyRequest(owner, source, this, na ? na->nc->display : nick, pass); - FOREACH_MOD(OnCheckAuthentication, (u, req)); + Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, u, req); req->Dispatch(); } return; diff --git a/modules/commands/ns_info.cpp b/modules/commands/ns_info.cpp index 75c82bd3e..16f51db07 100644 --- a/modules/commands/ns_info.cpp +++ b/modules/commands/ns_info.cpp @@ -10,11 +10,15 @@ */ #include "module.h" +#include "modules/ns_info.h" +#include "modules/ns_set.h" class CommandNSInfo : public Command { + EventHandlers<Event::NickInfo> &onnickinfo; + public: - CommandNSInfo(Module *creator) : Command(creator, "nickserv/info", 0, 2) + CommandNSInfo(Module *creator, EventHandlers<Event::NickInfo> &event) : Command(creator, "nickserv/info", 0, 2), onnickinfo(event) { this->SetDesc(_("Displays information about a given nickname")); this->SetSyntax(_("[\037nickname\037]")); @@ -104,7 +108,7 @@ class CommandNSInfo : public Command } } - FOREACH_MOD(OnNickInfo, (source, na, info, show_hidden)); + this->onnickinfo(&Event::NickInfo::OnNickInfo, source, na, info, show_hidden); std::vector<Anope::string> replies; info.Process(replies); @@ -154,8 +158,7 @@ class CommandNSSetHide : public Command } NickCore *nc = na->nc; - EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); + EventReturn MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) return; @@ -263,13 +266,20 @@ class NSInfo : public Module CommandNSSetHide commandnssethide; CommandNSSASetHide commandnssasethide; + EventHandlers<Event::NickInfo> onnickinfo; + SerializableExtensibleItem<bool> hide_email, hide_usermask, hide_status, hide_quit; public: - NSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsinfo(this), commandnssethide(this), commandnssasethide(this), - hide_email(this, "HIDE_EMAIL"), hide_usermask(this, "HIDE_MASK"), hide_status(this, "HIDE_STATUS"), - hide_quit(this, "HIDE_QUIT") + NSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandnsinfo(this, onnickinfo) + , commandnssethide(this) + , commandnssasethide(this) + , onnickinfo(this, "OnNickInfo") + , hide_email(this, "HIDE_EMAIL") + , hide_usermask(this, "HIDE_MASK") + , hide_status(this, "HIDE_STATUS") + , hide_quit(this, "HIDE_QUIT") { } diff --git a/modules/commands/ns_list.cpp b/modules/commands/ns_list.cpp index 6aedbf666..0037cbcc5 100644 --- a/modules/commands/ns_list.cpp +++ b/modules/commands/ns_list.cpp @@ -10,6 +10,8 @@ */ #include "module.h" +#include "modules/ns_info.h" +#include "modules/ns_set.h" class CommandNSList : public Command { @@ -203,8 +205,7 @@ class CommandNSSetPrivate : public Command } NickCore *nc = na->nc; - EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); + EventReturn MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) return; @@ -273,6 +274,7 @@ class CommandNSSASetPrivate : public CommandNSSetPrivate class NSList : public Module + , public EventHook<Event::NickInfo> { CommandNSList commandnslist; @@ -282,9 +284,12 @@ class NSList : public Module SerializableExtensibleItem<bool> priv; public: - NSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnslist(this), commandnssetprivate(this), commandnssasetprivate(this), - priv(this, "NS_PRIVATE") + NSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::NickInfo>("OnNickInfo") + , commandnslist(this) + , commandnssetprivate(this) + , commandnssasetprivate(this) + , priv(this, "NS_PRIVATE") { } diff --git a/modules/commands/ns_logout.cpp b/modules/commands/ns_logout.cpp index 6697e583f..a23fd26d2 100644 --- a/modules/commands/ns_logout.cpp +++ b/modules/commands/ns_logout.cpp @@ -10,8 +10,7 @@ */ #include "module.h" - -static ServiceReference<NickServService> NickServService("NickServService", "NickServ"); +#include "modules/nickserv.h" class CommandNSLogout : public Command { @@ -37,8 +36,8 @@ class CommandNSLogout : public Command source.Reply(_("You can't logout %s, they are a Services Operator."), nick.c_str()); else { - if (!nick.empty() && !param.empty() && param.equals_ci("REVALIDATE") && NickServService) - NickServService->Validate(u2); + if (!nick.empty() && !param.empty() && param.equals_ci("REVALIDATE") && NickServ::service) + NickServ::service->Validate(u2); u2->super_admin = false; /* Dont let people logout and remain a SuperAdmin */ Log(LOG_COMMAND, source, this) << "to logout " << u2->nick; @@ -54,7 +53,7 @@ class CommandNSLogout : public Command u2->Logout(); /* Send out an event */ - FOREACH_MOD(OnNickLogout, (u2)); + Event::OnNickLogout(&Event::NickLogout::OnNickLogout, u2); } return; } @@ -81,8 +80,8 @@ class NSLogout : public Module CommandNSLogout commandnslogout; public: - NSLogout(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnslogout(this) + NSLogout(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandnslogout(this) { } diff --git a/modules/commands/ns_recover.cpp b/modules/commands/ns_recover.cpp index c469fc17b..de83ea619 100644 --- a/modules/commands/ns_recover.cpp +++ b/modules/commands/ns_recover.cpp @@ -11,8 +11,7 @@ #include "module.h" #include "modules/ns_cert.h" - -static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); +#include "modules/nickserv.h" typedef std::map<Anope::string, ChannelStatus> NSRecoverInfo; @@ -40,7 +39,7 @@ class NSRecoverRequest : public IdentifyRequest /* Nick is being held by us, release it */ if (na->HasExt("HELD")) { - nickserv->Release(na); + NickServ::service->Release(na); source.Reply(_("Service's hold on \002%s\002 has been released."), na->nick.c_str()); } else if (!u) @@ -89,13 +88,13 @@ class NSRecoverRequest : public IdentifyRequest } u->SendMessage(source.service, _("This nickname has been recovered by %s."), source.GetNick().c_str()); - if (nickserv) - nickserv->Collide(u, na); + if (NickServ::service) + NickServ::service->Collide(u, na); if (IRCD->CanSVSNick) { /* If we can svsnick then release our hold and svsnick the user using the command */ - nickserv->Release(na); + NickServ::service->Release(na); IRCD->SendForceNickChange(source.GetUser(), GetAccount(), Anope::CurTime); } else @@ -170,7 +169,7 @@ class CommandNSRecover : public Command if (ok == false && !pass.empty()) { NSRecoverRequest *req = new NSRecoverRequest(owner, source, this, na->nick, pass); - FOREACH_MOD(OnCheckAuthentication, (source.GetUser(), req)); + Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, source.GetUser(), req); req->Dispatch(); } else @@ -199,13 +198,18 @@ class CommandNSRecover : public Command }; class NSRecover : public Module + , public EventHook<Event::UserNickChange> + , public EventHook<Event::JoinChannel> { CommandNSRecover commandnsrecover; PrimitiveExtensibleItem<NSRecoverInfo> recover; public: - NSRecover(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsrecover(this), recover(this, "recover") + NSRecover(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::UserNickChange>("OnUserNickChange") + , EventHook<Event::JoinChannel>("OnJoinChannel") + , commandnsrecover(this) + , recover(this, "recover") { if (Config->GetModule("nickserv")->Get<bool>("nonicknameownership")) diff --git a/modules/commands/ns_register.cpp b/modules/commands/ns_register.cpp index 052a0a799..802292c91 100644 --- a/modules/commands/ns_register.cpp +++ b/modules/commands/ns_register.cpp @@ -10,6 +10,7 @@ */ #include "module.h" +#include "modules/nickserv.h" static bool SendRegmail(User *u, const NickAlias *na, BotInfo *bi); @@ -198,7 +199,8 @@ class CommandNSRegister : public Command Log(LOG_COMMAND, source, this) << "to register " << na->nick << " (email: " << (!na->nc->email.empty() ? na->nc->email : "none") << ")"; - FOREACH_MOD(OnNickRegister, (source.GetUser(), na)); + if (NickServ::Event::OnNickRegister) + NickServ::Event::OnNickRegister(&NickServ::Event::NickRegister::OnNickRegister, source.GetUser(), na); if (na->nc->GetAccessCount()) source.Reply(_("Nickname \002%s\002 registered under your user@host-mask: %s"), u_nick.c_str(), na->nc->GetAccess(0).c_str()); @@ -331,6 +333,8 @@ class CommandNSResend : public Command }; class NSRegister : public Module + , public EventHook<Event::NickIdentify> + , public EventHook<NickServ::Event::PreNickExpire> { CommandNSRegister commandnsregister; CommandNSConfirm commandnsconfirm; @@ -340,9 +344,14 @@ class NSRegister : public Module SerializableExtensibleItem<Anope::string> passcode; public: - NSRegister(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsregister(this), commandnsconfirm(this), commandnsrsend(this), unconfirmed(this, "UNCONFIRMED"), - passcode(this, "passcode") + NSRegister(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::NickIdentify>("OnNickIdentify") + , EventHook<NickServ::Event::PreNickExpire>("OnPreNickExpire") + , commandnsregister(this) + , commandnsconfirm(this) + , commandnsrsend(this) + , unconfirmed(this, "UNCONFIRMED") + , passcode(this, "passcode") { if (Config->GetModule(this)->Get<const Anope::string>("registration").equals_ci("disable")) throw ModuleException("Module " + this->name + " will not load with registration disabled."); diff --git a/modules/commands/ns_resetpass.cpp b/modules/commands/ns_resetpass.cpp index 7494fca04..af5c43cb7 100644 --- a/modules/commands/ns_resetpass.cpp +++ b/modules/commands/ns_resetpass.cpp @@ -61,13 +61,15 @@ struct ResetInfo }; class NSResetPass : public Module + , public EventHook<Event::PreCommand> { CommandNSResetPass commandnsresetpass; PrimitiveExtensibleItem<ResetInfo> reset; public: - NSResetPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsresetpass(this), reset(this, "reset") + NSResetPass(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::PreCommand>("OnPreCommand") + , commandnsresetpass(this), reset(this, "reset") { if (!Config->GetBlock("mail")->Get<bool>("usemail")) throw ModuleException("Not using mail."); diff --git a/modules/commands/ns_set.cpp b/modules/commands/ns_set.cpp index 013843360..89f3c5e83 100644 --- a/modules/commands/ns_set.cpp +++ b/modules/commands/ns_set.cpp @@ -10,6 +10,9 @@ */ #include "module.h" +#include "modules/ns_info.h" +#include "modules/ns_set.h" +#include "modules/nickserv.h" class CommandNSSet : public Command { @@ -247,7 +250,7 @@ class CommandNSSetAutoOp : public Command NickCore *nc = na->nc; EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); + MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) return; @@ -349,7 +352,7 @@ class CommandNSSetDisplay : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, user_na->nc, param)); + MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, user_na->nc, param); if (MOD_RESULT == EVENT_STOP) return; @@ -472,7 +475,7 @@ class CommandNSSetEmail : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); + MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) return; @@ -563,7 +566,7 @@ class CommandNSSetKeepModes : public Command NickCore *nc = na->nc; EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); + MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) return; @@ -656,7 +659,7 @@ class CommandNSSetKill : public Command NickCore *nc = na->nc; EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); + MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) return; @@ -788,7 +791,7 @@ class CommandNSSetLanguage : public Command NickCore *nc = na->nc; EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); + MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) return; @@ -903,7 +906,7 @@ class CommandNSSetMessage : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); + MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) return; @@ -1001,7 +1004,7 @@ class CommandNSSetSecure : public Command NickCore *nc = na->nc; EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); + MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) return; @@ -1123,6 +1126,13 @@ class CommandNSSASetNoexpire : public Command }; class NSSet : public Module + , public EventHook<Event::PreCommand> + , public EventHook<Event::SetCorrectModes> + , public EventHook<NickServ::Event::PreNickExpire> + , public EventHook<Event::NickInfo> + , public EventHook<Event::UserModeSet> + , public EventHook<Event::UserModeUnset> + , public EventHook<Event::UserLogin> { CommandNSSet commandnsset; CommandNSSASet commandnssaset; @@ -1208,25 +1218,46 @@ class NSSet : public Module PrimitiveExtensibleItem<std::pair<Anope::string, Anope::string > > ns_set_email; public: - NSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsset(this), commandnssaset(this), - commandnssetautoop(this), commandnssasetautoop(this), - commandnssetdisplay(this), commandnssasetdisplay(this), - commandnssetemail(this), commandnssasetemail(this), - commandnssetkeepmodes(this), commandnssasetkeepmodes(this), - commandnssetkill(this), commandnssasetkill(this), - commandnssetlanguage(this), commandnssasetlanguage(this), - commandnssetmessage(this), commandnssasetmessage(this), - commandnssetpassword(this), commandnssasetpassword(this), - commandnssetsecure(this), commandnssasetsecure(this), - commandnssasetnoexpire(this), - - autoop(this, "AUTOOP"), - killprotect(this, "KILLPROTECT"), kill_quick(this, "KILL_QUICK"), - kill_immed(this, "KILL_IMMED"), message(this, "MSG"), - secure(this, "NS_SECURE"), noexpire(this, "NS_NO_EXPIRE"), - - keep_modes(this, "NS_KEEP_MODES"), ns_set_email(this, "ns_set_email") + NSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::PreCommand>("OnPreCommand") + , EventHook<Event::SetCorrectModes>("OnSetCorrectModes") + , EventHook<NickServ::Event::PreNickExpire>("OnPreNickExpire") + , EventHook<Event::NickInfo>("OnNickInfo") + , EventHook<Event::UserModeSet>("OnUserModeSet") + , EventHook<Event::UserModeUnset>("OnUserModeUnset") + , EventHook<Event::UserLogin>("OnUserLogin") + , commandnsset(this) + , commandnssaset(this) + , commandnssetautoop(this) + , commandnssasetautoop(this) + , commandnssetdisplay(this) + , commandnssasetdisplay(this) + , commandnssetemail(this) + , commandnssasetemail(this) + , commandnssetkeepmodes(this) + , commandnssasetkeepmodes(this) + , commandnssetkill(this) + , commandnssasetkill(this) + , commandnssetlanguage(this) + , commandnssasetlanguage(this) + , commandnssetmessage(this) + , commandnssasetmessage(this) + , commandnssetpassword(this) + , commandnssasetpassword(this) + , commandnssetsecure(this) + , commandnssasetsecure(this) + , commandnssasetnoexpire(this) + + , autoop(this, "AUTOOP") + , killprotect(this, "KILLPROTECT") + , kill_quick(this, "KILL_QUICK") + , kill_immed(this, "KILL_IMMED") + , message(this, "MSG") + , secure(this, "NS_SECURE") + , noexpire(this, "NS_NO_EXPIRE") + + , keep_modes(this, "NS_KEEP_MODES") + , ns_set_email(this, "ns_set_email") { } diff --git a/modules/commands/ns_set_misc.cpp b/modules/commands/ns_set_misc.cpp index 73e3b169a..bf3ea8660 100644 --- a/modules/commands/ns_set_misc.cpp +++ b/modules/commands/ns_set_misc.cpp @@ -11,6 +11,8 @@ #include "module.h" #include "modules/set_misc.h" +#include "modules/ns_info.h" +#include "modules/ns_set.h" static Module *me; @@ -112,8 +114,7 @@ class CommandNSSetMisc : public Command } NickCore *nc = na->nc; - EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, nc, param)); + EventReturn MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, nc, param); if (MOD_RESULT == EVENT_STOP) return; @@ -176,14 +177,18 @@ class CommandNSSASetMisc : public CommandNSSetMisc }; class NSSetMisc : public Module + , public EventHook<Event::NickInfo> { CommandNSSetMisc commandnssetmisc; CommandNSSASetMisc commandnssasetmisc; Serialize::Type nsmiscdata_type; public: - NSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnssetmisc(this), commandnssasetmisc(this), nsmiscdata_type("NSMiscData", NSMiscData::Unserialize) + NSSetMisc(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::NickInfo>("OnNickInfo") + , commandnssetmisc(this) + , commandnssasetmisc(this) + , nsmiscdata_type("NSMiscData", NSMiscData::Unserialize) { me = this; } diff --git a/modules/commands/ns_status.cpp b/modules/commands/ns_status.cpp index e0f068490..f4c8c7192 100644 --- a/modules/commands/ns_status.cpp +++ b/modules/commands/ns_status.cpp @@ -77,8 +77,8 @@ class NSStatus : public Module CommandNSStatus commandnsstatus; public: - NSStatus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsstatus(this) + NSStatus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandnsstatus(this) { } diff --git a/modules/commands/ns_suspend.cpp b/modules/commands/ns_suspend.cpp index 27bb5c0bb..ca669d537 100644 --- a/modules/commands/ns_suspend.cpp +++ b/modules/commands/ns_suspend.cpp @@ -11,8 +11,8 @@ #include "module.h" #include "modules/suspend.h" - -static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); +#include "modules/ns_info.h" +#include "modules/nickserv.h" struct NSSuspendInfo : SuspendInfo, Serializable { @@ -54,8 +54,10 @@ struct NSSuspendInfo : SuspendInfo, Serializable class CommandNSSuspend : public Command { + EventHandlers<Event::NickSuspend> &onnicksuspend; + public: - CommandNSSuspend(Module *creator) : Command(creator, "nickserv/suspend", 2, 3) + CommandNSSuspend(Module *creator, EventHandlers<Event::NickSuspend> &event) : Command(creator, "nickserv/suspend", 2, 3), onnicksuspend(event) { this->SetDesc(_("Suspend a given nick")); this->SetSyntax(_("\037nickname\037 [+\037expiry\037] [\037reason\037]")); @@ -128,8 +130,8 @@ class CommandNSSuspend : public Command if (u2) { u2->Logout(); - if (nickserv) - nickserv->Collide(u2, na2); + if (NickServ::service) + NickServ::service->Collide(u2, na2); } } } @@ -137,7 +139,7 @@ class CommandNSSuspend : public Command Log(LOG_ADMIN, source, this) << "for " << nick << " (" << (!reason.empty() ? reason : "No reason") << "), expires on " << (expiry_secs ? Anope::strftime(Anope::CurTime + expiry_secs) : "never"); source.Reply(_("Nick %s is now suspended."), nick.c_str()); - FOREACH_MOD(OnNickSuspend, (na)); + this->onnicksuspend(&Event::NickSuspend::OnNickSuspend, na); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -154,8 +156,10 @@ class CommandNSSuspend : public Command class CommandNSUnSuspend : public Command { + EventHandlers<Event::NickUnsuspended> &onnickunsuspend; + public: - CommandNSUnSuspend(Module *creator) : Command(creator, "nickserv/unsuspend", 1, 1) + CommandNSUnSuspend(Module *creator, EventHandlers<Event::NickUnsuspended> &event) : Command(creator, "nickserv/unsuspend", 1, 1), onnickunsuspend(event) { this->SetDesc(_("Unsuspend a given nick")); this->SetSyntax(_("\037nickname\037")); @@ -189,7 +193,7 @@ class CommandNSUnSuspend : public Command source.Reply(_("Nick %s is now released."), nick.c_str()); - FOREACH_MOD(OnNickUnsuspended, (na)); + this->onnickunsuspend(&Event::NickUnsuspended::OnNickUnsuspended, na); } bool OnHelp(CommandSource &source, const Anope::string &subcommand) override @@ -202,16 +206,28 @@ class CommandNSUnSuspend : public Command }; class NSSuspend : public Module + , public EventHook<Event::NickInfo> + , public EventHook<NickServ::Event::PreNickExpire> + , public EventHook<NickServ::Event::NickValidate> { CommandNSSuspend commandnssuspend; CommandNSUnSuspend commandnsunsuspend; ExtensibleItem<NSSuspendInfo> suspend; Serialize::Type suspend_type; + EventHandlers<Event::NickSuspend> onnicksuspend; + EventHandlers<Event::NickUnsuspended> onnickunsuspend; public: - NSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnssuspend(this), commandnsunsuspend(this), suspend(this, "NS_SUSPENDED"), - suspend_type("NSSuspendInfo", NSSuspendInfo::Unserialize) + NSSuspend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::NickInfo>("OnNickInfo") + , EventHook<NickServ::Event::PreNickExpire>("OnPreNickExpire") + , EventHook<NickServ::Event::NickValidate>("OnNickValidate") + , commandnssuspend(this, onnicksuspend) + , commandnsunsuspend(this, onnickunsuspend) + , suspend(this, "NS_SUSPENDED") + , suspend_type("NSSuspendInfo", NSSuspendInfo::Unserialize) + , onnicksuspend(this, "OnNickSuspend") + , onnickunsuspend(this, "OnNickUnsuspended") { } diff --git a/modules/commands/ns_update.cpp b/modules/commands/ns_update.cpp index 8f5ddc330..1fa9c5b36 100644 --- a/modules/commands/ns_update.cpp +++ b/modules/commands/ns_update.cpp @@ -10,11 +10,14 @@ */ #include "module.h" +#include "modules/ns_update.h" class CommandNSUpdate : public Command { + EventHandlers<Event::NickUpdate> &onnickupdate; + public: - CommandNSUpdate(Module *creator) : Command(creator, "nickserv/update", 0, 0) + CommandNSUpdate(Module *creator, EventHandlers<Event::NickUpdate> &event) : Command(creator, "nickserv/update", 0, 0), onnickupdate(event) { this->SetDesc(_("Updates your current status, i.e. it checks for new memos")); this->RequireUser(true); @@ -31,7 +34,7 @@ class CommandNSUpdate : public Command na->last_seen = Anope::CurTime; } - FOREACH_MOD(OnNickUpdate, (u)); + this->onnickupdate(&Event::NickUpdate::OnNickUpdate, u); source.Reply(_("Status updated (memos, vhost, chmodes, flags).")); } @@ -50,10 +53,12 @@ class CommandNSUpdate : public Command class NSUpdate : public Module { CommandNSUpdate commandnsupdate; + EventHandlers<Event::NickUpdate> onnickupdate; public: - NSUpdate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandnsupdate(this) + NSUpdate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandnsupdate(this, onnickupdate) + , onnickupdate(this, "OnNickUpdate") { } diff --git a/modules/commands/os_akill.cpp b/modules/commands/os_akill.cpp index 81dd69ed2..971b284e5 100644 --- a/modules/commands/os_akill.cpp +++ b/modules/commands/os_akill.cpp @@ -174,7 +174,7 @@ class CommandOSAKill : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnAddXLine, MOD_RESULT, (source, x, akills)); + MOD_RESULT = Event::OnAddXLine(&Event::AddXLine::OnAddXLine, source, x, akills); if (MOD_RESULT == EVENT_STOP) { delete x; @@ -225,7 +225,7 @@ class CommandOSAKill : public Command do { - FOREACH_MOD(OnDelXLine, (source, x, akills)); + Event::OnDelXLine(&Event::DelXLine::OnDelXLine, source, x, akills); Log(LOG_ADMIN, source, this) << "to remove " << x->mask << " from the list"; source.Reply(_("\002%s\002 deleted from the AKILL list."), x->mask.c_str()); @@ -349,7 +349,7 @@ class CommandOSAKill : public Command for (unsigned i = akills->GetCount(); i > 0; --i) { XLine *x = akills->GetEntry(i - 1); - FOREACH_MOD(OnDelXLine, (source, x, akills)); + Event::OnDelXLine(&Event::DelXLine::OnDelXLine, source, x, akills); akills->DelXLine(x); } @@ -453,8 +453,8 @@ class OSAKill : public Module CommandOSAKill commandosakill; public: - OSAKill(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosakill(this) + OSAKill(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandosakill(this) { } diff --git a/modules/commands/os_chankill.cpp b/modules/commands/os_chankill.cpp index ef569912b..060258705 100644 --- a/modules/commands/os_chankill.cpp +++ b/modules/commands/os_chankill.cpp @@ -105,8 +105,8 @@ class OSChanKill : public Module CommandOSChanKill commandoschankill; public: - OSChanKill(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandoschankill(this) + OSChanKill(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandoschankill(this) { } diff --git a/modules/commands/os_config.cpp b/modules/commands/os_config.cpp index e12338924..e81030bc9 100644 --- a/modules/commands/os_config.cpp +++ b/modules/commands/os_config.cpp @@ -140,8 +140,8 @@ class OSConfig : public Module CommandOSConfig commandosconfig; public: - OSConfig(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosconfig(this) + OSConfig(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandosconfig(this) { } diff --git a/modules/commands/os_defcon.cpp b/modules/commands/os_defcon.cpp index 8b2f8a1c8..ee3a10d13 100644 --- a/modules/commands/os_defcon.cpp +++ b/modules/commands/os_defcon.cpp @@ -11,6 +11,8 @@ #include "module.h" #include "modules/os_session.h" +#include "modules/os_defcon.h" +#include "modules/global.h" enum DefconLevel { @@ -101,16 +103,15 @@ static DefconConfig DConfig; static void runDefCon(); static Anope::string defconReverseModes(const Anope::string &modes); -static ServiceReference<GlobalService> GlobalService("GlobalService", "Global"); - static Timer *timeout; class DefConTimeout : public Timer { + EventHandlers<Event::DefconLevel> &eventdefcon; int level; public: - DefConTimeout(Module *mod, int newlevel) : Timer(mod, DConfig.timeout), level(newlevel) + DefConTimeout(EventHandlers<Event::DefconLevel> &ev, Module *mod, int newlevel) : Timer(mod, DConfig.timeout), eventdefcon(ev), level(newlevel) { timeout = this; } @@ -125,18 +126,18 @@ class DefConTimeout : public Timer if (DConfig.defaultlevel != level) { DConfig.defaultlevel = level; - FOREACH_MOD(OnDefconLevel, (level)); + this->eventdefcon(&Event::DefconLevel::OnDefconLevel, level); Log(Config->GetClient("OperServ"), "operserv/defcon") << "Defcon level timeout, returning to level " << level; - if (DConfig.globalondefcon) + if (DConfig.globalondefcon && Global::service) { if (!DConfig.offmessage.empty()) - GlobalService->SendGlobal(NULL, "", DConfig.offmessage); + Global::service->SendGlobal(NULL, "", DConfig.offmessage); else - GlobalService->SendGlobal(NULL, "", Anope::printf(Language::Translate(_("The Defcon level is now at: \002%d\002")), DConfig.defaultlevel)); + Global::service->SendGlobal(NULL, "", Anope::printf(Language::Translate(_("The Defcon level is now at: \002%d\002")), DConfig.defaultlevel)); if (!DConfig.message.empty()) - GlobalService->SendGlobal(NULL, "", DConfig.message); + Global::service->SendGlobal(NULL, "", DConfig.message); } runDefCon(); @@ -170,8 +171,10 @@ class CommandOSDefcon : public Command source.Reply(_("* No new memos sent")); } + EventHandlers<Event::DefconLevel> &ondefconlevel; + public: - CommandOSDefcon(Module *creator) : Command(creator, "operserv/defcon", 1, 1) + CommandOSDefcon(Module *creator, EventHandlers<Event::DefconLevel> &event) : Command(creator, "operserv/defcon", 1, 1), ondefconlevel(event) { this->SetDesc(_("Manipulate the DefCon system")); this->SetSyntax(_("[\0021\002|\0022\002|\0023\002|\0024\002|\0025\002]")); @@ -203,12 +206,12 @@ class CommandOSDefcon : public Command DConfig.defaultlevel = newLevel; - FOREACH_MOD(OnDefconLevel, (newLevel)); + this->ondefconlevel(&Event::DefconLevel::OnDefconLevel, newLevel); delete timeout; if (DConfig.timeout) - timeout = new DefConTimeout(this->module, 5); + timeout = new DefConTimeout(this->ondefconlevel, this->module, 5); source.Reply(_("Services are now at DEFCON \002%d\002."), DConfig.defaultlevel); this->SendLevels(source); @@ -216,15 +219,15 @@ class CommandOSDefcon : public Command /* Global notice the user what is happening. Also any Message that the Admin would like to add. Set in config file. */ - if (DConfig.globalondefcon) + if (DConfig.globalondefcon && Global::service) { if (DConfig.defaultlevel == 5 && !DConfig.offmessage.empty()) - GlobalService->SendGlobal(NULL, "", DConfig.offmessage); + Global::service->SendGlobal(NULL, "", DConfig.offmessage); else if (DConfig.defaultlevel != 5) { - GlobalService->SendGlobal(NULL, "", Anope::printf(_("The Defcon level is now at: \002%d\002"), DConfig.defaultlevel)); + Global::service->SendGlobal(NULL, "", Anope::printf(_("The Defcon level is now at: \002%d\002"), DConfig.defaultlevel)); if (!DConfig.message.empty()) - GlobalService->SendGlobal(NULL, "", DConfig.message); + Global::service->SendGlobal(NULL, "", DConfig.message); } } @@ -245,10 +248,17 @@ class CommandOSDefcon : public Command }; class OSDefcon : public Module + , public EventHook<Event::ChannelModeSet> + , public EventHook<Event::ChannelModeUnset> + , public EventHook<Event::PreCommand> + , public EventHook<Event::UserConnect> + , public EventHook<Event::ChannelModeAdd> + , public EventHook<Event::ChannelSync> { ServiceReference<SessionService> session_service; ServiceReference<XLineManager> akills; CommandOSDefcon commandosdefcon; + EventHandlers<Event::DefconLevel> ondefconlevel; void ParseModeString() { @@ -330,11 +340,26 @@ class OSDefcon : public Module } public: - OSDefcon(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), session_service("SessionService", "session"), akills("XLineManager", "xlinemanager/sgline"), commandosdefcon(this) + OSDefcon(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::ChannelModeSet>("OnChannelModeSet") + , EventHook<Event::ChannelModeUnset>("OnChannelModeUnset") + , EventHook<Event::PreCommand>("OnPreCommand") + , EventHook<Event::UserConnect>("OnUserConnect") + , EventHook<Event::ChannelModeAdd>("OnChannelModeAdd") + , EventHook<Event::ChannelSync>("OnChannelSync") + , session_service("SessionService", "session") + , akills("XLineManager", "xlinemanager/sgline") + , commandosdefcon(this, ondefconlevel) + , ondefconlevel(this, "OnDefconLevel") { } + ~OSDefcon() + { + delete timeout; + } + void OnReload(Configuration::Conf *conf) override { Configuration::Block *block = conf->GetModule(this); diff --git a/modules/commands/os_dns.cpp b/modules/commands/os_dns.cpp index f58c29e98..d76ad451f 100644 --- a/modules/commands/os_dns.cpp +++ b/modules/commands/os_dns.cpp @@ -716,6 +716,11 @@ class CommandOSDNS : public Command }; class ModuleDNS : public Module + , public EventHook<Event::NewServer> + , public EventHook<Event::ServerQuit> + , public EventHook<Event::UserConnect> + , public EventHook<Event::PreUserLogoff> + , public EventHook<Event::DnsRequest> { Serialize::Type zone_type, dns_type; CommandOSDNS commandosdns; @@ -730,9 +735,16 @@ class ModuleDNS : public Module time_t last_warn; public: - ModuleDNS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), - zone_type("DNSZone", DNSZone::Unserialize), dns_type("DNSServer", DNSServer::Unserialize), commandosdns(this), - last_warn(0) + ModuleDNS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , EventHook<Event::NewServer>("OnNewServer") + , EventHook<Event::ServerQuit>("OnServerQuit") + , EventHook<Event::UserConnect>("OnUserConnect") + , EventHook<Event::PreUserLogoff>("OnPreUserLogoff") + , EventHook<Event::DnsRequest>("OnDnsRequest") + , zone_type("DNSZone", DNSZone::Unserialize) + , dns_type("DNSServer", DNSServer::Unserialize) + , commandosdns(this) + , last_warn(0) { diff --git a/modules/commands/os_forbid.cpp b/modules/commands/os_forbid.cpp index f13b72cf9..1f54f804f 100644 --- a/modules/commands/os_forbid.cpp +++ b/modules/commands/os_forbid.cpp @@ -11,8 +11,8 @@ #include "module.h" #include "modules/os_forbid.h" - -static ServiceReference<NickServService> nickserv("NickServService", "NickServ"); +#include "modules/nickserv.h" +#include "modules/chanserv.h" struct ForbidDataImpl : ForbidData, Serializable { @@ -147,6 +147,24 @@ class CommandOSForbid : public Command this->SetSyntax("LIST [NICK|CHAN|EMAIL|REGISTER]"); } + void OnUserNickChange(User *u) + { + if (u->HasMode("OPER")) + return; + + ForbidData *d = fs->FindForbid(u->nick, FT_NICK); + if (d != NULL) + { + BotInfo *bi = Config->GetClient("NickServ"); + if (!bi) + bi = Config->GetClient("OperServ"); + if (bi) + u->SendMessage(bi, _("This nickname has been forbidden: %s"), d->reason.c_str()); + if (NickServ::service) + NickServ::service->Collide(u, NULL); + } + } + void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { if (!this->fs) @@ -234,7 +252,7 @@ class CommandOSForbid : public Command int na_matches = 0; for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) - module->OnUserNickChange(it->second, ""); + this->OnUserNickChange(it->second); for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end;) { @@ -266,7 +284,6 @@ class CommandOSForbid : public Command if (d == NULL) continue; - ServiceReference<ChanServService> chanserv("ChanServService", "ChanServ"); BotInfo *OperServ = Config->GetClient("OperServ"); if (IRCD->CanSQLineChannel && OperServ) { @@ -274,9 +291,9 @@ class CommandOSForbid : public Command XLine x(c->name, OperServ->nick, Anope::CurTime + inhabit, d->reason); IRCD->SendSQLine(NULL, &x); } - else if (chanserv) + else if (ChanServ::service) { - chanserv->Hold(c); + ChanServ::service->Hold(c); } ++chan_matches; @@ -422,14 +439,24 @@ class CommandOSForbid : public Command }; class OSForbid : public Module + , public EventHook<Event::UserConnect> + , public EventHook<Event::UserNickChange> + , public EventHook<Event::CheckKick> + , public EventHook<Event::PreCommand> { MyForbidService forbidService; Serialize::Type forbiddata_type; CommandOSForbid commandosforbid; public: - OSForbid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - forbidService(this), forbiddata_type("ForbidData", ForbidDataImpl::Unserialize), commandosforbid(this) + OSForbid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::UserConnect>("OnUserConnect") + , EventHook<Event::UserNickChange>("OnUserNickChange") + , EventHook<Event::CheckKick>("OnCheckKick") + , EventHook<Event::PreCommand>("OnPreCommand") + , forbidService(this) + , forbiddata_type("ForbidData", ForbidDataImpl::Unserialize) + , commandosforbid(this) { } @@ -439,25 +466,12 @@ class OSForbid : public Module if (u->Quitting() || exempt) return; - this->OnUserNickChange(u, ""); + commandosforbid.OnUserNickChange(u); } void OnUserNickChange(User *u, const Anope::string &) override { - if (u->HasMode("OPER")) - return; - - ForbidData *d = this->forbidService.FindForbid(u->nick, FT_NICK); - if (d != NULL) - { - BotInfo *bi = Config->GetClient("NickServ"); - if (!bi) - bi = Config->GetClient("OperServ"); - if (bi) - u->SendMessage(bi, _("This nickname has been forbidden: %s"), d->reason.c_str()); - if (nickserv) - nickserv->Collide(u, NULL); - } + commandosforbid.OnUserNickChange(u); } EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override @@ -469,16 +483,15 @@ class OSForbid : public Module ForbidData *d = this->forbidService.FindForbid(c->name, FT_CHAN); if (d != NULL) { - ServiceReference<ChanServService> chanserv("ChanServService", "ChanServ"); if (IRCD->CanSQLineChannel) { time_t inhabit = Config->GetModule("chanserv")->Get<time_t>("inhabit", "15s"); XLine x(c->name, OperServ->nick, Anope::CurTime + inhabit, d->reason); IRCD->SendSQLine(NULL, &x); } - else if (chanserv) + else if (ChanServ::service) { - chanserv->Hold(c); + ChanServ::service->Hold(c); } reason = Anope::printf(Language::Translate(u, _("This channel has been forbidden: %s")), d->reason.c_str()); diff --git a/modules/commands/os_ignore.cpp b/modules/commands/os_ignore.cpp index d5a2774bc..fa6537a21 100644 --- a/modules/commands/os_ignore.cpp +++ b/modules/commands/os_ignore.cpp @@ -392,14 +392,18 @@ class CommandOSIgnore : public Command }; class OSIgnore : public Module + , public EventHook<Event::BotPrivmsg> { Serialize::Type ignoredata_type; OSIgnoreService osignoreservice; CommandOSIgnore commandosignore; public: - OSIgnore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - ignoredata_type("IgnoreData", IgnoreDataImpl::Unserialize), osignoreservice(this), commandosignore(this) + OSIgnore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::BotPrivmsg>("OnBotPrivmsg") + , ignoredata_type("IgnoreData", IgnoreDataImpl::Unserialize) + , osignoreservice(this) + , commandosignore(this) { } diff --git a/modules/commands/os_info.cpp b/modules/commands/os_info.cpp index 462fbbc4c..53b5fecd6 100644 --- a/modules/commands/os_info.cpp +++ b/modules/commands/os_info.cpp @@ -7,6 +7,8 @@ */ #include "module.h" +#include "modules/ns_info.h" +#include "modules/cs_info.h" struct OperInfo : Serializable { @@ -248,6 +250,8 @@ class CommandOSInfo : public Command }; class OSInfo : public Module + , public EventHook<Event::NickInfo> + , public EventHook<Event::ChanInfo> { CommandOSInfo commandosinfo; ExtensibleItem<OperInfos> oinfo; @@ -270,8 +274,12 @@ class OSInfo : public Module } public: - OSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosinfo(this), oinfo(this, "operinfo"), oinfo_type("OperInfo", OperInfo::Unserialize) + OSInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::NickInfo>("OnNickInfo") + , EventHook<Event::ChanInfo>("OnChanInfo") + , commandosinfo(this) + , oinfo(this, "operinfo") + , oinfo_type("OperInfo", OperInfo::Unserialize) { } diff --git a/modules/commands/os_jupe.cpp b/modules/commands/os_jupe.cpp index 3e0fad425..08fb6a4ce 100644 --- a/modules/commands/os_jupe.cpp +++ b/modules/commands/os_jupe.cpp @@ -70,8 +70,8 @@ class OSJupe : public Module CommandOSJupe commandosjupe; public: - OSJupe(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosjupe(this) + OSJupe(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandosjupe(this) { } diff --git a/modules/commands/os_kick.cpp b/modules/commands/os_kick.cpp index 20a967575..a1ae346a9 100644 --- a/modules/commands/os_kick.cpp +++ b/modules/commands/os_kick.cpp @@ -68,8 +68,8 @@ class OSKick : public Module CommandOSKick commandoskick; public: - OSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandoskick(this) + OSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandoskick(this) { } diff --git a/modules/commands/os_kill.cpp b/modules/commands/os_kill.cpp index b36e68df9..491e8b1c4 100644 --- a/modules/commands/os_kill.cpp +++ b/modules/commands/os_kill.cpp @@ -57,8 +57,8 @@ class OSKill : public Module CommandOSKill commandoskill; public: - OSKill(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandoskill(this) + OSKill(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandoskill(this) { } diff --git a/modules/commands/os_list.cpp b/modules/commands/os_list.cpp index d91b68938..fc077eac9 100644 --- a/modules/commands/os_list.cpp +++ b/modules/commands/os_list.cpp @@ -236,8 +236,9 @@ class OSList : public Module CommandOSUserList commandosuserlist; public: - OSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandoschanlist(this), commandosuserlist(this) + OSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandoschanlist(this) + , commandosuserlist(this) { } diff --git a/modules/commands/os_login.cpp b/modules/commands/os_login.cpp index d21eef468..e55459d24 100644 --- a/modules/commands/os_login.cpp +++ b/modules/commands/os_login.cpp @@ -105,14 +105,18 @@ class CommandOSLogout : public Command }; class OSLogin : public Module + , public EventHook<Event::IsServicesOperEvent> { CommandOSLogin commandoslogin; CommandOSLogout commandoslogout; ExtensibleItem<bool> os_login; public: - OSLogin(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandoslogin(this), commandoslogout(this), os_login(this, "os_login") + OSLogin(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::IsServicesOperEvent>("OnIsServicesOperEvent") + , commandoslogin(this) + , commandoslogout(this) + , os_login(this, "os_login") { } diff --git a/modules/commands/os_logsearch.cpp b/modules/commands/os_logsearch.cpp index fb9a75637..cba659957 100644 --- a/modules/commands/os_logsearch.cpp +++ b/modules/commands/os_logsearch.cpp @@ -147,8 +147,8 @@ class OSLogSearch : public Module CommandOSLogSearch commandoslogsearch; public: - OSLogSearch(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandoslogsearch(this) + OSLogSearch(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandoslogsearch(this) { } }; diff --git a/modules/commands/os_mode.cpp b/modules/commands/os_mode.cpp index 167f654af..7358e4c78 100644 --- a/modules/commands/os_mode.cpp +++ b/modules/commands/os_mode.cpp @@ -174,8 +174,9 @@ class OSMode : public Module CommandOSUMode commandosumode; public: - OSMode(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosmode(this), commandosumode(this) + OSMode(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandosmode(this) + , commandosumode(this) { } diff --git a/modules/commands/os_modinfo.cpp b/modules/commands/os_modinfo.cpp index f8b05bff8..e8c2caa69 100644 --- a/modules/commands/os_modinfo.cpp +++ b/modules/commands/os_modinfo.cpp @@ -204,8 +204,9 @@ class OSModInfo : public Module CommandOSModList commandosmodlist; public: - OSModInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosmodinfo(this), commandosmodlist(this) + OSModInfo(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandosmodinfo(this) + , commandosmodlist(this) { } diff --git a/modules/commands/os_module.cpp b/modules/commands/os_module.cpp index f1d113265..c4f814ee3 100644 --- a/modules/commands/os_module.cpp +++ b/modules/commands/os_module.cpp @@ -177,8 +177,10 @@ class OSModule : public Module CommandOSModUnLoad commandosmodunload; public: - OSModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosmodload(this), commandosmodreload(this), commandosmodunload(this) + OSModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandosmodload(this) + , commandosmodreload(this) + , commandosmodunload(this) { this->SetPermanent(true); diff --git a/modules/commands/os_news.cpp b/modules/commands/os_news.cpp index 1ecc9773d..62379e30a 100644 --- a/modules/commands/os_news.cpp +++ b/modules/commands/os_news.cpp @@ -370,6 +370,8 @@ class CommandOSRandomNews : public NewsBase static unsigned cur_rand_news = 0; class OSNews : public Module + , public EventHook<Event::UserModeSet> + , public EventHook<Event::UserConnect> { MyNewsService newsservice; Serialize::Type newsitem_type; @@ -428,9 +430,14 @@ class OSNews : public Module } public: - OSNews(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - newsservice(this), newsitem_type("NewsItem", MyNewsItem::Unserialize), - commandoslogonnews(this), commandosopernews(this), commandosrandomnews(this) + OSNews(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::UserModeSet>("OnUserModeSet") + , EventHook<Event::UserConnect>("OnUserConnect") + , newsservice(this) + , newsitem_type("NewsItem", MyNewsItem::Unserialize) + , commandoslogonnews(this) + , commandosopernews(this) + , commandosrandomnews(this) { } diff --git a/modules/commands/os_noop.cpp b/modules/commands/os_noop.cpp index 2eb818451..061624724 100644 --- a/modules/commands/os_noop.cpp +++ b/modules/commands/os_noop.cpp @@ -74,13 +74,16 @@ class CommandOSNOOP : public Command }; class OSNOOP : public Module + , public EventHook<Event::UserModeSet> { CommandOSNOOP commandosnoop; PrimitiveExtensibleItem<Anope::string> noop; public: - OSNOOP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosnoop(this), noop(this, "noop") + OSNOOP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::UserModeSet>("OnUserModeSet") + , commandosnoop(this) + , noop(this, "noop") { } diff --git a/modules/commands/os_oline.cpp b/modules/commands/os_oline.cpp index 143924b47..6d1d5d443 100644 --- a/modules/commands/os_oline.cpp +++ b/modules/commands/os_oline.cpp @@ -65,8 +65,8 @@ class OSOLine : public Module CommandOSOLine commandosoline; public: - OSOLine(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosoline(this) + OSOLine(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandosoline(this) { if (!IRCD || !IRCD->CanSVSO) diff --git a/modules/commands/os_oper.cpp b/modules/commands/os_oper.cpp index cd9eddfdb..a18b022ab 100644 --- a/modules/commands/os_oper.cpp +++ b/modules/commands/os_oper.cpp @@ -235,8 +235,9 @@ class OSOper : public Module CommandOSOper commandosoper; public: - OSOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - myoper_type("Oper", MyOper::Unserialize), commandosoper(this) + OSOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , myoper_type("Oper", MyOper::Unserialize) + , commandosoper(this) { } diff --git a/modules/commands/os_reload.cpp b/modules/commands/os_reload.cpp index 140118ba4..647f187b4 100644 --- a/modules/commands/os_reload.cpp +++ b/modules/commands/os_reload.cpp @@ -54,8 +54,8 @@ class OSReload : public Module CommandOSReload commandosreload; public: - OSReload(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosreload(this) + OSReload(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandosreload(this) { } diff --git a/modules/commands/os_session.cpp b/modules/commands/os_session.cpp index 94a2f9f0f..9cb525b4d 100644 --- a/modules/commands/os_session.cpp +++ b/modules/commands/os_session.cpp @@ -33,6 +33,8 @@ namespace /* Number of bits to use when comparing session IPs */ unsigned ipv4_cidr; unsigned ipv6_cidr; + + EventHandlers<Event::Exception> *events; } class MySessionService : public SessionService @@ -163,7 +165,7 @@ class ExceptionDelCallback : public NumberList static void DoDel(CommandSource &source, unsigned index) { Exception *e = session_service->GetExceptions()[index]; - FOREACH_MOD(OnExceptionDel, (source, e)); + (*events)(&Event::Exception::OnExceptionDel, source, e); session_service->DelException(e); delete e; @@ -372,7 +374,7 @@ class CommandOSException : public Command exception->expires = expires; EventReturn MOD_RESULT; - FOREACH_RESULT(OnExceptionAdd, MOD_RESULT, (exception)); + MOD_RESULT = (*events)(&Event::Exception::OnExceptionAdd, exception); if (MOD_RESULT == EVENT_STOP) delete exception; else @@ -627,20 +629,32 @@ class CommandOSException : public Command }; class OSSession : public Module + , public EventHook<Event::UserConnect> + , public EventHook<Event::UserQuit> + , public EventHook<Event::ExpireTick> { Serialize::Type exception_type; MySessionService ss; CommandOSSession commandossession; CommandOSException commandosexception; ServiceReference<XLineManager> akills; + EventHandlers<Event::Exception> exceptionevents; public: - OSSession(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - exception_type("Exception", Exception::Unserialize), ss(this), commandossession(this), commandosexception(this), akills("XLineManager", "xlinemanager/sgline") + OSSession(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::UserConnect>("OnUserConnect", EventHook<Event::UserConnect>::Priority::FIRST) + , EventHook<Event::UserQuit>("OnUserQuit", EventHook<Event::UserQuit>::Priority::FIRST) + , EventHook<Event::ExpireTick>("OnExpireTick", EventHook<Event::ExpireTick>::Priority::FIRST) + , exception_type("Exception", Exception::Unserialize) + , ss(this) + , commandossession(this) + , commandosexception(this) + , akills("XLineManager", "xlinemanager/sgline") + , exceptionevents(this, "Exception") { this->SetPermanent(true); - ModuleManager::SetPriority(this, PRIORITY_FIRST); + events = &exceptionevents; } void OnReload(Configuration::Conf *conf) override diff --git a/modules/commands/os_set.cpp b/modules/commands/os_set.cpp index 1f8959408..bc58b7dc1 100644 --- a/modules/commands/os_set.cpp +++ b/modules/commands/os_set.cpp @@ -258,8 +258,8 @@ class OSSet : public Module CommandOSSet commandosset; public: - OSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosset(this) + OSSet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandosset(this) { } }; diff --git a/modules/commands/os_stats.cpp b/modules/commands/os_stats.cpp index c5ab3459c..d55bdb1dc 100644 --- a/modules/commands/os_stats.cpp +++ b/modules/commands/os_stats.cpp @@ -253,8 +253,9 @@ class OSStats : public Module Stats stats_saver; public: - OSStats(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosstats(this), stats_type("Stats", Stats::Unserialize) + OSStats(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandosstats(this) + , stats_type("Stats", Stats::Unserialize) { } diff --git a/modules/commands/os_sxline.cpp b/modules/commands/os_sxline.cpp index 20b937bb0..43ae2b7d4 100644 --- a/modules/commands/os_sxline.cpp +++ b/modules/commands/os_sxline.cpp @@ -93,7 +93,7 @@ class CommandOSSXLineBase : public Command return; } - FOREACH_MOD(OnDelXLine, (source, x, this->xlm())); + Event::OnDelXLine(&Event::DelXLine::OnDelXLine, source, x, this->xlm()); SXLineDelCallback::DoDel(this->xlm(), source, x); source.Reply(_("\002%s\002 deleted from the %s list."), mask.c_str(), source.command.c_str()); @@ -202,7 +202,7 @@ class CommandOSSXLineBase : public Command void OnClear(CommandSource &source) { - FOREACH_MOD(OnDelXLine, (source, NULL, this->xlm())); + Event::OnDelXLine(&Event::DelXLine::OnDelXLine, source, nullptr, this->xlm()); for (unsigned i = this->xlm()->GetCount(); i > 0; --i) { @@ -372,7 +372,7 @@ class CommandOSSNLine : public CommandOSSXLineBase } EventReturn MOD_RESULT; - FOREACH_RESULT(OnAddXLine, MOD_RESULT, (source, x, this->xlm())); + MOD_RESULT = Event::OnAddXLine(&Event::AddXLine::OnAddXLine, source, x, this->xlm()); if (MOD_RESULT == EVENT_STOP) { delete x; @@ -570,7 +570,7 @@ class CommandOSSQLine : public CommandOSSXLineBase } EventReturn MOD_RESULT; - FOREACH_RESULT(OnAddXLine, MOD_RESULT, (source, x, this->xlm())); + MOD_RESULT = Event::OnAddXLine(&Event::AddXLine::OnAddXLine, source, x, this->xlm()); if (MOD_RESULT == EVENT_STOP) { delete x; diff --git a/modules/commands/os_update.cpp b/modules/commands/os_update.cpp index 50be11d85..3f0d07d17 100644 --- a/modules/commands/os_update.cpp +++ b/modules/commands/os_update.cpp @@ -42,8 +42,8 @@ class OSUpdate : public Module CommandOSUpdate commandosupdate; public: - OSUpdate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - commandosupdate(this) + OSUpdate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , commandosupdate(this) { } diff --git a/modules/cs_statusupdate.cpp b/modules/cs_statusupdate.cpp index 2696d6c1a..58498ff40 100644 --- a/modules/cs_statusupdate.cpp +++ b/modules/cs_statusupdate.cpp @@ -8,9 +8,13 @@ #include "module.h" class StatusUpdate : public Module + , public EventHook<Event::AccessAdd> + , public EventHook<Event::AccessDel> { public: StatusUpdate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::AccessAdd>("OnAccessAdd") + , EventHook<Event::AccessDel>("OnAccessDel") { } diff --git a/modules/database/db_flatfile.cpp b/modules/database/db_flatfile.cpp index c4b2254c8..50f1412b1 100644 --- a/modules/database/db_flatfile.cpp +++ b/modules/database/db_flatfile.cpp @@ -103,6 +103,11 @@ class LoadData : public Serialize::Data }; class DBFlatFile : public Module, public Pipe + , public EventHook<Event::Restart> + , public EventHook<Event::Shutdown> + , public EventHook<Event::LoadDatabase> + , public EventHook<Event::SaveDatabase> + , public EventHook<Event::SerializeTypeCreate> { /* Day the last backup was on */ int last_day; @@ -167,7 +172,15 @@ class DBFlatFile : public Module, public Pipe } public: - DBFlatFile(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR), last_day(0), loaded(false), child_pid(-1) + DBFlatFile(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR) + , EventHook<Event::Restart>("OnRestart") + , EventHook<Event::Shutdown>("OnShutdown") + , EventHook<Event::LoadDatabase>("OnLoadDatabase") + , EventHook<Event::SaveDatabase>("OnSaveDatabase") + , EventHook<Event::SerializeTypeCreate>("OnSerializeTypeCreate") + , last_day(0) + , loaded(false) + , child_pid(-1) { } diff --git a/modules/database/db_old.cpp b/modules/database/db_old.cpp index 82f26e064..f80d55d5a 100644 --- a/modules/database/db_old.cpp +++ b/modules/database/db_old.cpp @@ -1294,16 +1294,21 @@ static void LoadNews() } class DBOld : public Module + , public EventHook<Event::LoadDatabase> + , public EventHook<Event::UplinkSync> { PrimitiveExtensibleItem<uint32_t> mlock_on, mlock_off, mlock_limit; PrimitiveExtensibleItem<Anope::string> mlock_key; public: - DBOld(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR), - mlock_on(this, "mlock_on"), mlock_off(this, "mlock_off"), mlock_limit(this, "mlock_limit"), mlock_key(this, "mlock_key") + DBOld(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR) + , EventHook<Event::LoadDatabase>("OnLoadDatabase") + , EventHook<Event::UplinkSync>("OnUplinkSync") + , mlock_on(this, "mlock_on") + , mlock_off(this, "mlock_off") + , mlock_limit(this, "mlock_limit") + , mlock_key(this, "mlock_key") { - - hashm = Config->GetModule(this)->Get<const Anope::string>("hash"); if (hashm != "md5" && hashm != "oldmd5" && hashm != "sha1" && hashm != "plain" && hashm != "sha256") diff --git a/modules/database/db_redis.cpp b/modules/database/db_redis.cpp index d7585bc32..81b1f083f 100644 --- a/modules/database/db_redis.cpp +++ b/modules/database/db_redis.cpp @@ -121,6 +121,11 @@ class SubscriptionListener : public Interface }; class DatabaseRedis : public Module, public Pipe + , public EventHook<Event::LoadDatabase> + , public EventHook<Event::SerializeTypeCreate> + , public EventHook<Event::SerializableConstruct> + , public EventHook<Event::SerializableDestruct> + , public EventHook<Event::SerializableUpdate> { SubscriptionListener sl; std::set<Serializable *> updated_items; @@ -128,7 +133,13 @@ class DatabaseRedis : public Module, public Pipe public: ServiceReference<Provider> redis; - DatabaseRedis(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR), sl(this) + DatabaseRedis(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR) + , EventHook<Event::LoadDatabase>("OnLoadDatabase") + , EventHook<Event::SerializeTypeCreate>("OnSerializeTypeCreate") + , EventHook<Event::SerializableConstruct>("OnSerializableConstruct") + , EventHook<Event::SerializableDestruct>("OnSerializableDestruct") + , EventHook<Event::SerializableUpdate>("OnSerializableUpdate") + , sl(this) { me = this; diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp index 34ae7cfea..5d213cb9a 100644 --- a/modules/database/db_sql.cpp +++ b/modules/database/db_sql.cpp @@ -55,6 +55,13 @@ public: }; class DBSQL : public Module, public Pipe + , public EventHook<Event::Shutdown> + , public EventHook<Event::Restart> + , public EventHook<Event::LoadDatabase> + , public EventHook<Event::SerializableConstruct> + , public EventHook<Event::SerializableDestruct> + , public EventHook<Event::SerializableUpdate> + , public EventHook<Event::SerializeTypeCreate> { ServiceReference<Provider> sql; SQLSQLInterface sqlinterface; @@ -89,7 +96,19 @@ class DBSQL : public Module, public Pipe } public: - DBSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR), sql("", ""), sqlinterface(this), shutting_down(false), loading_databases(false), loaded(false), imported(false) + DBSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR) + , EventHook<Event::Shutdown>("OnShutdown") + , EventHook<Event::Restart>("OnRestart") + , EventHook<Event::LoadDatabase>("OnLoadDatabase") + , EventHook<Event::SerializableConstruct>("OnSerializableConstruct") + , EventHook<Event::SerializableDestruct>("OnSerializableDestruct") + , EventHook<Event::SerializableUpdate>("OnSerializableUpdate") + , EventHook<Event::SerializeTypeCreate>("OnSerializeTypeCreate") + , sqlinterface(this) + , shutting_down(false) + , loading_databases(false) + , loaded(false) + , imported(false) { diff --git a/modules/database/db_sql_live.cpp b/modules/database/db_sql_live.cpp index 0099ff5e2..ad10f0a7d 100644 --- a/modules/database/db_sql_live.cpp +++ b/modules/database/db_sql_live.cpp @@ -4,6 +4,13 @@ using namespace SQL; class DBMySQL : public Module, public Pipe + , public EventHook<Event::LoadDatabase> + , public EventHook<Event::Shutdown> + , public EventHook<Event::Restart> + , public EventHook<Event::SerializableConstruct> + , public EventHook<Event::SerializableDestruct> + , public EventHook<Event::SerializeCheck> + , public EventHook<Event::SerializableUpdate> { private: Anope::string prefix; @@ -64,7 +71,14 @@ class DBMySQL : public Module, public Pipe } public: - DBMySQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR), SQL("", "") + DBMySQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR) + , EventHook<Event::LoadDatabase>("OnLoadDatabase") + , EventHook<Event::Shutdown>("OnShutdown") + , EventHook<Event::Restart>("OnRestart") + , EventHook<Event::SerializableConstruct>("OnSerializableConstruct") + , EventHook<Event::SerializableDestruct>("OnSerializableDestruct") + , EventHook<Event::SerializeCheck>("OnSerializeCheck") + , EventHook<Event::SerializableUpdate>("OnSerializableUpdate") { this->lastwarn = 0; this->ro = false; diff --git a/modules/encryption/enc_bcrypt.cpp b/modules/encryption/enc_bcrypt.cpp index 8ed5695ac..020bafe6e 100644 --- a/modules/encryption/enc_bcrypt.cpp +++ b/modules/encryption/enc_bcrypt.cpp @@ -841,6 +841,8 @@ char *_crypt_gensalt_blowfish_rn(const char *prefix, unsigned long count, #include "modules/encryption.h" class EBCRYPT : public Module + , public EventHook<Event::Encrypt> + , public EventHook<Event::CheckAuthentication> { unsigned int rounds; @@ -873,8 +875,10 @@ class EBCRYPT : public Module } public: - EBCRYPT(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR | EXTRA), - rounds(10) + EBCRYPT(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR | EXTRA) + , EventHook<Event::Encrypt>("OnEncrypt") + , EventHook<Event::CheckAuthentication>("OnCheckAuthentication") + , rounds(10) { // Test a pre-calculated hash bool test = Compare("Test!", "$2a$10$x9AQFAQScY0v9KF2suqkEOepsHFrG.CXHbIXI.1F28SfSUb56A/7K"); diff --git a/modules/encryption/enc_md5.cpp b/modules/encryption/enc_md5.cpp index b49390d56..838c5712f 100644 --- a/modules/encryption/enc_md5.cpp +++ b/modules/encryption/enc_md5.cpp @@ -338,12 +338,16 @@ class MD5Provider : public Encryption::Provider }; class EMD5 : public Module + , public EventHook<Event::Encrypt> + , public EventHook<Event::CheckAuthentication> { MD5Provider md5provider; public: - EMD5(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR), - md5provider(this) + EMD5(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR) + , EventHook<Event::Encrypt>("OnEncrypt") + , EventHook<Event::CheckAuthentication>("OnCheckAuthentication") + , md5provider(this) { } diff --git a/modules/encryption/enc_none.cpp b/modules/encryption/enc_none.cpp index ae698914c..1346177f7 100644 --- a/modules/encryption/enc_none.cpp +++ b/modules/encryption/enc_none.cpp @@ -10,9 +10,15 @@ #include "module.h" class ENone : public Module + , public EventHook<Event::Encrypt> + , public EventHook<Event::Decrypt> + , public EventHook<Event::CheckAuthentication> { public: ENone(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR) + , EventHook<Event::Encrypt>("OnEncrypt") + , EventHook<Event::Decrypt>("OnDecrypt") + , EventHook<Event::CheckAuthentication>("OnCheckAuthentication") { } diff --git a/modules/encryption/enc_old.cpp b/modules/encryption/enc_old.cpp index 89c228b1d..b885eb777 100644 --- a/modules/encryption/enc_old.cpp +++ b/modules/encryption/enc_old.cpp @@ -35,14 +35,18 @@ class OldMD5Provider : public Encryption::Provider }; class EOld : public Module + , public EventHook<Event::Encrypt> + , public EventHook<Event::CheckAuthentication> { OldMD5Provider oldmd5provider; inline static char XTOI(char c) { return c > 9 ? c - 'A' + 10 : c - '0'; } public: - EOld(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR), - oldmd5provider(this) + EOld(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR) + , EventHook<Event::Encrypt>("OnEncrypt") + , EventHook<Event::CheckAuthentication>("OnCheckAuthentication") + , oldmd5provider(this) { ModuleManager::LoadModule("enc_md5", User::Find(creator)); diff --git a/modules/encryption/enc_sha1.cpp b/modules/encryption/enc_sha1.cpp index 79d657493..f65b5d5ea 100644 --- a/modules/encryption/enc_sha1.cpp +++ b/modules/encryption/enc_sha1.cpp @@ -193,12 +193,16 @@ class SHA1Provider : public Encryption::Provider }; class ESHA1 : public Module + , public EventHook<Event::Encrypt> + , public EventHook<Event::CheckAuthentication> { SHA1Provider sha1provider; public: - ESHA1(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR), - sha1provider(this) + ESHA1(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR) + , EventHook<Event::Encrypt>("OnEncrypt") + , EventHook<Event::CheckAuthentication>("OnCheckAuthentication") + , sha1provider(this) { } diff --git a/modules/encryption/enc_sha256.cpp b/modules/encryption/enc_sha256.cpp index 8be792346..9cd682c57 100644 --- a/modules/encryption/enc_sha256.cpp +++ b/modules/encryption/enc_sha256.cpp @@ -237,6 +237,8 @@ class SHA256Provider : public Encryption::Provider }; class ESHA256 : public Module + , public EventHook<Event::Encrypt> + , public EventHook<Event::CheckAuthentication> { SHA256Provider sha256provider; @@ -273,8 +275,10 @@ class ESHA256 : public Module } public: - ESHA256(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR), - sha256provider(this) + ESHA256(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, ENCRYPTION | VENDOR) + , EventHook<Event::Encrypt>("OnEncrypt") + , EventHook<Event::CheckAuthentication>("OnCheckAuthentication") + , sha256provider(this) { diff --git a/modules/extra/m_ldap.cpp b/modules/extra/m_ldap.cpp index eb5589032..1615d855c 100644 --- a/modules/extra/m_ldap.cpp +++ b/modules/extra/m_ldap.cpp @@ -444,11 +444,13 @@ class LDAPService : public LDAPProvider, public Thread, public Condition }; class ModuleLDAP : public Module, public Pipe + , public EventHook<Event::ModuleUnload> { std::map<Anope::string, LDAPService *> LDAPServices; public: ModuleLDAP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , EventHook<Event::ModuleUnload>("OnModuleUnload") { me = this; diff --git a/modules/extra/m_ldap_authentication.cpp b/modules/extra/m_ldap_authentication.cpp index 1a4feb232..abd5cc33c 100644 --- a/modules/extra/m_ldap_authentication.cpp +++ b/modules/extra/m_ldap_authentication.cpp @@ -1,5 +1,6 @@ #include "module.h" #include "modules/ldap.h" +#include "modules/nickserv.h" static Module *me; @@ -104,7 +105,7 @@ class IdentifyInterface : public LDAPInterface { na = new NickAlias(ii->req->GetAccount(), new NickCore(ii->req->GetAccount())); na->last_realname = ii->user ? ii->user->realname : ii->req->GetAccount(); - FOREACH_MOD(OnNickRegister, (ii->user, na)); + NickServ::Event::OnNickRegister(&NickServ::Event::NickRegister::OnNickRegister, ii->user, na); BotInfo *NickServ = Config->GetClient("NickServ"); if (ii->user && NickServ) ii->user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); @@ -202,6 +203,10 @@ class OnRegisterInterface : public LDAPInterface }; class NSIdentifyLDAP : public Module + , public EventHook<Event::PreCommand> + , public EventHook<Event::CheckAuthentication> + , public EventHook<Event::NickIdentify> + , public EventHook<NickServ::Event::NickRegister> { ServiceReference<LDAPProvider> ldap; IdentifyInterface iinterface; @@ -214,14 +219,20 @@ class NSIdentifyLDAP : public Module Anope::string disable_register_reason; Anope::string disable_email_reason; public: - NSIdentifyLDAP(const Anope::string &modname, const Anope::string &creator) : - Module(modname, creator, EXTRA | VENDOR), ldap("LDAPProvider", "ldap/main"), iinterface(this), oninterface(this), orinterface(this), - dn(this, "m_ldap_authentication_dn") + + NSIdentifyLDAP(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , EventHook<Event::PreCommand>("OnPreCommand", EventHook<Event::PreCommand>::Priority::FIRST) + , EventHook<Event::CheckAuthentication>("OnCheckAuthentication", EventHook<Event::CheckAuthentication>::Priority::FIRST) + , EventHook<Event::NickIdentify>("OnNickIdentify", EventHook<Event::NickIdentify>::Priority::FIRST) + , EventHook<NickServ::Event::NickRegister>("OnNickRegister", EventHook<NickServ::Event::NickRegister>::Priority::FIRST) + , ldap("LDAPProvider", "ldap/main") + , iinterface(this) + , oninterface(this) + , orinterface(this) + , dn(this, "m_ldap_authentication_dn") { me = this; - - ModuleManager::SetPriority(this, PRIORITY_FIRST); } void OnReload(Configuration::Conf *config) override diff --git a/modules/extra/m_ldap_oper.cpp b/modules/extra/m_ldap_oper.cpp index e265bfd9d..7c6db48f5 100644 --- a/modules/extra/m_ldap_oper.cpp +++ b/modules/extra/m_ldap_oper.cpp @@ -76,6 +76,8 @@ class IdentifyInterface : public LDAPInterface }; class LDAPOper : public Module + , public EventHook<Event::NickIdentify> + , public EventHook<Event::DelCore> { ServiceReference<LDAPProvider> ldap; IdentifyInterface iinterface; @@ -85,8 +87,11 @@ class LDAPOper : public Module Anope::string basedn; Anope::string filter; public: - LDAPOper(const Anope::string &modname, const Anope::string &creator) : - Module(modname, creator, EXTRA | VENDOR), ldap("LDAPProvider", "ldap/main"), iinterface(this) + LDAPOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , EventHook<Event::NickIdentify>("OnNickIdentify") + , EventHook<Event::DelCore>("OnDelCore") + , ldap("LDAPProvider", "ldap/main") + , iinterface(this) { } diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp index 808cdd264..d0db90195 100644 --- a/modules/extra/m_mysql.cpp +++ b/modules/extra/m_mysql.cpp @@ -153,7 +153,9 @@ class DispatcherThread : public Thread, public Condition class ModuleSQL; static ModuleSQL *me; -class ModuleSQL : public Module, public Pipe +class ModuleSQL : public Module + , public Pipe + , public EventHook<Event::ModuleUnload> { /* SQL connections */ std::map<Anope::string, MySQLService *> MySQLServices; @@ -166,6 +168,7 @@ class ModuleSQL : public Module, public Pipe DispatcherThread *DThread; ModuleSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , EventHook<Event::ModuleUnload>("OnModuleUnload") { me = this; diff --git a/modules/extra/m_sasl_dh-aes.cpp b/modules/extra/m_sasl_dh-aes.cpp index 0a73f7788..f3294bfc1 100644 --- a/modules/extra/m_sasl_dh-aes.cpp +++ b/modules/extra/m_sasl_dh-aes.cpp @@ -160,7 +160,7 @@ class DHAES : public Mechanism return Err(sess, pubkey); SASL::IdentifyRequest* req = new SASL::IdentifyRequest(this->owner, m.source, username, password); - FOREACH_MOD(OnCheckAuthentication, (NULL, req)); + Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, nullptr, req); req->Dispatch(); BN_free(pubkey); @@ -174,8 +174,8 @@ class ModuleSASLDHAES : public Module DHAES dhaes; public: - ModuleSASLDHAES(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR | EXTRA), - dhaes(this) + ModuleSASLDHAES(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR | EXTRA) + , dhaes(this) { } }; diff --git a/modules/extra/m_sasl_dh-blowfish.cpp b/modules/extra/m_sasl_dh-blowfish.cpp index b310c1089..b32e8855e 100644 --- a/modules/extra/m_sasl_dh-blowfish.cpp +++ b/modules/extra/m_sasl_dh-blowfish.cpp @@ -170,7 +170,7 @@ class DHBS : public Mechanism return Err(sess, pubkey); SASL::IdentifyRequest* req = new SASL::IdentifyRequest(this->owner, m.source, username, password); - FOREACH_MOD(OnCheckAuthentication, (NULL, req)); + Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, nullptr, req); req->Dispatch(); BN_free(pubkey); @@ -184,8 +184,8 @@ class ModuleSASLDHBS : public Module DHBS dhbs; public: - ModuleSASLDHBS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR | EXTRA), - dhbs(this) + ModuleSASLDHBS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR | EXTRA) + , dhbs(this) { } }; diff --git a/modules/extra/m_sql_authentication.cpp b/modules/extra/m_sql_authentication.cpp index b3c0fd6b7..65f0f2800 100644 --- a/modules/extra/m_sql_authentication.cpp +++ b/modules/extra/m_sql_authentication.cpp @@ -1,5 +1,6 @@ #include "module.h" #include "modules/sql.h" +#include "modules/nickserv.h" static Module *me; @@ -42,7 +43,7 @@ class SQLAuthenticationResult : public SQL::Interface if (na == NULL) { na = new NickAlias(req->GetAccount(), new NickCore(req->GetAccount())); - FOREACH_MOD(OnNickRegister, (user, na)); + NickServ::Event::OnNickRegister(&NickServ::Event::NickRegister::OnNickRegister, user, na); if (user && NickServ) user->SendMessage(NickServ, _("Your account \002%s\002 has been successfully created."), na->nick.c_str()); } @@ -66,6 +67,8 @@ class SQLAuthenticationResult : public SQL::Interface }; class ModuleSQLAuthentication : public Module + , public EventHook<Event::PreCommand> + , public EventHook<Event::CheckAuthentication> { Anope::string engine; Anope::string query; @@ -75,6 +78,8 @@ class ModuleSQLAuthentication : public Module public: ModuleSQLAuthentication(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , EventHook<Event::PreCommand>("OnPreCommand") + , EventHook<Event::CheckAuthentication>("OnCheckAuthentication") { me = this; diff --git a/modules/extra/m_sql_log.cpp b/modules/extra/m_sql_log.cpp index 475ff1253..496ecb5e6 100644 --- a/modules/extra/m_sql_log.cpp +++ b/modules/extra/m_sql_log.cpp @@ -11,12 +11,14 @@ #include "modules/sql.h" class SQLLog : public Module + , public EventHook<Event::LogMessage> { std::set<Anope::string> inited; Anope::string table; public: SQLLog(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR | EXTRA) + , EventHook<Event::LogMessage>("OnLogMessage") { } diff --git a/modules/extra/m_sql_oper.cpp b/modules/extra/m_sql_oper.cpp index 01d1fa174..90fab856a 100644 --- a/modules/extra/m_sql_oper.cpp +++ b/modules/extra/m_sql_oper.cpp @@ -90,6 +90,7 @@ class SQLOperResult : public SQL::Interface }; class ModuleSQLOper : public Module + , public EventHook<Event::NickIdentify> { Anope::string engine; Anope::string query; @@ -97,7 +98,8 @@ class ModuleSQLOper : public Module ServiceReference<SQL::Provider> SQL; public: - ModuleSQLOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + ModuleSQLOper(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), + EventHook<Event::NickIdentify>("OnNickIdentify") { } diff --git a/modules/extra/m_sqlite.cpp b/modules/extra/m_sqlite.cpp index 1e9fdad7b..c0f503141 100644 --- a/modules/extra/m_sqlite.cpp +++ b/modules/extra/m_sqlite.cpp @@ -63,6 +63,7 @@ class ModuleSQLite : public Module { /* SQL connections */ std::map<Anope::string, SQLiteService *> SQLiteServices; + public: ModuleSQLite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) { diff --git a/modules/extra/m_ssl_gnutls.cpp b/modules/extra/m_ssl_gnutls.cpp index 8ad6ee684..492536c5c 100644 --- a/modules/extra/m_ssl_gnutls.cpp +++ b/modules/extra/m_ssl_gnutls.cpp @@ -293,6 +293,7 @@ namespace GnuTLS } class GnuTLSModule : public Module + , public EventHook<Event::PreServerConnect> { GnuTLS::Init libinit; @@ -300,7 +301,10 @@ class GnuTLSModule : public Module GnuTLS::X509CertCredentials *cred; MySSLService service; - GnuTLSModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), cred(NULL), service(this, "ssl") + GnuTLSModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , EventHook<Event::PreServerConnect>("OnPreServerConnect") + , cred(NULL) + , service(this, "ssl") { me = this; this->SetPermanent(true); diff --git a/modules/extra/m_ssl_openssl.cpp b/modules/extra/m_ssl_openssl.cpp index 4e35c0dbf..3344f1d28 100644 --- a/modules/extra/m_ssl_openssl.cpp +++ b/modules/extra/m_ssl_openssl.cpp @@ -81,13 +81,16 @@ class SSLSocketIO : public SocketIO class SSLModule; static SSLModule *me; class SSLModule : public Module + , public EventHook<Event::PreServerConnect> { Anope::string certfile, keyfile; public: MySSLService service; - SSLModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), service(this, "ssl") + SSLModule(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , EventHook<Event::PreServerConnect>("OnPreServerConnect") + , service(this, "ssl") { me = this; diff --git a/modules/extra/stats/cs_fantasy_top.cpp b/modules/extra/stats/cs_fantasy_top.cpp index 7f4092fe2..540a4f3d9 100644 --- a/modules/extra/stats/cs_fantasy_top.cpp +++ b/modules/extra/stats/cs_fantasy_top.cpp @@ -151,7 +151,7 @@ class CSTop : public Module { source.Reply(_("%2lu \002%-16s\002 letters: %s, words: %s, lines: %s, smileys: %s, actions: %s"), i+1, res.Get(i, "nick").c_str(), res.Get(i, "letters").c_str(), - res.Get(i, "words").c_str(), res.Get(i, "line").c_str(), + res.Get(i, "words").c_str(), res.Get(i, "line").c_str(), res.Get(i, "smileys").c_str(), res.Get(i, "actions").c_str()); } } diff --git a/modules/extra/stats/m_chanstats.cpp b/modules/extra/stats/m_chanstats.cpp index a1674bce3..e80c3e456 100644 --- a/modules/extra/stats/m_chanstats.cpp +++ b/modules/extra/stats/m_chanstats.cpp @@ -20,7 +20,7 @@ class CommandCSSetChanstats : 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; @@ -73,7 +73,7 @@ class CommandNSSetChanstats : public Command } EventReturn MOD_RESULT; - FOREACH_RESULT(OnSetNickOption, MOD_RESULT, (source, this, na->nc, param)); + MOD_RESULT = Event::OnSetNickOption(&Event::SetNickOption::OnSetNickOption, source, this, na->nc, param); if (MOD_RESULT == EVENT_STOP) return; diff --git a/modules/fantasy.cpp b/modules/fantasy.cpp index 1e8bc4e10..e89b35365 100644 --- a/modules/fantasy.cpp +++ b/modules/fantasy.cpp @@ -10,6 +10,7 @@ */ #include "module.h" +#include "modules/fantasy.h" class CommandBSSetFantasy : public Command { @@ -81,14 +82,22 @@ class CommandBSSetFantasy : public Command }; class Fantasy : public Module + , public EventHook<Event::Privmsg> { SerializableExtensibleItem<bool> fantasy; CommandBSSetFantasy commandbssetfantasy; + EventHandlers<Event::BotFantasy> OnBotFantasy; + EventHandlers<Event::BotNoFantasyAccess> OnBotNoFantasyAccess; + public: - Fantasy(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - fantasy(this, "BS_FANTASY"), commandbssetfantasy(this) + Fantasy(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::Privmsg>("OnPrivmsg") + , fantasy(this, "BS_FANTASY") + , commandbssetfantasy(this) + , OnBotFantasy(this, "OnBotFantasy") + , OnBotNoFantasyAccess(this, "OnBotNoFantasyAccess") { } @@ -168,11 +177,11 @@ class Fantasy : public Module EventReturn MOD_RESULT; if (has_fantasia) { - FOREACH_RESULT(OnBotFantasy, MOD_RESULT, (source, cmd, c->ci, params)); + MOD_RESULT = this->OnBotFantasy(&Event::BotFantasy::OnBotFantasy, source, cmd, c->ci, params); } else { - FOREACH_RESULT(OnBotNoFantasyAccess, MOD_RESULT, (source, cmd, c->ci, params)); + MOD_RESULT = this->OnBotNoFantasyAccess(&Event::BotNoFantasyAccess::OnBotNoFantasyAccess, source, cmd, c->ci, params); } if (MOD_RESULT == EVENT_STOP || !has_fantasia) @@ -181,7 +190,7 @@ class Fantasy : public Module if (MOD_RESULT != EVENT_ALLOW && !info.permission.empty() && !source.HasCommand(info.permission)) return; - FOREACH_RESULT(OnPreCommand, MOD_RESULT, (source, cmd, params)); + MOD_RESULT = Event::OnPreCommand(&Event::PreCommand::OnPreCommand, source, cmd, params); if (MOD_RESULT == EVENT_STOP) return; @@ -189,7 +198,7 @@ class Fantasy : public Module cmd->Execute(source, params); if (!nc_reference) source.nc = NULL; - FOREACH_MOD(OnPostCommand, (source, cmd, params)); + Event::OnPostCommand(&Event::PostCommand::OnPostCommand, source, cmd, params); } void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) diff --git a/modules/m_dns.cpp b/modules/m_dns.cpp index eaf9ba428..dfe44516a 100644 --- a/modules/m_dns.cpp +++ b/modules/m_dns.cpp @@ -823,7 +823,7 @@ class MyManager : public Manager, public Timer } } - FOREACH_MOD(OnDnsRequest, (recv_packet, packet)); + Event::OnDnsRequest(&Event::DnsRequest::OnDnsRequest, recv_packet, packet); for (unsigned i = 0; i < recv_packet.questions.size(); ++i) { @@ -1004,6 +1004,7 @@ class MyManager : public Manager, public Timer }; class ModuleDNS : public Module + , public EventHook<Event::ModuleUnload> { MyManager manager; @@ -1014,7 +1015,9 @@ class ModuleDNS : public Module std::vector<std::pair<Anope::string, short> > notify; public: - ModuleDNS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), manager(this) + ModuleDNS(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , EventHook<Event::ModuleUnload>("OnModuleUnload") + , manager(this) { } diff --git a/modules/m_dnsbl.cpp b/modules/m_dnsbl.cpp index 414598441..c5dd94f21 100644 --- a/modules/m_dnsbl.cpp +++ b/modules/m_dnsbl.cpp @@ -80,6 +80,7 @@ class DNSBLResolver : public Request }; class ModuleDNSBL : public Module + , public EventHook<Event::UserConnect> { std::vector<Blacklist> blacklists; bool check_on_connect; @@ -88,6 +89,7 @@ class ModuleDNSBL : public Module public: ModuleDNSBL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR | EXTRA) + , EventHook<Event::UserConnect>("OnUserConnect") { } diff --git a/modules/m_helpchan.cpp b/modules/m_helpchan.cpp index 1cde06c5a..07c9ff142 100644 --- a/modules/m_helpchan.cpp +++ b/modules/m_helpchan.cpp @@ -8,9 +8,11 @@ #include "module.h" class HelpChannel : public Module + , public EventHook<Event::ChannelModeSet> { public: HelpChannel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::ChannelModeSet>("OnChannelModeSet") { } diff --git a/modules/m_httpd.cpp b/modules/m_httpd.cpp index 88244b03b..314badc55 100644 --- a/modules/m_httpd.cpp +++ b/modules/m_httpd.cpp @@ -334,11 +334,14 @@ class MyHTTPProvider : public HTTPProvider, public Timer }; class HTTPD : public Module + , public EventHook<Event::ModuleLoad> { ServiceReference<SSLService> sslref; std::map<Anope::string, MyHTTPProvider *> providers; public: - HTTPD(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), sslref("SSLService", "ssl") + HTTPD(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , EventHook<Event::ModuleLoad>("OnModuleLoad") + , sslref("SSLService", "ssl") { } diff --git a/modules/m_proxyscan.cpp b/modules/m_proxyscan.cpp index 9918c4232..c67bb620f 100644 --- a/modules/m_proxyscan.cpp +++ b/modules/m_proxyscan.cpp @@ -189,6 +189,7 @@ class SOCKS5ProxyConnect : public ProxyConnect, public BinarySocket }; class ModuleProxyScan : public Module + , public EventHook<Event::UserConnect> { Anope::string listen_ip; unsigned short listen_port; @@ -217,8 +218,9 @@ class ModuleProxyScan : public Module } connectionTimeout; public: - ModuleProxyScan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), - connectionTimeout(this, 5) + ModuleProxyScan(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , EventHook<Event::UserConnect>("OnUserConnect") + , connectionTimeout(this, 5) { diff --git a/modules/m_redis.cpp b/modules/m_redis.cpp index 2dff7382e..1869cf0dc 100644 --- a/modules/m_redis.cpp +++ b/modules/m_redis.cpp @@ -521,11 +521,13 @@ bool RedisSocket::Read(const char *buffer, size_t l) class ModuleRedis : public Module + , public EventHook<Event::ModuleUnload> { std::map<Anope::string, MyRedisService *> services; public: ModuleRedis(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , EventHook<Event::ModuleUnload>("OnModuleUnload") { } diff --git a/modules/m_rewrite.cpp b/modules/m_rewrite.cpp index b12331665..940308c12 100644 --- a/modules/m_rewrite.cpp +++ b/modules/m_rewrite.cpp @@ -153,7 +153,8 @@ class ModuleRewrite : public Module RewriteCommand cmdrewrite; public: - ModuleRewrite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR | EXTRA), cmdrewrite(this) + ModuleRewrite(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR | EXTRA) + , cmdrewrite(this) { } diff --git a/modules/m_sasl.cpp b/modules/m_sasl.cpp index b8ecbc3a0..e38e865ff 100644 --- a/modules/m_sasl.cpp +++ b/modules/m_sasl.cpp @@ -44,7 +44,7 @@ class Plain : public Mechanism return; SASL::IdentifyRequest *req = new SASL::IdentifyRequest(this->owner, m.source, acc, pass); - FOREACH_MOD(OnCheckAuthentication, (NULL, req)); + Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, nullptr, req); req->Dispatch(); } } @@ -254,8 +254,10 @@ class ModuleSASL : public Module External *external; public: - ModuleSASL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), - sasl(this), plain(this), external(NULL) + ModuleSASL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , sasl(this) + , plain(this) + , external(NULL) { try { diff --git a/modules/m_xmlrpc.cpp b/modules/m_xmlrpc.cpp index 2d2814143..e92650a89 100644 --- a/modules/m_xmlrpc.cpp +++ b/modules/m_xmlrpc.cpp @@ -161,8 +161,9 @@ class ModuleXMLRPC : public Module public: MyXMLRPCServiceInterface xmlrpcinterface; - ModuleXMLRPC(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), - httpref("HTTPProvider", "httpd/main"), xmlrpcinterface(this, "xmlrpc") + ModuleXMLRPC(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , httpref("HTTPProvider", "httpd/main") + , xmlrpcinterface(this, "xmlrpc") { if (!httpref) throw ModuleException("Unable to find http reference, is m_httpd loaded?"); diff --git a/modules/m_xmlrpc_main.cpp b/modules/m_xmlrpc_main.cpp index 0f46f09e1..011b2d250 100644 --- a/modules/m_xmlrpc_main.cpp +++ b/modules/m_xmlrpc_main.cpp @@ -117,7 +117,7 @@ class MyXMLRPCEvent : public XMLRPCEvent else { XMLRPCIdentifyRequest *req = new XMLRPCIdentifyRequest(me, request, client, iface, username, password); - FOREACH_MOD(OnCheckAuthentication, (NULL, req)); + Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, nullptr, req); req->Dispatch(); return false; } diff --git a/modules/ns_maxemail.cpp b/modules/ns_maxemail.cpp index fe4746927..a7e2f29ac 100644 --- a/modules/ns_maxemail.cpp +++ b/modules/ns_maxemail.cpp @@ -13,6 +13,7 @@ #include "module.h" class NSMaxEmail : public Module + , public EventHook<Event::PreCommand> { bool CheckLimitReached(CommandSource &source, const Anope::string &email) { @@ -52,6 +53,7 @@ class NSMaxEmail : public Module public: NSMaxEmail(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) + , EventHook<Event::PreCommand>("OnPreCommand") { } diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 439bfd387..5c1a23426 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -466,6 +466,7 @@ struct IRCDMessageTopic : IRCDMessage }; class ProtoBahamut : public Module + , public EventHook<Event::UserNickChange> { BahamutIRCdProto ircd_proto; @@ -535,15 +536,35 @@ class ProtoBahamut : public Module } public: - ProtoBahamut(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), - ircd_proto(this), - message_away(this), message_capab(this), message_error(this), message_invite(this), - message_join(this), message_kick(this), message_kill(this), message_motd(this), message_notice(this), - message_part(this), message_ping(this), message_privmsg(this), message_quit(this), - message_squit(this), message_stats(this), message_time(this), message_version(this), message_whois(this), - - message_burst(this), message_mode(this, "MODE"), message_svsmode(this, "SVSMODE"), - message_nick(this), message_server(this), message_sjoin(this), message_topic(this) + ProtoBahamut(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR) + , EventHook<Event::UserNickChange>("OnUserNickChange") + , ircd_proto(this) + , message_away(this) + , message_capab(this) + , message_error(this) + , message_invite(this) + , message_join(this) + , message_kick(this) + , message_kill(this) + , message_motd(this) + , message_notice(this) + , message_part(this) + , message_ping(this) + , message_privmsg(this) + , message_quit(this) + , message_squit(this) + , message_stats(this) + , message_time(this) + , message_version(this) + , message_whois(this) + + , message_burst(this) + , message_mode(this, "MODE") + , message_svsmode(this, "SVSMODE") + , message_nick(this) + , message_server(this) + , message_sjoin(this) + , message_topic(this) { this->AddModes(); diff --git a/modules/protocol/charybdis.cpp b/modules/protocol/charybdis.cpp index eed63edbf..68bf31e76 100644 --- a/modules/protocol/charybdis.cpp +++ b/modules/protocol/charybdis.cpp @@ -175,7 +175,7 @@ struct IRCDMessageEncap : IRCDMessage if (params[1] == "CERTFP") { u->fingerprint = params[2]; - FOREACH_MOD(OnFingerprint, (u)); + Event::OnFingerprint(&Event::Fingerprint::OnFingerprint, u); } /* * Received: :42X ENCAP * SASL 42XAAAAAH * S PLAIN @@ -258,6 +258,8 @@ struct IRCDMessagePass : IRCDMessage }; class ProtoCharybdis : public Module + , public EventHook<Event::ChannelSync> + , public EventHook<Event::MLockEvents> { Module *m_ratbox; @@ -321,24 +323,44 @@ class ProtoCharybdis : public Module } public: - ProtoCharybdis(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), - ircd_proto(this), - message_away(this), message_capab(this), message_error(this), message_invite(this), message_kick(this), - message_kill(this), message_mode(this), message_motd(this), message_notice(this), message_part(this), - message_ping(this), message_privmsg(this), message_quit(this), message_squit(this), message_stats(this), - message_time(this), message_topic(this), message_version(this), message_whois(this), - - message_bmask("IRCDMessage", "charybdis/bmask", "ratbox/bmask"), - message_join("IRCDMessage", "charybdis/join", "ratbox/join"), - message_nick("IRCDMessage", "charybdis/nick", "ratbox/nick"), - message_pong("IRCDMessage", "charybdis/pong", "ratbox/pong"), - message_sid("IRCDMessage", "charybdis/sid", "ratbox/sid"), - message_sjoin("IRCDMessage", "charybdis/sjoin", "ratbox/sjoin"), - message_tb("IRCDMessage", "charybdis/tb", "ratbox/tb"), - message_tmode("IRCDMessage", "charybdis/tmode", "ratbox/tmode"), - message_uid("IRCDMessage", "charybdis/uid", "ratbox/uid"), - - message_encap(this), message_euid(this), message_pass(this), message_server(this) + ProtoCharybdis(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR) + , EventHook<Event::ChannelSync>("OnChannelSync") + , EventHook<Event::MLockEvents>("MLock") + , ircd_proto(this) + , message_away(this) + , message_capab(this) + , message_error(this) + , message_invite(this) + , message_kick(this) + , message_kill(this) + , message_mode(this) + , message_motd(this) + , message_notice(this) + , message_part(this) + , message_ping(this) + , message_privmsg(this) + , message_quit(this) + , message_squit(this) + , message_stats(this) + , message_time(this) + , message_topic(this) + , message_version(this) + , message_whois(this) + + , message_bmask("IRCDMessage", "charybdis/bmask", "ratbox/bmask") + , message_join("IRCDMessage", "charybdis/join", "ratbox/join") + , message_nick("IRCDMessage", "charybdis/nick", "ratbox/nick") + , message_pong("IRCDMessage", "charybdis/pong", "ratbox/pong") + , message_sid("IRCDMessage", "charybdis/sid", "ratbox/sid") + , message_sjoin("IRCDMessage", "charybdis/sjoin", "ratbox/sjoin") + , message_tb("IRCDMessage", "charybdis/tb", "ratbox/tb") + , message_tmode("IRCDMessage", "charybdis/tmode", "ratbox/tmode") + , message_uid("IRCDMessage", "charybdis/uid", "ratbox/uid") + + , message_encap(this) + , message_euid(this) + , message_pass(this) + , message_server(this) { diff --git a/modules/protocol/hybrid.cpp b/modules/protocol/hybrid.cpp index dc5261403..d2b5b935a 100644 --- a/modules/protocol/hybrid.cpp +++ b/modules/protocol/hybrid.cpp @@ -558,11 +558,12 @@ struct IRCDMessageCertFP: IRCDMessage User *u = source.GetUser(); u->fingerprint = params[0]; - FOREACH_MOD(OnFingerprint, (u)); + Event::OnFingerprint(&Event::Fingerprint::OnFingerprint, u); } }; class ProtoHybrid : public Module + , public EventHook<Event::UserNickChange> { HybridProto ircd_proto; @@ -651,16 +652,42 @@ class ProtoHybrid : public Module } public: - ProtoHybrid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), - ircd_proto(this), - message_away(this), message_capab(this), message_error(this), message_invite(this), message_kick(this), - message_kill(this), message_mode(this), message_motd(this), message_notice(this), message_part(this), - message_ping(this), message_privmsg(this), message_quit(this), message_squit(this), message_stats(this), - message_time(this), message_topic(this), message_version(this), message_whois(this), - message_bmask(this), message_eob(this), message_join(this), - message_nick(this), message_pass(this), message_pong(this), message_server(this), message_sid(this), - message_sjoin(this), message_svsmode(this), message_tburst(this), message_tmode(this), message_uid(this), - message_certfp(this) + ProtoHybrid(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR) + , EventHook<Event::UserNickChange>("OnUserNickChange") + , ircd_proto(this) + , message_away(this) + , message_capab(this) + , message_error(this) + , message_invite(this) + , message_kick(this) + , message_kill(this) + , message_mode(this) + , message_motd(this) + , message_notice(this) + , message_part(this) + , message_ping(this) + , message_privmsg(this) + , message_quit(this) + , message_squit(this) + , message_stats(this) + , message_time(this) + , message_topic(this) + , message_version(this) + , message_whois(this) + , message_bmask(this) + , message_eob(this) + , message_join(this) + , message_nick(this) + , message_pass(this) + , message_pong(this) + , message_server(this) + , message_sid(this) + , message_sjoin(this) + , message_svsmode(this) + , message_tburst(this) + , message_tmode(this) + , message_uid(this) + , message_certfp(this) { if (Config->GetModule(this)) this->AddModes(); diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp index 7949fd610..77ebb2fe6 100644 --- a/modules/protocol/inspircd20.cpp +++ b/modules/protocol/inspircd20.cpp @@ -12,6 +12,7 @@ #include "module.h" #include "modules/sasl.h" #include "modules/cs_mode.h" +#include "modules/cs_set.h" struct SASLUser { @@ -1188,7 +1189,7 @@ struct IRCDMessageMetadata : IRCDMessage { u->fingerprint = data.substr(pos1, pos2 - pos1); } - FOREACH_MOD(OnFingerprint, (u)); + Event::OnFingerprint(&Event::Fingerprint::OnFingerprint, u); } } else if (params[0][0] == '#') @@ -1424,6 +1425,12 @@ struct IRCDMessageUID : IRCDMessage }; class ProtoInspIRCd20 : public Module + , public EventHook<Event::UserNickChange> + , public EventHook<Event::ChannelSync> + , public EventHook<Event::ChanRegistered> + , public EventHook<Event::DelChan> + , public EventHook<Event::MLockEvents> + , public EventHook<Event::SetChannelOption> { InspIRCd20Proto ircd_proto; ExtensibleItem<bool> ssl; @@ -1472,16 +1479,48 @@ class ProtoInspIRCd20 : public Module } public: - ProtoInspIRCd20(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), - ircd_proto(this), ssl(this, "ssl"), - message_away(this), message_error(this), message_invite(this), message_join(this), message_kick(this), - message_kill(this), message_motd(this), message_notice(this), message_part(this), message_ping(this), - message_privmsg(this), message_quit(this), message_stats(this), message_topic(this), - - message_capab(this), message_encap(this), message_endburst(this), - message_fhost(this), message_fident(this), message_fjoin(this), message_fmode(this), message_ftopic(this), - message_idle(this), message_metadata(this), message_mode(this), message_nick(this), message_opertype(this), message_rsquit(this), - message_server(this), message_squit(this), message_time(this), message_uid(this) + ProtoInspIRCd20(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR) + , EventHook<Event::UserNickChange>("OnUserNickChange") + , EventHook<Event::ChannelSync>("OnChannelSync") + , EventHook<Event::ChanRegistered>("OnChanRegistered") + , EventHook<Event::DelChan>("OnDelChan") + , EventHook<Event::MLockEvents>("MLock") + , EventHook<Event::SetChannelOption>("OnSetChannelOption") + , ircd_proto(this) + , ssl(this, "ssl") + , message_away(this) + , message_error(this) + , message_invite(this) + , message_join(this) + , message_kick(this) + , message_kill(this) + , message_motd(this) + , message_notice(this) + , message_part(this) + , message_ping(this) + , message_privmsg(this) + , message_quit(this) + , message_stats(this) + , message_topic(this) + + , message_capab(this) + , message_encap(this) + , message_endburst(this) + , message_fhost(this) + , message_fident(this) + , message_fjoin(this) + , message_fmode(this) + , message_ftopic(this) + , message_idle(this) + , message_metadata(this) + , message_mode(this) + , message_nick(this) + , message_opertype(this) + , message_rsquit(this) + , message_server(this) + , message_squit(this) + , message_time(this) + , message_uid(this) { } diff --git a/modules/protocol/ngircd.cpp b/modules/protocol/ngircd.cpp index 998d83921..06790b2af 100644 --- a/modules/protocol/ngircd.cpp +++ b/modules/protocol/ngircd.cpp @@ -352,7 +352,7 @@ struct IRCDMessageMetadata : IRCDMessage else if (params[1].equals_cs("certfp")) { u->fingerprint = params[2]; - FOREACH_MOD(OnFingerprint, (u)); + Event::OnFingerprint(&Event::Fingerprint::OnFingerprint, u); } else if (params[1].equals_cs("cloakhost")) { @@ -586,6 +586,7 @@ struct IRCDMessageTopic : IRCDMessage class ProtongIRCd : public Module + , public EventHook<Event::UserNickChange> { ngIRCdProto ircd_proto; @@ -666,16 +667,38 @@ class ProtongIRCd : public Module } public: - ProtongIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), - ircd_proto(this), - message_capab(this), message_error(this), message_invite(this), message_kick(this), message_kill(this), - message_motd(this), message_notice(this), message_part(this), message_ping(this), message_privmsg(this), - message_squery(this, "SQUERY"), message_quit(this), message_squit(this), message_stats(this), message_time(this), - message_version(this), message_whois(this), - - message_005(this), message_376(this), message_chaninfo(this), message_join(this), message_metadata(this), - message_mode(this), message_nick(this), message_njoin(this), message_pong(this), message_server(this), - message_topic(this) + ProtongIRCd(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR) + , EventHook<Event::UserNickChange>("OnUserNickChange") + , ircd_proto(this) + , message_capab(this) + , message_error(this) + , message_invite(this) + , message_kick(this) + , message_kill(this) + , message_motd(this) + , message_notice(this) + , message_part(this) + , message_ping(this) + , message_privmsg(this) + , message_squery(this, "SQUERY") + , message_quit(this) + , message_squit(this) + , message_stats(this) + , message_time(this) + , message_version(this) + , message_whois(this) + + , message_005(this) + , message_376(this) + , message_chaninfo(this) + , message_join(this) + , message_metadata(this) + , message_mode(this) + , message_nick(this) + , message_njoin(this) + , message_pong(this) + , message_server(this) + , message_topic(this) { Servers::Capab.insert("QS"); diff --git a/modules/protocol/plexus.cpp b/modules/protocol/plexus.cpp index a7ff0ae88..e4cc26e6a 100644 --- a/modules/protocol/plexus.cpp +++ b/modules/protocol/plexus.cpp @@ -204,7 +204,7 @@ struct IRCDMessageEncap : IRCDMessage if (u) { u->fingerprint = params[3]; - FOREACH_MOD(OnFingerprint, (u)); + Event::OnFingerprint(&Event::Fingerprint::OnFingerprint, u); } } return; @@ -382,20 +382,41 @@ class ProtoPlexus : public Module } public: - ProtoPlexus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), - ircd_proto(this), - message_away(this), message_capab(this), message_error(this), message_invite(this), message_kick(this), message_kill(this), - message_mode(this), message_motd(this), message_notice(this), message_part(this), message_ping(this), message_privmsg(this), - message_quit(this), message_squit(this), message_stats(this), message_time(this), message_topic(this), message_version(this), - message_whois(this), - - message_bmask("IRCDMessage", "plexus/bmask", "hybrid/bmask"), message_eob("IRCDMessage", "plexus/eob", "hybrid/eob"), - message_join("IRCDMessage", "plexus/join", "hybrid/join"), message_nick("IRCDMessage", "plexus/nick", "hybrid/nick"), - message_sid("IRCDMessage", "plexus/sid", "hybrid/sid"), - message_sjoin("IRCDMessage", "plexus/sjoin", "hybrid/sjoin"), message_tburst("IRCDMessage", "plexus/tburst", "hybrid/tburst"), - message_tmode("IRCDMessage", "plexus/tmode", "hybrid/tmode"), - - message_encap(this), message_pass(this), message_server(this), message_uid(this) + ProtoPlexus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR) + , ircd_proto(this) + , message_away(this) + , message_capab(this) + , message_error(this) + , message_invite(this) + , message_kick(this) + , message_kill(this) + , message_mode(this) + , message_motd(this) + , message_notice(this) + , message_part(this) + , message_ping(this) + , message_privmsg(this) + , message_quit(this) + , message_squit(this) + , message_stats(this) + , message_time(this) + , message_topic(this) + , message_version(this) + , message_whois(this) + + , message_bmask("IRCDMessage", "plexus/bmask", "hybrid/bmask") + , message_eob("IRCDMessage", "plexus/eob", "hybrid/eob") + , message_join("IRCDMessage", "plexus/join", "hybrid/join") + , message_nick("IRCDMessage", "plexus/nick", "hybrid/nick") + , message_sid("IRCDMessage", "plexus/sid", "hybrid/sid") + , message_sjoin("IRCDMessage", "plexus/sjoin", "hybrid/sjoin") + , message_tburst("IRCDMessage", "plexus/tburst", "hybrid/tburst") + , message_tmode("IRCDMessage", "plexus/tmode", "hybrid/tmode") + + , message_encap(this) + , message_pass(this) + , message_server(this) + , message_uid(this) { if (ModuleManager::LoadModule("hybrid", User::Find(creator)) != MOD_ERR_OK) diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp index ef09b9553..5cc80742f 100644 --- a/modules/protocol/ratbox.cpp +++ b/modules/protocol/ratbox.cpp @@ -289,19 +289,41 @@ class ProtoRatbox : public Module } public: - ProtoRatbox(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), - ircd_proto(this), - message_away(this), message_capab(this), message_error(this), message_invite(this), message_kick(this), - message_kill(this), message_mode(this), message_motd(this), message_notice(this), message_part(this), - message_ping(this), message_privmsg(this), message_quit(this), message_squit(this), message_stats(this), - message_time(this), message_topic(this), message_version(this), message_whois(this), - - message_bmask("IRCDMessage", "ratbox/bmask", "hybrid/bmask"), message_join("IRCDMessage", "ratbox/join", "hybrid/join"), - message_nick("IRCDMessage", "ratbox/nick", "hybrid/nick"), message_pong("IRCDMessage", "ratbox/pong", "hybrid/pong"), - message_sid("IRCDMessage", "ratbox/sid", "hybrid/sid"), message_sjoin("IRCDMessage", "ratbox/sjoin", "hybrid/sjoin"), - message_tmode("IRCDMessage", "ratbox/tmode", "hybrid/tmode"), - - message_encap(this), message_pass(this), message_server(this), message_tburst(this), message_uid(this) + ProtoRatbox(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR) + , ircd_proto(this) + , message_away(this) + , message_capab(this) + , message_error(this) + , message_invite(this) + , message_kick(this) + , message_kill(this) + , message_mode(this) + , message_motd(this) + , message_notice(this) + , message_part(this) + , message_ping(this) + , message_privmsg(this) + , message_quit(this) + , message_squit(this) + , message_stats(this) + , message_time(this) + , message_topic(this) + , message_version(this) + , message_whois(this) + + , message_bmask("IRCDMessage", "ratbox/bmask", "hybrid/bmask") + , message_join("IRCDMessage", "ratbox/join", "hybrid/join") + , message_nick("IRCDMessage", "ratbox/nick", "hybrid/nick") + , message_pong("IRCDMessage", "ratbox/pong", "hybrid/pong") + , message_sid("IRCDMessage", "ratbox/sid", "hybrid/sid") + , message_sjoin("IRCDMessage", "ratbox/sjoin", "hybrid/sjoin") + , message_tmode("IRCDMessage", "ratbox/tmode", "hybrid/tmode") + + , message_encap(this) + , message_pass(this) + , message_server(this) + , message_tburst(this) + , message_uid(this) { if (ModuleManager::LoadModule("hybrid", User::Find(creator)) != MOD_ERR_OK) diff --git a/modules/protocol/unreal.cpp b/modules/protocol/unreal.cpp index 395b4dfcc..eec4601ce 100644 --- a/modules/protocol/unreal.cpp +++ b/modules/protocol/unreal.cpp @@ -1091,6 +1091,11 @@ struct IRCDMessageUmode2 : IRCDMessage }; class ProtoUnreal : public Module + , public EventHook<Event::UserNickChange> + , public EventHook<Event::ChannelSync> + , public EventHook<Event::ChanRegistered> + , public EventHook<Event::DelChan> + , public EventHook<Event::MLockEvents> { UnrealIRCdProto ircd_proto; @@ -1173,22 +1178,53 @@ class ProtoUnreal : public Module } public: - ProtoUnreal(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR), - ircd_proto(this), - message_away(this), message_error(this), message_invite(this), message_join(this), message_kick(this), - message_kill(this), message_motd(this), message_notice(this), message_part(this), message_ping(this), - message_privmsg(this), message_quit(this), message_squit(this), message_stats(this), message_time(this), - message_version(this), message_whois(this), - - message_capab(this), message_chghost(this), message_chgident(this), message_chgname(this), message_mode(this, "MODE"), - message_svsmode(this, "SVSMODE"), message_svs2mode(this, "SVS2MODE"), message_netinfo(this), message_nick(this), message_pong(this), - message_sasl(this), message_sdesc(this), message_sethost(this), message_setident(this), message_setname(this), message_server(this), - message_sjoin(this), message_topic(this), message_umode2(this) + ProtoUnreal(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PROTOCOL | VENDOR) + , EventHook<Event::UserNickChange>("OnUserNickChange", EventHook<Event::UserNickChange>::Priority::FIRST) + , EventHook<Event::ChannelSync>("OnChannelSync", EventHook<Event::ChannelSync>::Priority::FIRST) + , EventHook<Event::ChanRegistered>("OnChanRegistered", EventHook<Event::ChanRegistered>::Priority::FIRST) + , EventHook<Event::DelChan>("OnDelChan", EventHook<Event::DelChan>::Priority::FIRST) + , EventHook<Event::MLockEvents>("MLock", EventHook<Event::MLockEvents>::Priority::FIRST) + , ircd_proto(this) + , message_away(this) + , message_error(this) + , message_invite(this) + , message_join(this) + , message_kick(this) + , message_kill(this) + , message_motd(this) + , message_notice(this) + , message_part(this) + , message_ping(this) + , message_privmsg(this) + , message_quit(this) + , message_squit(this) + , message_stats(this) + , message_time(this) + , message_version(this) + , message_whois(this) + + , message_capab(this) + , message_chghost(this) + , message_chgident(this) + , message_chgname(this) + , message_mode(this, "MODE") + , message_svsmode(this, "SVSMODE") + , message_svs2mode(this, "SVS2MODE") + , message_netinfo(this) + , message_nick(this) + , message_pong(this) + , message_sasl(this) + , message_sdesc(this) + , message_sethost(this) + , message_setident(this) + , message_setname(this) + , message_server(this) + , message_sjoin(this) + , message_topic(this) + , message_umode2(this) { this->AddModes(); - - ModuleManager::SetPriority(this, PRIORITY_FIRST); } void OnReload(Configuration::Conf *conf) override diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp index cd09ed227..dbaf7b8d2 100644 --- a/modules/pseudoclients/botserv.cpp +++ b/modules/pseudoclients/botserv.cpp @@ -10,15 +10,35 @@ */ #include "module.h" +#include "modules/help.h" class BotServCore : public Module + , public EventHook<Event::SetCorrectModes> + , public EventHook<Event::BotAssign> + , public EventHook<Event::JoinChannel> + , public EventHook<Event::LeaveChannel> + , public EventHook<Event::Help> + , public EventHook<Event::ChannelModeSet> + , public EventHook<Event::CreateChan> + , public EventHook<Event::UserKicked> + , public EventHook<Event::CreateBot> { Reference<BotInfo> BotServ; ExtensibleRef<bool> persist, inhabit; public: - BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), - persist("PERSIST"), inhabit("inhabit") + BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) + , EventHook<Event::SetCorrectModes>("OnSetCorrectModes") + , EventHook<Event::BotAssign>("OnBotAssign") + , EventHook<Event::JoinChannel>("OnJoinChannel") + , EventHook<Event::LeaveChannel>("OnLeaveChannel") + , EventHook<Event::Help>("Help") + , EventHook<Event::ChannelModeSet>("OnChannelModeSet") + , EventHook<Event::CreateChan>("OnCreateChan") + , EventHook<Event::UserKicked>("OnUserKicked") + , EventHook<Event::CreateBot>("OnCreateBot") + , persist("PERSIST") + , inhabit("inhabit") { } diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp index 1d6e1090c..7c607e251 100644 --- a/modules/pseudoclients/chanserv.cpp +++ b/modules/pseudoclients/chanserv.cpp @@ -11,18 +11,66 @@ #include "module.h" #include "modules/cs_mode.h" - -class ChanServCore : public Module, public ChanServService +#include "modules/help.h" +#include "modules/bs_bot.h" +#include "modules/chanserv.h" +#include "modules/cs_info.h" + +class ChanServCore : public Module + , public ChanServ::ChanServService + , public EventHook<Event::BotDelete> + , public EventHook<Event::BotPrivmsg> + , public EventHook<Event::DelCore> + , public EventHook<Event::DelChan> + , public EventHook<Event::Help> + , public EventHook<Event::CheckModes> + , public EventHook<Event::CreateChan> + , public EventHook<Event::CanSet> + , public EventHook<Event::ChannelSync> + , public EventHook<Event::Log> + , public EventHook<Event::ExpireTick> + , public EventHook<Event::CheckDelete> + , public EventHook<Event::PreUplinkSync> + , public EventHook<Event::ChanRegistered> + , public EventHook<Event::JoinChannel> + , public EventHook<Event::ChannelModeSet> + , public EventHook<Event::ChanInfo> + , public EventHook<Event::SetCorrectModes> { Reference<BotInfo> ChanServ; std::vector<Anope::string> defaults; ExtensibleItem<bool> inhabit; ExtensibleRef<bool> persist; bool always_lower; + EventHandlers<ChanServ::Event::PreChanExpire> OnPreChanExpire; + EventHandlers<ChanServ::Event::ChanExpire> OnChanExpire; public: - ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), - ChanServService(this), inhabit(this, "inhabit"), persist("PERSIST"), always_lower(false) + ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) + , ChanServService(this) + , EventHook<Event::BotDelete>("OnBotDelete") + , EventHook<Event::BotPrivmsg>("OnBotPrivmsg") + , EventHook<Event::DelCore>("OnDelCore") + , EventHook<Event::DelChan>("OnDelChan") + , EventHook<Event::Help>("OnHelp") + , EventHook<Event::CheckModes>("OnCheckModes") + , EventHook<Event::CreateChan>("OnCreateChan") + , EventHook<Event::CanSet>("OnCanSet") + , EventHook<Event::ChannelSync>("OnChannelSync") + , EventHook<Event::Log>("OnLog") + , EventHook<Event::ExpireTick>("OnExpireTick") + , EventHook<Event::CheckDelete>("OnCheckDelete") + , EventHook<Event::PreUplinkSync>("OnPreUplinkSync") + , EventHook<Event::ChanRegistered>("OnChanRegistered") + , EventHook<Event::JoinChannel>("OnJoinChannel") + , EventHook<Event::ChannelModeSet>("OnChannelModeSet") + , EventHook<Event::ChanInfo>("OnChanInfo") + , EventHook<Event::SetCorrectModes>("OnSetCorrectModes") + , inhabit(this, "inhabit") + , persist("PERSIST") + , always_lower(false) + , OnPreChanExpire(this, "OnPreChanExpire") + , OnChanExpire(this, "OnChanExpire") { } @@ -167,13 +215,13 @@ class ChanServCore : public Module, public ChanServService if (newowner) { - Log(LOG_NORMAL, "chanserv/drop", ChanServ) << "Transferring foundership of " << ci->name << " from deleted nick " << nc->display << " to " << newowner->display; + ::Log(LOG_NORMAL, "chanserv/drop", ChanServ) << "Transferring foundership of " << ci->name << " from deleted nick " << nc->display << " to " << newowner->display; ci->SetFounder(newowner); ci->SetSuccessor(NULL); } else { - Log(LOG_NORMAL, "chanserv/drop", ChanServ) << "Deleting channel " << ci->name << " owned by deleted nick " << nc->display; + ::Log(LOG_NORMAL, "chanserv/drop", ChanServ) << "Deleting channel " << ci->name << " owned by deleted nick " << nc->display; delete ci; continue; @@ -318,7 +366,7 @@ class ChanServCore : public Module, public ChanServService } } - void OnLog(Log *l) override + void OnLog(::Log *l) override { if (l->type == LOG_CHANNEL) l->bi = ChanServ; @@ -351,12 +399,12 @@ class ChanServCore : public Module, public ChanServService expire = true; } - FOREACH_MOD(OnPreChanExpire, (ci, expire)); + this->OnPreChanExpire(&ChanServ::Event::PreChanExpire::OnPreChanExpire, ci, expire); if (expire) { - Log(LOG_NORMAL, "chanserv/expire", ChanServ) << "Expiring channel " << ci->name << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << ")"; - FOREACH_MOD(OnChanExpire, (ci)); + ::Log(LOG_NORMAL, "chanserv/expire", ChanServ) << "Expiring channel " << ci->name << " (founder: " << (ci->GetFounder() ? ci->GetFounder()->display : "(none)") << ")"; + this->OnChanExpire(&ChanServ::Event::ChanExpire::OnChanExpire, ci); delete ci; } } @@ -425,7 +473,7 @@ class ChanServCore : public Module, public ChanServService { if (always_lower && c->ci && c->creation_time > c->ci->time_registered) { - Log(LOG_DEBUG) << "Changing TS of " << c->name << " from " << c->creation_time << " to " << c->ci->time_registered; + ::Log(LOG_DEBUG) << "Changing TS of " << c->name << " from " << c->creation_time << " to " << c->ci->time_registered; c->creation_time = c->ci->time_registered; IRCD->SendChannel(c); c->Reset(); diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp index fe15a3ef9..e7577db47 100644 --- a/modules/pseudoclients/global.cpp +++ b/modules/pseudoclients/global.cpp @@ -10,8 +10,15 @@ */ #include "module.h" - -class GlobalCore : public Module, public GlobalService +#include "modules/help.h" +#include "modules/global.h" + +class GlobalCore : public Module + , public Global::GlobalService + , public EventHook<Event::Restart> + , public EventHook<Event::Shutdown> + , public EventHook<Event::NewServer> + , public EventHook<Event::Help> { Reference<BotInfo> Global; @@ -24,8 +31,12 @@ class GlobalCore : public Module, public GlobalService } public: - GlobalCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), - GlobalService(this) + GlobalCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) + , GlobalService(this) + , EventHook<Event::Restart>("OnRestart") + , EventHook<Event::Shutdown>("OnShutdown") + , EventHook<Event::NewServer>("OnNewServer") + , EventHook<Event::Help>("OnHelp") { } @@ -90,6 +101,10 @@ class GlobalCore : public Module, public GlobalService source.Reply(_("%s commands:"), Global->nick.c_str()); return EVENT_CONTINUE; } + + void OnPostHelp(CommandSource &source, const std::vector<Anope::string> ¶ms) override + { + } }; MODULE_INIT(GlobalCore) diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp index 9d9130fa6..373275e59 100644 --- a/modules/pseudoclients/hostserv.cpp +++ b/modules/pseudoclients/hostserv.cpp @@ -10,12 +10,26 @@ */ #include "module.h" +#include "modules/ns_update.h" +#include "modules/hs_del.h" +#include "modules/help.h" class HostServCore : public Module + , public EventHook<Event::UserLogin> + , public EventHook<Event::NickUpdate> + , public EventHook<Event::Help> + , public EventHook<Event::SetVhost> + , public EventHook<Event::DeleteVhost> { Reference<BotInfo> HostServ; + public: HostServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) + , EventHook<Event::UserLogin>("OnUserLogin") + , EventHook<Event::NickUpdate>("OnNickUpdate") + , EventHook<Event::Help>("OnHelp") + , EventHook<Event::SetVhost>("OnSetVhost") + , EventHook<Event::DeleteVhost>("OnDeleteVhost") { if (!IRCD || !IRCD->CanSetVHost) throw ModuleException("Your IRCd does not support vhosts"); @@ -79,6 +93,10 @@ class HostServCore : public Module return EVENT_CONTINUE; } + void OnPostHelp(CommandSource &source, const std::vector<Anope::string> ¶ms) override + { + } + void OnSetVhost(NickAlias *na) override { if (Config->GetModule(this)->Get<bool>("activate_on_set")) diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv.cpp index 71f5e64d0..c9b11d294 100644 --- a/modules/pseudoclients/memoserv.cpp +++ b/modules/pseudoclients/memoserv.cpp @@ -10,10 +10,24 @@ */ #include "module.h" - -class MemoServCore : public Module, public MemoServService +#include "modules/ns_update.h" +#include "modules/help.h" +#include "modules/bs_bot.h" +#include "modules/memoserv.h" + +class MemoServCore : public Module, public MemoServ::MemoServService + , public EventHook<Event::NickCoreCreate> + , public EventHook<Event::CreateChan> + , public EventHook<Event::BotDelete> + , public EventHook<Event::NickIdentify> + , public EventHook<Event::JoinChannel> + , public EventHook<Event::UserAway> + , public EventHook<Event::NickUpdate> + , public EventHook<Event::Help> { Reference<BotInfo> MemoServ; + EventHandlers<MemoServ::Event::MemoSend> onmemosend; + EventHandlers<MemoServ::Event::MemoDel> onmemodel; bool SendMemoMail(NickCore *nc, MemoInfo *mi, Memo *m) { @@ -36,8 +50,18 @@ class MemoServCore : public Module, public MemoServService } public: - MemoServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), - MemoServService(this) + MemoServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) + , MemoServ::MemoServService(this) + , EventHook<Event::NickCoreCreate>("OnNickCoreCreate") + , EventHook<Event::CreateChan>("OnCreateChan") + , EventHook<Event::BotDelete>("OnBotDelete") + , EventHook<Event::NickIdentify>("OnNickIdentify") + , EventHook<Event::JoinChannel>("OnJoinChannel") + , EventHook<Event::UserAway>("OnUserAway") + , EventHook<Event::NickUpdate>("OnNickUpdate") + , EventHook<Event::Help>("OnHelp") + , onmemosend(this, "OnMemoSend") + , onmemodel(this, "OnMemoDel") { } @@ -74,7 +98,7 @@ class MemoServCore : public Module, public MemoServService m->text = message; m->unread = true; - FOREACH_MOD(OnMemoSend, (source, target, mi, m)); + this->onmemosend(&MemoServ::Event::MemoSend::OnMemoSend, source, target, mi, m); if (ischan) { diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp index d8b55a9d5..f29b1aa02 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv.cpp @@ -10,18 +10,23 @@ */ #include "module.h" +#include "modules/ns_info.h" +#include "modules/ns_group.h" +#include "modules/ns_update.h" +#include "modules/help.h" +#include "modules/nickserv.h" /** Timer for colliding nicks to force people off of nicknames */ class NickServCollide : public Timer { - NickServService *service; + NickServ::NickServService *service; Reference<User> u; time_t ts; Reference<NickAlias> na; public: - NickServCollide(NickServService *nss, User *user, NickAlias *nick, time_t delay) : Timer(delay), service(nss), u(user), ts(user->timestamp), na(nick) + NickServCollide(NickServ::NickServService *nss, User *user, NickAlias *nick, time_t delay) : Timer(delay), service(nss), u(user), ts(user->timestamp), na(nick) { } @@ -91,11 +96,32 @@ class NickServRelease : public User, public Timer void Tick(time_t t) override { } }; -class NickServCore : public Module, public NickServService +class NickServCore : public Module, public NickServ::NickServService + , public EventHook<Event::Shutdown> + , public EventHook<Event::Restart> + , public EventHook<Event::UserLogin> + , public EventHook<Event::DelNick> + , public EventHook<Event::DelCore> + , public EventHook<Event::ChangeCoreDisplay> + , public EventHook<Event::NickIdentify> + , public EventHook<Event::NickGroup> + , public EventHook<Event::NickUpdate> + , public EventHook<Event::UserConnect> + , public EventHook<Event::PostUserLogoff> + , public EventHook<Event::ServerSync> + , public EventHook<Event::UserNickChange> + , public EventHook<Event::UserModeSet> + , public EventHook<Event::Help> + , public EventHook<Event::ExpireTick> + , public EventHook<Event::NickInfo> { Reference<BotInfo> NickServ; std::vector<Anope::string> defaults; ExtensibleItem<bool> held, collided; + EventHandlers<NickServ::Event::PreNickExpire> onprenickexpire; + EventHandlers<NickServ::Event::NickExpire> onnickexpire; + EventHandlers<NickServ::Event::NickRegister> onnickregister; + EventHandlers<NickServ::Event::NickValidate> onnickvalidate; void OnCancel(User *u, NickAlias *na) { @@ -113,8 +139,31 @@ class NickServCore : public Module, public NickServService } public: - NickServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), - NickServService(this), held(this, "HELD"), collided(this, "COLLIDED") + NickServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) + , NickServ::NickServService(this) + , EventHook<Event::Shutdown>("OnShutdown") + , EventHook<Event::Restart>("OnRestart") + , EventHook<Event::UserLogin>("OnUserLogin") + , EventHook<Event::DelNick>("OnDelNick") + , EventHook<Event::DelCore>("OnDelCore") + , EventHook<Event::ChangeCoreDisplay>("OnChangeCoreDisplay") + , EventHook<Event::NickIdentify>("OnNickIdentify") + , EventHook<Event::NickGroup>("OnNickGroup") + , EventHook<Event::NickUpdate>("OnNickUpdate") + , EventHook<Event::UserConnect>("OnUserConnect") + , EventHook<Event::PostUserLogoff>("OnPostUserLogoff") + , EventHook<Event::ServerSync>("OnServerSync") + , EventHook<Event::UserNickChange>("OnUserNickChange") + , EventHook<Event::UserModeSet>("OnUserModeSet") + , EventHook<Event::Help>("OnHelp") + , EventHook<Event::ExpireTick>("OnExpireTick") + , EventHook<Event::NickInfo>("OnNickInfo") + , held(this, "HELD") + , collided(this, "COLLIDED") + , onprenickexpire(this, "OnPreNickExpire") + , onnickexpire(this, "OnNickExpire") + , onnickregister(this, "OnNickRegister") + , onnickvalidate(this, "OnNickValidate") { } @@ -143,8 +192,7 @@ class NickServCore : public Module, public NickServService if (!na) return; - EventReturn MOD_RESULT; - FOREACH_RESULT(OnNickValidate, MOD_RESULT, (u, na)); + EventReturn MOD_RESULT = this->onnickvalidate(&NickServ::Event::NickValidate::OnNickValidate, u, na); if (MOD_RESULT == EVENT_STOP) { this->Collide(u, na); @@ -306,7 +354,7 @@ class NickServCore : public Module, public NickServService IRCD->SendLogout(user); user->RemoveMode(NickServ, "REGISTERED"); user->Logout(); - FOREACH_MOD(OnNickLogout, (user)); + Event::OnNickLogout(&Event::NickLogout::OnNickLogout, user); } nc->users.clear(); } @@ -515,12 +563,12 @@ class NickServCore : public Module, public NickServService if (nickserv_expire && Anope::CurTime - na->last_seen >= nickserv_expire) expire = true; - FOREACH_MOD(OnPreNickExpire, (na, expire)); + this->onprenickexpire(&NickServ::Event::PreNickExpire::OnPreNickExpire, na, expire); if (expire) { Log(LOG_NORMAL, "nickserv/expire", NickServ) << "Expiring nickname " << na->nick << " (group: " << na->nc->display << ") (e-mail: " << (na->nc->email.empty() ? "none" : na->nc->email) << ")"; - FOREACH_MOD(OnNickExpire, (na)); + this->onnickexpire(&NickServ::Event::NickExpire::OnNickExpire, na); delete na; } } diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp index 7b43436f7..91d7f1add 100644 --- a/modules/pseudoclients/operserv.cpp +++ b/modules/pseudoclients/operserv.cpp @@ -10,6 +10,8 @@ */ #include "module.h" +#include "modules/help.h" +#include "modules/nickserv.h" class SGLineManager : public XLineManager { @@ -23,7 +25,7 @@ class SGLineManager : public XLineManager void OnExpire(const XLine *x) override { - Log(Config->GetClient("OperServ"), "expire/akill") << "AKILL on \002" << x->mask << "\002 has expired"; + ::Log(Config->GetClient("OperServ"), "expire/akill") << "AKILL on \002" << x->mask << "\002 has expired"; } void Send(User *u, XLine *x) override @@ -68,10 +70,8 @@ class SGLineManager : public XLineManager class SQLineManager : public XLineManager { - ServiceReference<NickServService> nickserv; - public: - SQLineManager(Module *creator) : XLineManager(creator, "xlinemanager/sqline", 'Q'), nickserv("NickServService", "NickServ") { } + SQLineManager(Module *creator) : XLineManager(creator, "xlinemanager/sqline", 'Q') { } void OnMatch(User *u, XLine *x) override { @@ -80,7 +80,7 @@ class SQLineManager : public XLineManager void OnExpire(const XLine *x) override { - Log(Config->GetClient("OperServ"), "expire/sqline") << "SQLINE on \002" << x->mask << "\002 has expired"; + ::Log(Config->GetClient("OperServ"), "expire/sqline") << "SQLINE on \002" << x->mask << "\002 has expired"; } void Send(User *u, XLine *x) override @@ -89,8 +89,8 @@ class SQLineManager : public XLineManager { if (!u) ; - else if (nickserv) - nickserv->Collide(u, NULL); + else if (NickServ::service) + NickServ::service->Collide(u, NULL); else u->Kill(Config->GetClient("OperServ"), "Q-Lined: " + x->reason); } @@ -144,7 +144,7 @@ class SNLineManager : public XLineManager void OnExpire(const XLine *x) override { - Log(Config->GetClient("OperServ"), "expire/snline") << "SNLINE on \002" << x->mask << "\002 has expired"; + ::Log(Config->GetClient("OperServ"), "expire/snline") << "SNLINE on \002" << x->mask << "\002 has expired"; } void Send(User *u, XLine *x) override @@ -171,6 +171,15 @@ class SNLineManager : public XLineManager }; class OperServCore : public Module + , public EventHook<Event::BotPrivmsg> + , public EventHook<Event::ServerQuit> + , public EventHook<Event::UserModeSet> + , public EventHook<Event::UserModeUnset> + , public EventHook<Event::UserConnect> + , public EventHook<Event::UserNickChange> + , public EventHook<Event::CheckKick> + , public EventHook<Event::Help> + , public EventHook<Event::Log> { Reference<BotInfo> OperServ; SGLineManager sglines; @@ -178,8 +187,19 @@ class OperServCore : public Module SNLineManager snlines; public: - OperServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR), - sglines(this), sqlines(this), snlines(this) + OperServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) + , EventHook<Event::BotPrivmsg>("OnBotPrivmsg") + , EventHook<Event::ServerQuit>("OnServerQuit") + , EventHook<Event::UserModeSet>("OnUserModeSet") + , EventHook<Event::UserModeUnset>("OnUserModeUnset") + , EventHook<Event::UserConnect>("OnUserConnect") + , EventHook<Event::UserNickChange>("OnUserNickChange") + , EventHook<Event::CheckKick>("OnCheckKick") + , EventHook<Event::Help>("OnHelp") + , EventHook<Event::Log>("OnLog") + , sglines(this) + , sqlines(this) + , snlines(this) { /* Yes, these are in this order for a reason. Most violent->least violent. */ @@ -218,7 +238,7 @@ class OperServCore : public Module if (bi == OperServ && !u->HasMode("OPER") && Config->GetModule(this)->Get<bool>("opersonly")) { u->SendMessage(bi, ACCESS_DENIED); - Log(bi, "bados") << "Denied access to " << bi->nick << " from " << u->GetMask() << " (non-oper)"; + ::Log(bi, "bados") << "Denied access to " << bi->nick << " from " << u->GetMask() << " (non-oper)"; return EVENT_STOP; } @@ -228,19 +248,19 @@ class OperServCore : public Module void OnServerQuit(Server *server) override { if (server->IsJuped()) - Log(server, "squit", OperServ) << "Received SQUIT for juped server " << server->GetName(); + ::Log(server, "squit", OperServ) << "Received SQUIT for juped server " << server->GetName(); } void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) override { if (mname == "OPER") - Log(u, "oper", OperServ) << "is now an IRC operator."; + ::Log(u, "oper", OperServ) << "is now an IRC operator."; } void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) override { if (mname == "OPER") - Log(u, "oper", OperServ) << "is no longer an IRC operator"; + ::Log(u, "oper", OperServ) << "is no longer an IRC operator"; } void OnUserConnect(User *u, bool &exempt) override @@ -276,7 +296,11 @@ class OperServCore : public Module return EVENT_CONTINUE; } - void OnLog(Log *l) override + void OnPostHelp(CommandSource &source, const std::vector<Anope::string> ¶ms) override + { + } + + void OnLog(::Log *l) override { if (l->type == LOG_SERVER) l->bi = OperServ; diff --git a/modules/webcpanel/pages/index.cpp b/modules/webcpanel/pages/index.cpp index debedd551..0b2ce3d9c 100644 --- a/modules/webcpanel/pages/index.cpp +++ b/modules/webcpanel/pages/index.cpp @@ -87,7 +87,7 @@ bool WebCPanel::Index::OnRequest(HTTPProvider *server, const Anope::string &page // Rate limit check. WebpanelRequest *req = new WebpanelRequest(me, reply, message, server, page_name, client, replacements, user, pass); - FOREACH_MOD(OnCheckAuthentication, (NULL, req)); + Event::OnCheckAuthentication(&Event::CheckAuthentication::OnCheckAuthentication, nullptr, req); req->Dispatch(); return false; } diff --git a/modules/webcpanel/webcpanel.cpp b/modules/webcpanel/webcpanel.cpp index d5acfbf67..17a64529b 100644 --- a/modules/webcpanel/webcpanel.cpp +++ b/modules/webcpanel/webcpanel.cpp @@ -43,14 +43,31 @@ class ModuleWebCPanel : public Module public: - ModuleWebCPanel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR), - panel(this, "webcpanel"), id(this, "webcpanel_id"), ip(this, "webcpanel_ip"), - style_css("style.css", "/static/style.css", "text/css"), logo_png("logo.png", "/static/logo.png", "image/png"), cubes_png("cubes.png", "/static/cubes.png", "image/png"), favicon_ico("favicon.ico", "/favicon.ico", "image/x-icon"), - index("/"), logout("/logout"), _register("/register"), confirm("/confirm"), - nickserv_info("NickServ", "/nickserv/info"), nickserv_cert("NickServ", "/nickserv/cert"), nickserv_access("NickServ", "/nickserv/access"), nickserv_alist("NickServ", "/nickserv/alist"), - chanserv_info("ChanServ", "/chanserv/info"), chanserv_set("ChanServ", "/chanserv/set"), chanserv_access("ChanServ", "/chanserv/access"), chanserv_akick("ChanServ", "/chanserv/akick"), - chanserv_modes("ChanServ", "/chanserv/modes"), chanserv_drop("ChanServ", "/chanserv/drop"), memoserv_memos("MemoServ", "/memoserv/memos"), hostserv_request("HostServ", "/hostserv/request"), - operserv_akill("OperServ", "/operserv/akill") + ModuleWebCPanel(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, EXTRA | VENDOR) + , panel(this, "webcpanel") + , id(this, "webcpanel_id") + , ip(this, "webcpanel_ip") + , style_css("style.css", "/static/style.css", "text/css") + , logo_png("logo.png", "/static/logo.png", "image/png") + , cubes_png("cubes.png", "/static/cubes.png", "image/png") + , favicon_ico("favicon.ico", "/favicon.ico", "image/x-icon") + , index("/") + , logout("/logout") + , _register("/register") + , confirm("/confirm") + , nickserv_info("NickServ", "/nickserv/info") + , nickserv_cert("NickServ", "/nickserv/cert") + , nickserv_access("NickServ", "/nickserv/access") + , nickserv_alist("NickServ", "/nickserv/alist") + , chanserv_info("ChanServ", "/chanserv/info") + , chanserv_set("ChanServ", "/chanserv/set") + , chanserv_access("ChanServ", "/chanserv/access") + , chanserv_akick("ChanServ", "/chanserv/akick") + , chanserv_modes("ChanServ", "/chanserv/modes") + , chanserv_drop("ChanServ", "/chanserv/drop") + , memoserv_memos("MemoServ", "/memoserv/memos") + , hostserv_request("HostServ", "/hostserv/request") + , operserv_akill("OperServ", "/operserv/akill") { me = this; |
