summaryrefslogtreecommitdiff
path: root/src/bots.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-06-23 09:45:15 -0400
committerAdam <Adam@anope.org>2014-06-23 09:45:15 -0400
commitfd9bb0ea7e3c8a39f1632c2ebbdc25d0fac192a0 (patch)
tree1d68e86065e0b012aee41533d4f9b289ee0707ac /src/bots.cpp
parent148b26f687ce85dc01e852a2358b03d493757ada (diff)
parent9a947fa4359c667be58ebae4634d9ac0e53d5db4 (diff)
Merge branch '2.0' into 2.1
Conflicts: cmake/Anope.cmake cmake/FindGettext.cmake include/access.h include/messages.h include/modes.h include/modules.h include/users.h modules/CMakeLists.txt modules/commands/bs_bot.cpp modules/commands/cs_access.cpp modules/commands/cs_ban.cpp modules/commands/cs_clone.cpp modules/commands/cs_flags.cpp modules/commands/cs_info.cpp modules/commands/cs_list.cpp modules/commands/cs_log.cpp modules/commands/cs_mode.cpp modules/commands/cs_status.cpp modules/commands/cs_suspend.cpp modules/commands/cs_updown.cpp modules/commands/cs_xop.cpp modules/commands/ms_check.cpp modules/commands/ns_access.cpp modules/commands/ns_cert.cpp modules/commands/ns_group.cpp modules/commands/ns_register.cpp modules/commands/ns_set.cpp modules/commands/ns_suspend.cpp modules/commands/os_session.cpp modules/commands/os_svs.cpp modules/extra/m_ldap_authentication.cpp modules/extra/m_regex_pcre.cpp modules/extra/m_sql_authentication.cpp modules/extra/stats/m_chanstats.cpp modules/protocol/bahamut.cpp modules/protocol/hybrid.cpp modules/protocol/inspircd12.cpp modules/protocol/inspircd20.cpp modules/protocol/unreal.cpp modules/pseudoclients/chanserv.cpp modules/pseudoclients/chanserv/channel.cpp modules/pseudoclients/nickserv/nickserv.cpp modules/webcpanel/pages/chanserv/access.cpp src/access.cpp src/bots.cpp src/channels.cpp src/language.cpp src/modes.cpp src/modulemanager.cpp src/process.cpp src/users.cpp src/version.sh
Diffstat (limited to 'src/bots.cpp')
-rw-r--r--src/bots.cpp40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/bots.cpp b/src/bots.cpp
index 52773dd72..6f5c66388 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -22,7 +22,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("ChanServ::Channel"), 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;
@@ -56,6 +56,7 @@ BotInfo::~BotInfo()
if (Me && Me->IsSynced())
{
IRCD->SendQuit(this, "");
+ Event::OnUserQuit(&Event::UserQuit::OnUserQuit, this, "");
this->introduced = false;
XLine x(this->nick);
IRCD->SendSQLineDel(&x);
@@ -96,7 +97,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 +119,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;
}
@@ -213,11 +214,16 @@ void BotInfo::Part(Channel *c, const Anope::string &reason)
if (c->FindUser(this) == NULL)
return;
+ Event::OnPrePartChannel(&Event::PrePartChannel::OnPrePartChannel, this, c);
+
IRCD->SendPart(this, c, "%s", !reason.empty() ? reason.c_str() : "");
- Event::OnPartChannel(&Event::PartChannel::OnPartChannel, this, c, c->name, reason);
+ Anope::string cname = c->name;
+ Reference<Channel> cref = c;
c->DeleteUser(this);
+
+ Event::OnPartChannel(&Event::PartChannel::OnPartChannel, this, cref, cname, reason);
}
void BotInfo::OnMessage(User *u, const Anope::string &message)
@@ -262,22 +268,28 @@ CommandInfo *BotInfo::FindCommand(const Anope::string &service)
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;
}