diff options
-rw-r--r-- | include/bots.h | 1 | ||||
-rw-r--r-- | src/bots.cpp | 11 | ||||
-rw-r--r-- | src/init.cpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 5 | ||||
-rw-r--r-- | src/protocol.cpp | 1 | ||||
-rw-r--r-- | src/send.cpp | 10 | ||||
-rw-r--r-- | src/servers.cpp | 1 |
7 files changed, 27 insertions, 4 deletions
diff --git a/include/bots.h b/include/bots.h index 477380c2c..399ba3ea1 100644 --- a/include/bots.h +++ b/include/bots.h @@ -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. diff --git a/src/bots.cpp b/src/bots.cpp index e94691b05..3e9af64d5 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -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); } diff --git a/src/init.cpp b/src/init.cpp index 0a218f099..49d9759a8 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -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); diff --git a/src/main.cpp b/src/main.cpp index df3d217dd..401431683 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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); diff --git a/src/protocol.cpp b/src/protocol.cpp index 1c2ef4d7d..8517c73b6 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -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(); } diff --git a/src/send.cpp b/src/send.cpp index c7a0608f8..28c1ca08c 100644 --- a/src/send.cpp +++ b/src/send.cpp @@ -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); diff --git a/src/servers.cpp b/src/servers.cpp index e63311eef..d1e20e515 100644 --- a/src/servers.cpp +++ b/src/servers.cpp @@ -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); } |