mirror of
https://github.com/anope/anope.git
synced 2026-06-25 14:46:37 +02:00
c4d520b465
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1232 5417fbe8-f217-4b02-8779-1006273d7864
77 lines
1.4 KiB
C++
77 lines
1.4 KiB
C++
/*
|
|
* Copyright (C) 2008 Robin Burchell <w00t@inspircd.org>
|
|
* Copyright (C) 2008 Anope Team <info@anope.org>
|
|
*
|
|
* Please read COPYING and README for further details.
|
|
*
|
|
*
|
|
* $Id$
|
|
*
|
|
*/
|
|
|
|
#include "services.h"
|
|
|
|
BotInfo::BotInfo(const char *nnick)
|
|
{
|
|
this->nick = sstrdup(nnick);
|
|
this->lastmsg = time(NULL);
|
|
insert_bot(this); // XXX, this is ugly, but it needs to stay until hashing of bots is redone in STL.
|
|
nbots++;
|
|
}
|
|
|
|
void BotInfo::ChangeNick(const char *newnick)
|
|
{
|
|
if (this->next)
|
|
this->next->prev = this->prev;
|
|
if (this->prev)
|
|
this->prev->next = this->next;
|
|
else
|
|
botlists[tolower(*this->nick)] = this->next;
|
|
|
|
if (this->nick)
|
|
free(this->nick);
|
|
this->nick = sstrdup(newnick);
|
|
|
|
insert_bot(this);
|
|
}
|
|
|
|
void BotInfo::RejoinAll()
|
|
{
|
|
int i;
|
|
ChannelInfo *ci;
|
|
|
|
for (i = 0; i < 256; i++)
|
|
for (ci = chanlists[i]; ci; ci = ci->next)
|
|
if (ci->bi == this && ci->c && (ci->c->usercount >= BSMinUsers))
|
|
bot_join(ci);
|
|
}
|
|
|
|
void BotInfo::Assign(User *u, ChannelInfo *ci)
|
|
{
|
|
if (ci->bi)
|
|
{
|
|
if (u)
|
|
ci->bi->UnAssign(u, ci);
|
|
else
|
|
ci->bi->UnAssign(NULL, ci);
|
|
}
|
|
|
|
ci->bi = this;
|
|
this->chancount++;
|
|
if (ci->c && ci->c->usercount >= BSMinUsers)
|
|
bot_join(ci);
|
|
}
|
|
|
|
void BotInfo::UnAssign(User *u, ChannelInfo *ci)
|
|
{
|
|
send_event(EVENT_BOT_UNASSIGN, 2, ci->name, ci->bi->nick);
|
|
|
|
if (u && ci->c && ci->c->usercount >= BSMinUsers)
|
|
anope_cmd_part(ci->bi->nick, ci->name, "UNASSIGN from %s", u->nick);
|
|
|
|
ci->bi->chancount--;
|
|
ci->bi = NULL;
|
|
}
|
|
|
|
|