summaryrefslogtreecommitdiff
path: root/modules/botserv/main
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-07-28 21:29:35 -0400
committerAdam <Adam@anope.org>2016-07-28 21:29:35 -0400
commit0e758a2ac23dc4a001e8e126cec14588da9a9769 (patch)
tree45df813323e023c5c89db7279426c4ad0943b4a9 /modules/botserv/main
parenta3c8afae00c54d5b95c620248b51f90679d7d53f (diff)
Allow serializable fields to use storage in the respective objects.
Split service management code nito a proper servicemanager. Make service references managed instead of lazy lookup. Also made events and serializable use service manager instead of their respective systems for management
Diffstat (limited to 'modules/botserv/main')
-rw-r--r--modules/botserv/main/botserv.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/modules/botserv/main/botserv.cpp b/modules/botserv/main/botserv.cpp
index 0b51691fc..a297db153 100644
--- a/modules/botserv/main/botserv.cpp
+++ b/modules/botserv/main/botserv.cpp
@@ -20,17 +20,25 @@ class BotServCore : public Module, public BotServ::BotServService
, public EventHook<Event::LeaveChannel>
, public EventHook<Event::Help>
, public EventHook<Event::ChannelModeSet>
- , public EventHook<Event::CreateChan>
+ , public EventHook<Event::ChanRegistered>
, public EventHook<Event::UserKicked>
, public EventHook<Event::CreateBot>
{
Reference<ServiceBot> BotServ;
- ExtensibleRef<bool> persist, inhabit;//XXX?
+ ExtensibleRef<bool> inhabit;
public:
BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR)
, BotServ::BotServService(this)
- , persist("PERSIST")
+ , EventHook<Event::SetCorrectModes>(this)
+ , EventHook<Event::BotAssign>(this)
+ , EventHook<Event::JoinChannel>(this)
+ , EventHook<Event::LeaveChannel>(this)
+ , EventHook<Event::Help>(this)
+ , EventHook<Event::ChannelModeSet>(this)
+ , EventHook<Event::ChanRegistered>(this)
+ , EventHook<Event::UserKicked>(this)
+ , EventHook<Event::CreateBot>(this)
, inhabit("inhabit")
{
}
@@ -119,7 +127,7 @@ class BotServCore : public Module, public BotServ::BotServService
void OnLeaveChannel(User *u, Channel *c) override
{
/* Channel is persistent, it shouldn't be deleted and the service bot should stay */
- if (c->ci && persist && persist->HasExt(c->ci))
+ if (c->ci && c->ci->HasFieldS("PERSIST"))
return;
/* Channel is syncing from a netburst, don't destroy it as more users are probably wanting to join immediately
@@ -132,9 +140,14 @@ class BotServCore : public Module, public BotServ::BotServService
if (inhabit && inhabit->HasExt(c))
return;
- /* This is called prior to removing the user from the channnel, so c->users.size() - 1 should be safe */
- if (c->ci && c->ci->GetBot() && u != c->ci->GetBot() && c->users.size() - 1 <= Config->GetModule(this)->Get<unsigned>("minusers") && c->FindUser(c->ci->GetBot()))
- c->ci->GetBot()->Part(c->ci->c);
+ if (c->ci)
+ {
+ ServiceBot *bot = c->ci->GetBot();
+
+ /* This is called prior to removing the user from the channnel, so c->users.size() - 1 should be safe */
+ if (bot && u != bot && c->users.size() - 1 <= Config->GetModule(this)->Get<unsigned>("minusers") && c->FindUser(bot))
+ bot->Part(c);
+ }
}
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) override
@@ -201,7 +214,7 @@ class BotServCore : public Module, public BotServ::BotServService
return EVENT_CONTINUE;
}
- void OnCreateChan(ChanServ::Channel *ci) override
+ void OnChanRegistered(ChanServ::Channel *ci) override
{
/* Set default bot flags */
spacesepstream sep(Config->GetModule(this)->Get<Anope::string>("defaults", "greet fantasy"));