1
0
mirror of https://github.com/anope/anope.git synced 2026-06-26 16:56:39 +02:00

Track when our clients are introduced or not

This commit is contained in:
Adam
2011-08-12 12:46:11 -04:00
parent feee50e695
commit f3d7d4ee37
7 changed files with 27 additions and 4 deletions
+1
View File
@@ -41,6 +41,7 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>
typedef Anope::insensitive_map<CommandInfo> command_map;
command_map commands; /* Commands, actual name to service name */
Anope::string botmodes; /* Modes the bot should have as configured in service:modes */
bool introduced; /* Whether or not this bot is introduced */
/** Create a new bot.
* @param nick The nickname to assign to the bot.
+7 -4
View File
@@ -20,6 +20,7 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
this->chancount = 0;
this->lastmsg = this->created = Anope::CurTime;
this->introduced = false;
BotListByNick[this->nick] = this;
if (!this->uid.empty())
@@ -28,15 +29,16 @@ BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const A
// If we're synchronised with the uplink already, send the bot.
if (Me && Me->IsSynced())
{
Anope::string tmodes = !this->botmodes.empty() ? ("+" + this->botmodes) : (ircd ? ircd->pseudoclient_mode : "");
if (!tmodes.empty())
this->SetModesInternal(tmodes.c_str());
ircdproto->SendClientIntroduction(this);
this->introduced = true;
XLine x(this->nick, "Reserved for services");
ircdproto->SendSQLine(NULL, &x);
}
Anope::string tmodes = !this->botmodes.empty() ? ("+" + this->botmodes) : (ircd ? ircd->pseudoclient_mode : "");
if (!tmodes.empty())
this->SetModesInternal(tmodes.c_str());
if (Config)
for (unsigned i = 0; i < Config->LogInfos.size(); ++i)
{
@@ -70,6 +72,7 @@ BotInfo::~BotInfo()
if (Me && Me->IsSynced())
{
ircdproto->SendQuit(this, "");
this->introduced = false;
XLine x(this->nick);
ircdproto->SendSQLineDel(&x);
}
+2
View File
@@ -32,6 +32,8 @@ void introduce_user(const Anope::string &user)
BotInfo *bi = findbot(u->nick);
if (bi)
{
bi->introduced = true;
XLine x(bi->nick, "Reserved for services");
ircdproto->SendSQLine(NULL, &x);
+5
View File
@@ -127,8 +127,13 @@ class UplinkSocket : public ConnectionSocket
User *u = it->second;
if (u->server == Me)
{
/* Don't use quitmsg here, it may contain information you don't want people to see */
ircdproto->SendQuit(u, "Shutting down");
BotInfo *bi = findbot(u->nick);
if (bi != NULL)
bi->introduced = false;
}
}
ircdproto->SendSquit(Config->ServerName, quitmsg);
+1
View File
@@ -331,6 +331,7 @@ bool IRCdMessage::OnKill(const Anope::string &source, const std::vector<Anope::s
/* Recover if someone kills us. */
if (u->server == Me && (bi = dynamic_cast<BotInfo *>(u)))
{
bi->introduced = false;
introduce_user(bi->nick);
bi->RejoinAll();
}
+10
View File
@@ -39,6 +39,16 @@ void send_cmd(const Anope::string &source, const char *fmt, ...)
return;
}
if (!source.empty() && source.find(".") == Anope::string::npos)
{
BotInfo *bi = findbot(source);
if (bi != NULL && bi->introduced == false)
{
Log(LOG_DEBUG) << "Attempted to send \"" << source << " " << buf << "\" with source not introduced";
return;
}
}
if (!source.empty())
{
UplinkSock->Write(":%s %s", source.c_str(), buf);
+1
View File
@@ -82,6 +82,7 @@ Server::Server(Server *uplink, const Anope::string &name, unsigned hops, const A
BotInfo *bi = findbot(u->nick);
if (bi)
{
bi->introduced = true;
XLine x(bi->nick, "Reserved for services");
ircdproto->SendSQLine(NULL, &x);
}