summaryrefslogtreecommitdiff
path: root/modules/commands
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-04-20 14:35:14 -0400
committerAdam <Adam@anope.org>2014-04-20 14:35:14 -0400
commit26ac315192e0d8a04d50e910697ab794eedf0cc1 (patch)
treeb9916f14fe35ce5c4de95c4194ca4ea0cb30812f /modules/commands
parent0b6476f06ff9ce06545c421143c7d7163c750aa5 (diff)
New event system
Diffstat (limited to 'modules/commands')
-rw-r--r--modules/commands/bs_assign.cpp13
-rw-r--r--modules/commands/bs_badwords.cpp15
-rw-r--r--modules/commands/bs_bot.cpp22
-rw-r--r--modules/commands/bs_botlist.cpp4
-rw-r--r--modules/commands/bs_control.cpp4
-rw-r--r--modules/commands/bs_info.cpp15
-rw-r--r--modules/commands/bs_kick.cpp45
-rw-r--r--modules/commands/bs_set.cpp10
-rw-r--r--modules/commands/cs_access.cpp32
-rw-r--r--modules/commands/cs_akick.cpp23
-rw-r--r--modules/commands/cs_ban.cpp3
-rw-r--r--modules/commands/cs_clone.cpp5
-rw-r--r--modules/commands/cs_drop.cpp13
-rw-r--r--modules/commands/cs_enforce.cpp4
-rw-r--r--modules/commands/cs_entrymsg.cpp9
-rw-r--r--modules/commands/cs_flags.cpp11
-rw-r--r--modules/commands/cs_getkey.cpp3
-rw-r--r--modules/commands/cs_info.cpp13
-rw-r--r--modules/commands/cs_invite.cpp3
-rw-r--r--modules/commands/cs_kick.cpp3
-rw-r--r--modules/commands/cs_list.cpp13
-rw-r--r--modules/commands/cs_log.cpp19
-rw-r--r--modules/commands/cs_mode.cpp27
-rw-r--r--modules/commands/cs_register.cpp6
-rw-r--r--modules/commands/cs_seen.cpp20
-rw-r--r--modules/commands/cs_set.cpp94
-rw-r--r--modules/commands/cs_set_misc.cpp11
-rw-r--r--modules/commands/cs_status.cpp3
-rw-r--r--modules/commands/cs_suspend.cpp36
-rw-r--r--modules/commands/cs_sync.cpp5
-rw-r--r--modules/commands/cs_topic.cpp21
-rw-r--r--modules/commands/cs_unban.cpp4
-rw-r--r--modules/commands/cs_updown.cpp5
-rw-r--r--modules/commands/cs_xop.cpp13
-rw-r--r--modules/commands/gl_global.cpp20
-rw-r--r--modules/commands/greet.cpp23
-rw-r--r--modules/commands/help.cpp18
-rw-r--r--modules/commands/hs_del.cpp20
-rw-r--r--modules/commands/hs_group.cpp11
-rw-r--r--modules/commands/hs_list.cpp4
-rw-r--r--modules/commands/hs_off.cpp4
-rw-r--r--modules/commands/hs_on.cpp4
-rw-r--r--modules/commands/hs_request.cpp27
-rw-r--r--modules/commands/hs_set.cpp8
-rw-r--r--modules/commands/ms_cancel.cpp8
-rw-r--r--modules/commands/ms_check.cpp4
-rw-r--r--modules/commands/ms_del.cpp14
-rw-r--r--modules/commands/ms_ignore.cpp4
-rw-r--r--modules/commands/ms_info.cpp4
-rw-r--r--modules/commands/ms_list.cpp4
-rw-r--r--modules/commands/ms_read.cpp11
-rw-r--r--modules/commands/ms_rsend.cpp22
-rw-r--r--modules/commands/ms_send.cpp24
-rw-r--r--modules/commands/ms_sendall.cpp16
-rw-r--r--modules/commands/ms_set.cpp9
-rw-r--r--modules/commands/ms_staff.cpp16
-rw-r--r--modules/commands/ns_access.cpp7
-rw-r--r--modules/commands/ns_ajoin.cpp8
-rw-r--r--modules/commands/ns_alist.cpp4
-rw-r--r--modules/commands/ns_cert.cpp23
-rw-r--r--modules/commands/ns_drop.cpp13
-rw-r--r--modules/commands/ns_getemail.cpp5
-rw-r--r--modules/commands/ns_getpass.cpp4
-rw-r--r--modules/commands/ns_group.cpp27
-rw-r--r--modules/commands/ns_identify.cpp2
-rw-r--r--modules/commands/ns_info.cpp26
-rw-r--r--modules/commands/ns_list.cpp15
-rw-r--r--modules/commands/ns_logout.cpp13
-rw-r--r--modules/commands/ns_recover.cpp22
-rw-r--r--modules/commands/ns_register.cpp17
-rw-r--r--modules/commands/ns_resetpass.cpp6
-rw-r--r--modules/commands/ns_set.cpp85
-rw-r--r--modules/commands/ns_set_misc.cpp13
-rw-r--r--modules/commands/ns_status.cpp4
-rw-r--r--modules/commands/ns_suspend.cpp38
-rw-r--r--modules/commands/ns_update.cpp13
-rw-r--r--modules/commands/os_akill.cpp10
-rw-r--r--modules/commands/os_chankill.cpp4
-rw-r--r--modules/commands/os_config.cpp4
-rw-r--r--modules/commands/os_defcon.cpp57
-rw-r--r--modules/commands/os_dns.cpp18
-rw-r--r--modules/commands/os_forbid.cpp65
-rw-r--r--modules/commands/os_ignore.cpp8
-rw-r--r--modules/commands/os_info.cpp12
-rw-r--r--modules/commands/os_jupe.cpp4
-rw-r--r--modules/commands/os_kick.cpp4
-rw-r--r--modules/commands/os_kill.cpp4
-rw-r--r--modules/commands/os_list.cpp5
-rw-r--r--modules/commands/os_login.cpp8
-rw-r--r--modules/commands/os_logsearch.cpp4
-rw-r--r--modules/commands/os_mode.cpp5
-rw-r--r--modules/commands/os_modinfo.cpp5
-rw-r--r--modules/commands/os_module.cpp6
-rw-r--r--modules/commands/os_news.cpp13
-rw-r--r--modules/commands/os_noop.cpp7
-rw-r--r--modules/commands/os_oline.cpp4
-rw-r--r--modules/commands/os_oper.cpp5
-rw-r--r--modules/commands/os_reload.cpp4
-rw-r--r--modules/commands/os_session.cpp24
-rw-r--r--modules/commands/os_set.cpp4
-rw-r--r--modules/commands/os_stats.cpp5
-rw-r--r--modules/commands/os_sxline.cpp8
-rw-r--r--modules/commands/os_update.cpp4
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> &params)
{
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> &params)
@@ -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> &params)
@@ -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;