1
0
mirror of https://github.com/anope/anope.git synced 2026-07-07 13:03:12 +02:00

Make the actual clients into services too

This commit is contained in:
Adam
2012-11-24 21:22:32 -05:00
parent f0708340ef
commit 0210cf2b17
16 changed files with 68 additions and 23 deletions
+1 -1
View File
@@ -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;
+8 -2
View File
@@ -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
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef BOTSERV_H
#define BOTSERV_H
static Reference<BotInfo> BotServ;
static ServiceReference<BotInfo> BotServ("BotInfo", "BotServ");
#endif // BOTSERV_H
+9 -2
View File
@@ -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
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef CHANSERV_H
#define CHANSERV_H
static Reference<BotInfo> ChanServ;
static ServiceReference<BotInfo> ChanServ("BotInfo", "ChanServ");
#endif // CHANSERV_H
+9 -2
View File
@@ -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
+1 -1
View File
@@ -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
+9 -2
View File
@@ -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
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef HOSTSERV_H
#define HOSTSERV_H
static Reference<BotInfo> HostServ;
static ServiceReference<BotInfo> HostServ("BotInfo", "HostServ");
#endif // HOSTSERV_H
+9 -2
View File
@@ -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
+1 -1
View File
@@ -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
+9 -2
View File
@@ -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
+1 -1
View File
@@ -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
+6 -2
View File
@@ -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();
+1 -1
View File
@@ -1,6 +1,6 @@
#ifndef OPERSERV_H
#define OPERSERV_H
static Reference<BotInfo> OperServ;
static ServiceReference<BotInfo> OperServ("BotInfo", "OperServ");
#endif // OPERSERV_H
+1 -1
View File
@@ -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;