summaryrefslogtreecommitdiff
path: root/src/bots.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-10-15 16:25:57 -0400
committerAdam <Adam@anope.org>2016-10-15 16:25:57 -0400
commit1ba242179fee46583098f48421af39ce9a8985a1 (patch)
treea276cd7bd53e7270c86ab3744bd6a568a016501b /src/bots.cpp
parent696239e93391f3dfd6459857fb02a6006048093a (diff)
Various improvements/bugfixes to extdb stuff
Diffstat (limited to 'src/bots.cpp')
-rw-r--r--src/bots.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/bots.cpp b/src/bots.cpp
index 07d6ec858..2ba7bda67 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -37,15 +37,6 @@ ServiceBot::ServiceBot(const Anope::string &nnick, const Anope::string &nuser, c
this->lastmsg = Anope::CurTime;
this->introduced = false;
- bi = Serialize::New<BotInfo *>();
- bi->bot = this;
-
- bi->SetNick(nnick);
- bi->SetUser(nuser);
- bi->SetHost(nhost);
- bi->SetRealName(nreal);
- bi->SetCreated(Anope::CurTime);
-
EventManager::Get()->Dispatch(&Event::CreateBot::OnCreateBot, this);
// If we're synchronised with the uplink already, send the bot.
@@ -65,8 +56,11 @@ ServiceBot::ServiceBot(const Anope::string &nnick, const Anope::string &nuser, c
ServiceBot::~ServiceBot()
{
- bi->bot = nullptr;
- bi->Delete();
+ if (bi != nullptr)
+ {
+ bi->bot = nullptr;
+ bi->Delete();
+ }
EventManager::Get()->Dispatch(&Event::DelBot::OnDelBot, this);
@@ -109,7 +103,8 @@ void ServiceBot::SetNewNick(const Anope::string &newnick)
{
UserListByNick.erase(this->nick);
- bi->SetNick(newnick);
+ if (bi != nullptr)
+ bi->SetNick(newnick);
this->nick = newnick;
UserListByNick[this->nick] = this;
@@ -117,7 +112,7 @@ void ServiceBot::SetNewNick(const Anope::string &newnick)
std::vector<ChanServ::Channel *> ServiceBot::GetChannels() const
{
- return bi->GetRefs<ChanServ::Channel *>();
+ return bi != nullptr ? bi->GetRefs<ChanServ::Channel *>() : std::vector<ChanServ::Channel *>();
}
void ServiceBot::Assign(User *u, ChanServ::Channel *ci)