diff options
author | Adam <Adam@anope.org> | 2012-11-24 21:22:32 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-11-24 21:22:32 -0500 |
commit | 0210cf2b171af3f5fd4842389e653dd909c716f8 (patch) | |
tree | 2334a5d17fdc7942ff6cdde893f24020ba5e4271 | |
parent | f0708340ef8919b3a4f9f90f22187d68b06048c0 (diff) |
Make the actual clients into services too
-rw-r--r-- | include/bots.h | 2 | ||||
-rw-r--r-- | modules/pseudoclients/botserv.cpp | 10 | ||||
-rw-r--r-- | modules/pseudoclients/botserv.h | 2 | ||||
-rw-r--r-- | modules/pseudoclients/chanserv.cpp | 11 | ||||
-rw-r--r-- | modules/pseudoclients/chanserv.h | 2 | ||||
-rw-r--r-- | modules/pseudoclients/global.cpp | 11 | ||||
-rw-r--r-- | modules/pseudoclients/global.h | 2 | ||||
-rw-r--r-- | modules/pseudoclients/hostserv.cpp | 11 | ||||
-rw-r--r-- | modules/pseudoclients/hostserv.h | 2 | ||||
-rw-r--r-- | modules/pseudoclients/memoserv.cpp | 11 | ||||
-rw-r--r-- | modules/pseudoclients/memoserv.h | 2 | ||||
-rw-r--r-- | modules/pseudoclients/nickserv.cpp | 11 | ||||
-rw-r--r-- | modules/pseudoclients/nickserv.h | 2 | ||||
-rw-r--r-- | modules/pseudoclients/operserv.cpp | 8 | ||||
-rw-r--r-- | modules/pseudoclients/operserv.h | 2 | ||||
-rw-r--r-- | src/bots.cpp | 2 |
16 files changed, 68 insertions, 23 deletions
diff --git a/include/bots.h b/include/bots.h index 3d44d08dd..9b613715b 100644 --- a/include/bots.h +++ b/include/bots.h @@ -35,7 +35,7 @@ enum BotFlag }; /* A service bot (NickServ, ChanServ, a BotServ bot, etc). */ -class CoreExport BotInfo : public User, public Flags<BotFlag>, public Serializable +class CoreExport BotInfo : public User, public Flags<BotFlag>, public Serializable, public Service { public: time_t created; diff --git a/modules/pseudoclients/botserv.cpp b/modules/pseudoclients/botserv.cpp index f78d0a6de..1cd67c060 100644 --- a/modules/pseudoclients/botserv.cpp +++ b/modules/pseudoclients/botserv.cpp @@ -20,14 +20,20 @@ class BotServCore : public Module { this->SetAuthor("Anope"); - BotServ = BotInfo::Find(Config->BotServ); - if (!BotServ) + BotInfo *bi = BotInfo::Find(Config->BotServ); + if (!bi) throw ModuleException("No bot named " + Config->BotServ); Implementation i[] = { I_OnPrivmsg, I_OnJoinChannel, I_OnLeaveChannel, I_OnPreHelp, I_OnPostHelp, I_OnChannelModeSet }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); + Service::AddAlias("BotInfo", "BotServ", bi->nick); + } + + ~BotServCore() + { + Service::DelAlias("BotInfo", "BotServ"); } void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_override diff --git a/modules/pseudoclients/botserv.h b/modules/pseudoclients/botserv.h index 9757e5d4e..362b15c23 100644 --- a/modules/pseudoclients/botserv.h +++ b/modules/pseudoclients/botserv.h @@ -1,6 +1,6 @@ #ifndef BOTSERV_H #define BOTSERV_H -static Reference<BotInfo> BotServ; +static ServiceReference<BotInfo> BotServ("BotInfo", "BotServ"); #endif // BOTSERV_H diff --git a/modules/pseudoclients/chanserv.cpp b/modules/pseudoclients/chanserv.cpp index 7a5b482bb..6f5cda048 100644 --- a/modules/pseudoclients/chanserv.cpp +++ b/modules/pseudoclients/chanserv.cpp @@ -61,12 +61,19 @@ class ChanServCore : public Module { this->SetAuthor("Anope"); - ChanServ = BotInfo::Find(Config->ChanServ); - if (!ChanServ) + BotInfo *bi = BotInfo::Find(Config->ChanServ); + if (!bi) throw ModuleException("No bot named " + Config->ChanServ); Implementation i[] = { I_OnBotPrivmsg, I_OnDelCore, I_OnPreHelp, I_OnPostHelp, I_OnCheckModes }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); + + Service::AddAlias("BotInfo", "ChanServ", bi->nick); + } + + ~ChanServCore() + { + Service::DelAlias("BotInfo", "ChanServ"); } EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) anope_override diff --git a/modules/pseudoclients/chanserv.h b/modules/pseudoclients/chanserv.h index 6c9ccd6c6..62ea86b22 100644 --- a/modules/pseudoclients/chanserv.h +++ b/modules/pseudoclients/chanserv.h @@ -1,6 +1,6 @@ #ifndef CHANSERV_H #define CHANSERV_H -static Reference<BotInfo> ChanServ; +static ServiceReference<BotInfo> ChanServ("BotInfo", "ChanServ"); #endif // CHANSERV_H diff --git a/modules/pseudoclients/global.cpp b/modules/pseudoclients/global.cpp index a5e1eb573..3fca89039 100644 --- a/modules/pseudoclients/global.cpp +++ b/modules/pseudoclients/global.cpp @@ -53,12 +53,19 @@ class GlobalCore : public Module { this->SetAuthor("Anope"); - Global = BotInfo::Find(Config->Global); - if (!Global) + BotInfo *bi = BotInfo::Find(Config->Global); + if (!bi) throw ModuleException("No bot named " + Config->Global); Implementation i[] = { I_OnRestart, I_OnShutdown, I_OnNewServer, I_OnPreHelp }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); + + Service::AddAlias("BotInfo", "Global", bi->nick); + } + + ~GlobalCore() + { + Service::DelAlias("BotInfo", "Global"); } void OnRestart() anope_override diff --git a/modules/pseudoclients/global.h b/modules/pseudoclients/global.h index 46bccef6d..f776e73e3 100644 --- a/modules/pseudoclients/global.h +++ b/modules/pseudoclients/global.h @@ -15,7 +15,7 @@ class GlobalService : public Service }; static ServiceReference<GlobalService> GlobalService("GlobalService", "Global"); -static Reference<BotInfo> Global; +static ServiceReference<BotInfo> Global("BotInfo", "Global"); #endif // GLOBAL_H diff --git a/modules/pseudoclients/hostserv.cpp b/modules/pseudoclients/hostserv.cpp index 47c4250c0..6f101720b 100644 --- a/modules/pseudoclients/hostserv.cpp +++ b/modules/pseudoclients/hostserv.cpp @@ -23,12 +23,19 @@ class HostServCore : public Module if (!IRCD || !IRCD->CanSetVHost) throw ModuleException("Your IRCd does not support vhosts"); - HostServ = BotInfo::Find(Config->HostServ); - if (!HostServ) + BotInfo *bi = BotInfo::Find(Config->HostServ); + if (!bi) throw ModuleException("No bot named " + Config->HostServ); Implementation i[] = { I_OnNickIdentify, I_OnNickUpdate, I_OnPreHelp }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); + + Service::AddAlias("BotInfo", "HostServ", bi->nick); + } + + ~HostServCore() + { + Service::DelAlias("BotInfo", "HostServ"); } void OnNickIdentify(User *u) anope_override diff --git a/modules/pseudoclients/hostserv.h b/modules/pseudoclients/hostserv.h index 039e711c3..cfadca806 100644 --- a/modules/pseudoclients/hostserv.h +++ b/modules/pseudoclients/hostserv.h @@ -1,6 +1,6 @@ #ifndef HOSTSERV_H #define HOSTSERV_H -static Reference<BotInfo> HostServ; +static ServiceReference<BotInfo> HostServ("BotInfo", "HostServ"); #endif // HOSTSERV_H diff --git a/modules/pseudoclients/memoserv.cpp b/modules/pseudoclients/memoserv.cpp index ee9c127f9..ff8d11602 100644 --- a/modules/pseudoclients/memoserv.cpp +++ b/modules/pseudoclients/memoserv.cpp @@ -165,12 +165,19 @@ class MemoServCore : public Module { this->SetAuthor("Anope"); - MemoServ = BotInfo::Find(Config->MemoServ); - if (!MemoServ) + BotInfo *bi = BotInfo::Find(Config->MemoServ); + if (!bi) throw ModuleException("No bot named " + Config->MemoServ); Implementation i[] = { I_OnNickIdentify, I_OnJoinChannel, I_OnUserAway, I_OnNickUpdate, I_OnPreHelp, I_OnPostHelp }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); + + Service::AddAlias("BotInfo", "MemoServ", bi->nick); + } + + ~MemoServCore() + { + Service::DelAlias("BotInfo", "MemoServ"); } void OnNickIdentify(User *u) anope_override diff --git a/modules/pseudoclients/memoserv.h b/modules/pseudoclients/memoserv.h index 25d453ab0..bd88fffd4 100644 --- a/modules/pseudoclients/memoserv.h +++ b/modules/pseudoclients/memoserv.h @@ -36,7 +36,7 @@ class MemoServService : public Service }; static ServiceReference<MemoServService> MemoServService("MemoServService", "MemoServ"); -static Reference<BotInfo> MemoServ; +static ServiceReference<BotInfo> MemoServ("BotInfo", "MemoServ"); #endif // MEMOSERV_H diff --git a/modules/pseudoclients/nickserv.cpp b/modules/pseudoclients/nickserv.cpp index 95044f610..0efb1d261 100644 --- a/modules/pseudoclients/nickserv.cpp +++ b/modules/pseudoclients/nickserv.cpp @@ -185,13 +185,20 @@ class NickServCore : public Module { this->SetAuthor("Anope"); - NickServ = BotInfo::Find(Config->NickServ); - if (!NickServ) + BotInfo *bi = BotInfo::Find(Config->NickServ); + if (!bi) throw ModuleException("No bot named " + Config->NickServ); Implementation i[] = { I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickIdentify, I_OnNickGroup, I_OnNickUpdate, I_OnUserNickChange, I_OnPreHelp, I_OnPostHelp, I_OnUserConnect }; ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation)); + + Service::AddAlias("BotInfo", "NickServ", bi->nick); + } + + ~NickServCore() + { + Service::DelAlias("BotInfo", "NickServ"); } void OnDelNick(NickAlias *na) anope_override diff --git a/modules/pseudoclients/nickserv.h b/modules/pseudoclients/nickserv.h index 52934fe96..3115ebc79 100644 --- a/modules/pseudoclients/nickserv.h +++ b/modules/pseudoclients/nickserv.h @@ -10,7 +10,7 @@ class NickServService : public Service }; static ServiceReference<NickServService> NickServService("NickServService", "NickServ"); -static Reference<BotInfo> NickServ; +static ServiceReference<BotInfo> NickServ("BotInfo", "NickServ"); #endif // NICKSERV_H diff --git a/modules/pseudoclients/operserv.cpp b/modules/pseudoclients/operserv.cpp index 8ee8c211b..5b61c3df9 100644 --- a/modules/pseudoclients/operserv.cpp +++ b/modules/pseudoclients/operserv.cpp @@ -175,8 +175,8 @@ class OperServCore : public Module { this->SetAuthor("Anope"); - OperServ = BotInfo::Find(Config->OperServ); - if (!OperServ) + BotInfo *bi = BotInfo::Find(Config->OperServ); + if (!bi) throw ModuleException("No bot named " + Config->OperServ); Implementation i[] = { I_OnBotPrivmsg, I_OnServerQuit, I_OnUserModeSet, I_OnUserModeUnset, I_OnUserConnect, I_OnUserNickChange, I_OnPreHelp }; @@ -186,10 +186,14 @@ class OperServCore : public Module XLineManager::RegisterXLineManager(&sglines); XLineManager::RegisterXLineManager(&sqlines); XLineManager::RegisterXLineManager(&snlines); + + Service::AddAlias("BotInfo", "OperServ", bi->nick); } ~OperServCore() { + Service::DelAlias("BotInfo", "OperServ"); + this->sglines.Clear(); this->sqlines.Clear(); this->snlines.Clear(); diff --git a/modules/pseudoclients/operserv.h b/modules/pseudoclients/operserv.h index dd9dafc76..e1577db1d 100644 --- a/modules/pseudoclients/operserv.h +++ b/modules/pseudoclients/operserv.h @@ -1,6 +1,6 @@ #ifndef OPERSERV_H #define OPERSERV_H -static Reference<BotInfo> OperServ; +static ServiceReference<BotInfo> OperServ("BotInfo", "OperServ"); #endif // OPERSERV_H diff --git a/src/bots.cpp b/src/bots.cpp index 52753148f..1e48d034e 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -32,7 +32,7 @@ static const Anope::string BotServFlagStrings[] = { }; template<> const Anope::string* Flags<BotServFlag>::flags_strings = BotServFlagStrings; -BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", Servers::TS6_UID_Retrieve()), Serializable("BotInfo"), botmodes(bmodes) +BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", Servers::TS6_UID_Retrieve()), Serializable("BotInfo"), Service(NULL, "BotInfo", nnick), botmodes(bmodes) { this->lastmsg = this->created = Anope::CurTime; this->introduced = false; |