diff options
-rw-r--r-- | include/anope.h | 7 | ||||
-rw-r--r-- | include/regchannel.h | 21 | ||||
-rw-r--r-- | include/services.h | 20 | ||||
-rw-r--r-- | src/chanserv.cpp | 13 | ||||
-rw-r--r-- | src/main.cpp | 2 |
5 files changed, 38 insertions, 25 deletions
diff --git a/include/anope.h b/include/anope.h index 51a80a598..a63abb9d1 100644 --- a/include/anope.h +++ b/include/anope.h @@ -291,7 +291,7 @@ namespace Anope /** The current system time, which is pretty close to being accurate. * Use this unless you need very specific time checks */ - static time_t CurTime = time(NULL); + extern time_t CurTime; extern CoreExport string Version(); @@ -477,6 +477,11 @@ class dynamic_reference : public dynamic_reference_base { return this->ref; } + + virtual inline T *operator*() + { + return this->ref; + } }; #endif // ANOPE_H diff --git a/include/regchannel.h b/include/regchannel.h index 2b7ea67f4..689857c2d 100644 --- a/include/regchannel.h +++ b/include/regchannel.h @@ -300,4 +300,25 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, void RestoreTopic(); }; +/** A timer used to keep the BotServ bot/ChanServ in the channel + * after kicking the last user in a channel + */ +class ChanServTimer : public Timer +{ + private: + dynamic_reference<Channel> c; + + public: + /** Default constructor + * @param chan The channel + */ + ChanServTimer(Channel *chan); + + /** Called when the delay is up + * @param The current time + */ + void Tick(time_t); +}; + + #endif // REGCHANNEL_H diff --git a/include/services.h b/include/services.h index 3034613b4..5575dc0bc 100644 --- a/include/services.h +++ b/include/services.h @@ -1030,26 +1030,6 @@ struct Uplink Uplink(const Anope::string &_host, int _port, const Anope::string &_password, bool _ipv6) : host(_host), port(_port), password(_password), ipv6(_ipv6) { } }; -/** A timer used to keep the BotServ bot/ChanServ in the channel - * after kicking the last user in a channel - */ -class ChanServTimer : public Timer -{ - private: - Channel *c; - - public: - /** Default constructor - * @param chan The channel - */ - ChanServTimer(Channel *chan); - - /** Called when th edelay is up - * @param The current time - */ - void Tick(time_t); -}; - /** A class to process numbered lists (passed to most DEL/LIST/VIEW commands). * The function HandleNumber is called for every number in the list. Note that * if descending is true it gets called in descending order. This is so deleting diff --git a/src/chanserv.cpp b/src/chanserv.cpp index 9d8fb411a..338d0f311 100644 --- a/src/chanserv.cpp +++ b/src/chanserv.cpp @@ -837,17 +837,22 @@ ChanServTimer::ChanServTimer(Channel *chan) : Timer(Config->CSInhabit), c(chan) { if (c->ci) c->ci->SetFlag(CI_INHABIT); - ChanServ->Join(c); + if (!c->ci->bi) + ChanServ->Join(*c); + else if (!c->FindUser(c->ci->bi)) + c->ci->bi->Join(*c); } void ChanServTimer::Tick(time_t) { - if (!c->ci) + if (!c || !c->ci) return; c->ci->UnsetFlag(CI_INHABIT); - if (c->users.size() == 1 || c->ci->bi != ChanServ) - ChanServ->Part(c); + if (!c->ci->bi) + ChanServ->Part(*c); + else if (c->users.size() == 1 || c->users.size() < Config->BSMinUsers) + c->ci->bi->Part(*c); } diff --git a/src/main.cpp b/src/main.cpp index 26ebd65ba..a1417b197 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -71,6 +71,8 @@ time_t start_time; /* Parameters and environment */ char **my_av, **my_envp; +time_t Anope::CurTime = time(NULL); + /******** Local variables! ********/ /* Set to 1 after we've set everything up */ |