diff options
| author | Adam <Adam@anope.org> | 2014-04-20 14:35:14 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2014-04-20 14:35:14 -0400 |
| commit | 26ac315192e0d8a04d50e910697ab794eedf0cc1 (patch) | |
| tree | b9916f14fe35ce5c4de95c4194ca4ea0cb30812f /modules/commands | |
| parent | 0b6476f06ff9ce06545c421143c7d7163c750aa5 (diff) | |
New event system
Diffstat (limited to 'modules/commands')
103 files changed, 942 insertions, 506 deletions
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; |
