mirror of
https://github.com/anope/anope.git
synced 2026-06-30 07:16:38 +02:00
Made Anope track its own clients internally as if they were real users
This commit is contained in:
+62
-15
@@ -20,15 +20,14 @@ BotInfo *MemoServ = NULL;
|
||||
BotInfo *NickServ = NULL;
|
||||
BotInfo *OperServ = NULL;
|
||||
|
||||
BotInfo::BotInfo(const std::string &nnick, const std::string &nuser, const std::string &nhost, const std::string &nreal)
|
||||
BotInfo::BotInfo(const std::string &nnick, const std::string &nuser, const std::string &nhost, const std::string &nreal) : User(nnick, ts6_uid_retrieve())
|
||||
{
|
||||
this->nick = nnick;
|
||||
this->user = nuser;
|
||||
this->host = nhost;
|
||||
this->real = nreal;
|
||||
this->ident = nuser;
|
||||
this->host = sstrdup(nhost.c_str());
|
||||
this->realname = sstrdup(nreal.c_str());
|
||||
this->server = Me;
|
||||
|
||||
this->lastmsg = this->created = time(NULL);
|
||||
this->uid = ts6_uid_retrieve();
|
||||
this->chancount = 0;
|
||||
|
||||
ci::string ci_nick(nnick.c_str());
|
||||
if (Config.s_ChanServ && ci_nick == Config.s_ChanServ)
|
||||
@@ -53,7 +52,7 @@ BotInfo::BotInfo(const std::string &nnick, const std::string &nuser, const std::
|
||||
// If we're synchronised with the uplink already, call introduce_user() for this bot.
|
||||
if (Me && Me->GetUplink()->IsSynced())
|
||||
{
|
||||
ircdproto->SendClientIntroduction(this->nick, this->user, this->host, this->real, ircd->pseudoclient_mode, this->uid);
|
||||
ircdproto->SendClientIntroduction(this->nick, this->GetIdent(), this->host, this->realname, ircd->pseudoclient_mode, this->uid);
|
||||
XLine x(this->nick.c_str(), "Reserved for services");
|
||||
ircdproto->SendSQLine(&x);
|
||||
}
|
||||
@@ -77,10 +76,12 @@ BotInfo::~BotInfo()
|
||||
|
||||
void BotInfo::ChangeNick(const char *newnick)
|
||||
{
|
||||
UserListByNick.erase(this->nick.c_str());
|
||||
BotListByNick.erase(this->nick.c_str());
|
||||
|
||||
this->nick = newnick;
|
||||
|
||||
UserListByNick[this->nick.c_str()] = this;
|
||||
BotListByNick[this->nick.c_str()] = this;
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ void BotInfo::RejoinAll()
|
||||
ChannelInfo *ci = it->second;
|
||||
|
||||
if (ci->bi == this && ci->c && ci->c->users.size() >= Config.BSMinUsers)
|
||||
bot_join(ci);
|
||||
this->Join(ci->c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,9 +107,8 @@ void BotInfo::Assign(User *u, ChannelInfo *ci)
|
||||
ci->bi->UnAssign(u, ci);
|
||||
|
||||
ci->bi = this;
|
||||
++this->chancount;
|
||||
if (ci->c && ci->c->users.size() >= Config.BSMinUsers)
|
||||
bot_join(ci);
|
||||
this->Join(ci->c);
|
||||
}
|
||||
|
||||
void BotInfo::UnAssign(User *u, ChannelInfo *ci)
|
||||
@@ -118,14 +118,61 @@ void BotInfo::UnAssign(User *u, ChannelInfo *ci)
|
||||
if (MOD_RESULT == EVENT_STOP)
|
||||
return;
|
||||
|
||||
if (ci->c && ci->c->users.size() >= Config.BSMinUsers)
|
||||
if (ci->c && ci->c->FindUser(ci->bi))
|
||||
{
|
||||
if (u)
|
||||
ircdproto->SendPart(ci->bi, ci->c, "UNASSIGN from %s", u->nick.c_str());
|
||||
ci->bi->Part(ci->c, "UNASSIGN from " + u->nick);
|
||||
else
|
||||
ircdproto->SendPart(ci->bi, ci->c, "");
|
||||
ci->bi->Part(ci->c);
|
||||
}
|
||||
|
||||
--ci->bi->chancount;
|
||||
ci->bi = NULL;
|
||||
}
|
||||
|
||||
void BotInfo::Join(Channel *c)
|
||||
{
|
||||
if (Config.BSSmartJoin)
|
||||
{
|
||||
/* We check for bans */
|
||||
if (c->bans && c->bans->count)
|
||||
{
|
||||
Entry *ban, *next;
|
||||
|
||||
for (ban = c->bans->entries; ban; ban = next)
|
||||
{
|
||||
next = ban->next;
|
||||
|
||||
if (entry_match(ban, this->nick.c_str(), this->GetIdent().c_str(), this->host, 0))
|
||||
c->RemoveMode(NULL, CMODE_BAN, ban->mask);
|
||||
}
|
||||
|
||||
std::string Limit;
|
||||
int limit = 0;
|
||||
if (c->GetParam(CMODE_LIMIT, Limit))
|
||||
limit = atoi(Limit.c_str());
|
||||
|
||||
/* Should we be invited? */
|
||||
if (c->HasMode(CMODE_INVITE) || (limit && c->users.size() >= limit))
|
||||
ircdproto->SendNoticeChanops(this, c, "%s invited %s into the channel.", this->nick.c_str(), this->nick.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
ircdproto->SendJoin(this, c->name.c_str(), c->creation_time);
|
||||
for (std::list<ChannelModeStatus *>::iterator it = BotModes.begin(), it_end = BotModes.end(); it != it_end; ++it)
|
||||
c->SetMode(this, *it, this->nick, false);
|
||||
c->JoinUser(this);
|
||||
FOREACH_MOD(I_OnBotJoin, OnBotJoin(c->ci, this));
|
||||
}
|
||||
|
||||
void BotInfo::Join(const std::string &chname)
|
||||
{
|
||||
Channel *c = findchan(chname);
|
||||
return this->Join(c ? c : new Channel(chname));
|
||||
}
|
||||
|
||||
void BotInfo::Part(Channel *c, const std::string &reason)
|
||||
{
|
||||
ircdproto->SendPart(this, c, !reason.empty() ? reason.c_str() : "");
|
||||
c->DeleteUser(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user