diff options
author | Adam <Adam@anope.org> | 2014-05-21 08:50:40 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-05-21 08:50:40 -0400 |
commit | f627a3bacd0d058e94260dac1555790cafd9a926 (patch) | |
tree | 4ba71bf94b44ba07abc627ba0c26f3b8b94da439 /src/bots.cpp | |
parent | 5a1257b7f0b44ee3fd4639e5be288d160ceb5095 (diff) |
Core prep for p10 stuff
Diffstat (limited to 'src/bots.cpp')
-rw-r--r-- | src/bots.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/bots.cpp b/src/bots.cpp index 9ce918a91..16e6a1cf9 100644 --- a/src/bots.cpp +++ b/src/bots.cpp @@ -21,7 +21,7 @@ Serialize::Checker<botinfo_map> BotListByNick("BotInfo"), BotListByUID("BotInfo"); -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(), NULL), Serializable("BotInfo"), channels("ChannelInfo"), 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, "", IRCD ? IRCD->UID_Retrieve() : "", NULL), Serializable("BotInfo"), channels("ChannelInfo"), botmodes(bmodes) { this->lastmsg = this->created = Anope::CurTime; this->introduced = false; @@ -96,7 +96,7 @@ Serializable* BotInfo::Unserialize(Serializable *obj, Serialize::Data &data) BotInfo *bi; if (obj) bi = anope_dynamic_static_cast<BotInfo *>(obj); - else if (!(bi = BotInfo::Find(nick))) + else if (!(bi = BotInfo::Find(nick, true))) bi = new BotInfo(nick, user, host, realname); data["created"] >> bi->created; @@ -118,7 +118,7 @@ void BotInfo::GenerateUID() UserListByUID.erase(this->uid); } - this->uid = Servers::TS6_UID_Retrieve(); + this->uid = IRCD->UID_Retrieve(); (*BotListByUID)[this->uid] = this; UserListByUID[this->uid] = this; } @@ -215,9 +215,9 @@ void BotInfo::Part(Channel *c, const Anope::string &reason) IRCD->SendPart(this, c, "%s", !reason.empty() ? reason.c_str() : ""); - FOREACH_MOD(OnPartChannel, (this, c, c->name, reason)); - c->DeleteUser(this); + + FOREACH_MOD(OnPartChannel, (this, c, c->name, reason)); } void BotInfo::OnMessage(User *u, const Anope::string &message) @@ -248,22 +248,28 @@ CommandInfo *BotInfo::GetCommand(const Anope::string &cname) BotInfo* BotInfo::Find(const Anope::string &nick, bool nick_only) { - BotInfo *bi = NULL; - if (!nick_only && isdigit(nick[0]) && IRCD->RequiresID) + if (!nick_only && IRCD != NULL && IRCD->RequiresID) { botinfo_map::iterator it = BotListByUID->find(nick); if (it != BotListByUID->end()) - bi = it->second; + { + BotInfo *bi = it->second; + bi->QueueUpdate(); + return bi; + } + + if (IRCD->AmbiguousID) + return NULL; } - else + + botinfo_map::iterator it = BotListByNick->find(nick); + if (it != BotListByNick->end()) { - botinfo_map::iterator it = BotListByNick->find(nick); - if (it != BotListByNick->end()) - bi = it->second; + BotInfo *bi = it->second; + bi->QueueUpdate(); + return bi; } - if (bi) - bi->QueueUpdate(); - return bi; + return NULL; } |