summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-06-27 02:41:48 -0400
committerAdam <Adam@anope.org>2010-06-27 02:41:48 -0400
commit57caa0b53f53927c72811ffffda8bb527975860f (patch)
tree7fef9b12d2d86758acb9198001f88f072e8a31d6
parentd49aee6cf88c79220eb785245257544c8051247f (diff)
Made Anope track its own clients internally as if they were real users
-rw-r--r--include/bots.h15
-rw-r--r--include/extern.h3
-rw-r--r--include/services.h5
-rw-r--r--include/users.h2
-rw-r--r--src/bots.cpp77
-rw-r--r--src/botserv.cpp46
-rw-r--r--src/channels.cpp61
-rw-r--r--src/chanserv.cpp10
-rw-r--r--src/core/bs_act.cpp2
-rw-r--r--src/core/bs_bot.cpp26
-rw-r--r--src/core/bs_botlist.cpp4
-rw-r--r--src/core/bs_info.cpp6
-rw-r--r--src/core/bs_say.cpp2
-rw-r--r--src/core/cs_set_persist.cpp8
-rw-r--r--src/core/cs_topic.cpp6
-rw-r--r--src/core/db_plain.cpp11
-rw-r--r--src/core/os_set.cpp10
-rw-r--r--src/init.cpp2
-rw-r--r--src/main.cpp12
-rw-r--r--src/messages.cpp2
-rw-r--r--src/modes.cpp4
-rw-r--r--src/modules/cs_appendtopic.cpp10
-rw-r--r--src/protocol.cpp24
-rw-r--r--src/protocol/bahamut.cpp4
-rw-r--r--src/protocol/inspircd11.cpp4
-rw-r--r--src/protocol/inspircd12.cpp40
-rw-r--r--src/protocol/inspircd20.cpp38
-rw-r--r--src/protocol/ratbox.cpp40
-rw-r--r--src/protocol/unreal32.cpp4
-rw-r--r--src/regchannel.cpp13
-rw-r--r--src/servers.cpp3
-rw-r--r--src/users.cpp2
32 files changed, 254 insertions, 242 deletions
diff --git a/include/bots.h b/include/bots.h
index 1b017b058..c1fd14450 100644
--- a/include/bots.h
+++ b/include/bots.h
@@ -29,19 +29,12 @@ enum BotFlag
BI_END
};
-class CoreExport BotInfo : public Extensible, public Flags<BotFlag, BI_END>
+class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>
{
public:
- std::string uid; /* required for UID supporting servers, as opposed to the shitty struct Uid. */
- std::string nick; /* Nickname of the bot */
- std::string user; /* Its user name */
- std::string host; /* Its hostname */
- std::string real; /* Its real name */
time_t created; /* Birth date ;) */
- int16 chancount; /* Number of channels that use the bot. */
- /* Dynamic data */
time_t lastmsg; /* Last time we said something */
- CommandMap Commands;
+ CommandMap Commands; /* Commands on this bot */
/** Create a new bot.
* @param nick The nickname to assign to the bot.
@@ -76,6 +69,10 @@ class CoreExport BotInfo : public Extensible, public Flags<BotFlag, BI_END>
* @param ci The channel registration to remove the bot from.
*/
void UnAssign(User *u, ChannelInfo *ci);
+
+ void Join(Channel *c);
+ void Join(const std::string &chname);
+ void Part(Channel *c, const std::string &reason = "");
};
#endif // BOTS_H
diff --git a/include/extern.h b/include/extern.h
index 9e6c94de7..ce73cad17 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -53,7 +53,6 @@ E BotInfo *findbot(const ci::string &nick);
* @param uid The UID to search for
* @return The pseudoclient structure, or NULL if one could not be found
*/
-E void bot_join(ChannelInfo *ci);
E char *normalizeBuffer(const char *);
E void bot_raw_ban(User * requester, ChannelInfo *ci, char *nick, const char *reason);
@@ -100,7 +99,7 @@ E Entry *elist_match_user(EList *list, User *u);
E Entry *elist_find_mask(EList *list, const char *mask);
E long get_memuse(EList *list);
-#define whosends(ci) ((!(ci) || !((ci)->botflags.HasFlag(BS_SYMBIOSIS)) || !(ci)->bi || !(ci)->c || (ci)->c->users.size() < Config.BSMinUsers) ? findbot(Config.s_ChanServ) : (ci)->bi)
+#define whosends(ci) (!(ci) || !((ci)->botflags.HasFlag(BS_SYMBIOSIS)) || !(ci)->bi || !(ci)->c || (ci)->c->FindUser((ci)->bi) ? findbot(Config.s_ChanServ) : (ci)->bi)
/**** chanserv.c ****/
diff --git a/include/services.h b/include/services.h
index 766137ba2..b234e438a 100644
--- a/include/services.h
+++ b/include/services.h
@@ -370,8 +370,8 @@ inline const std::string stringify(const T &x)
/*************************************************************************/
-/* forward declarations, mostly used by older code */
class User;
+class BotInfo;
class ChannelInfo;
class Channel;
class Server;
@@ -380,7 +380,6 @@ struct Session;
#include "extensible.h"
#include "threadengine.h"
-#include "bots.h"
#include "opertype.h"
#include "modes.h"
@@ -701,6 +700,8 @@ struct LevelInfo
/*************************************************************************/
#include "users.h"
+#include "bots.h"
+
/* This structure stocks ban data since it must not be removed when
* user is kicked.
*/
diff --git a/include/users.h b/include/users.h
index a6e75680b..870f4f230 100644
--- a/include/users.h
+++ b/include/users.h
@@ -76,7 +76,7 @@ class CoreExport User : public Extensible
/** Destroy a user.
*/
- ~User();
+ virtual ~User();
/** Update the nickname of a user record accordingly, should be
* called from ircd protocol.
diff --git a/src/bots.cpp b/src/bots.cpp
index 424120d2d..31cfe04b7 100644
--- a/src/bots.cpp
+++ b/src/bots.cpp
@@ -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);
+}
+
diff --git a/src/botserv.cpp b/src/botserv.cpp
index 624d1df83..85f559f24 100644
--- a/src/botserv.cpp
+++ b/src/botserv.cpp
@@ -45,9 +45,9 @@ void get_botserv_stats(long *nrec, long *memuse)
count++;
mem += sizeof(*bi);
mem += bi->nick.size() + 1;
- mem += bi->user.size() + 1;
- mem += bi->host.size() + 1;
- mem += bi->real.size() + 1;
+ mem += bi->GetIdent().size() + 1;
+ mem += strlen(bi->host) + 1;
+ mem += strlen(bi->realname) + 1;
}
*nrec = count;
@@ -528,46 +528,6 @@ static UserData *get_user_data(Channel *c, User *u)
/*************************************************************************/
-/* Makes the bot join a channel and op himself. */
-
-void bot_join(ChannelInfo * ci)
-{
- if (!ci || !ci->c || !ci->bi)
- return;
-
- if (Config.BSSmartJoin)
- {
- /* We check for bans */
- if (ci->c->bans && ci->c->bans->count)
- {
- Entry *ban, *next;
-
- for (ban = ci->c->bans->entries; ban; ban = next)
- {
- next = ban->next;
-
- if (entry_match(ban, ci->bi->nick.c_str(), ci->bi->user.c_str(), ci->bi->host.c_str(), 0))
- ci->c->RemoveMode(NULL, CMODE_BAN, ban->mask);
- }
- }
-
- std::string Limit;
- int limit = 0;
- if (ci->c->GetParam(CMODE_LIMIT, Limit))
- limit = atoi(Limit.c_str());
-
- /* Should we be invited? */
- if (ci->c->HasMode(CMODE_INVITE) || (limit && ci->c->users.size() >= limit))
- ircdproto->SendNoticeChanops(ci->bi, ci->c, "%s invited %s into the channel.", ci->bi->nick.c_str(), ci->bi->nick.c_str());
- }
- ircdproto->SendJoin(ci->bi, ci->c->name.c_str(), ci->c->creation_time);
- for (std::list<ChannelModeStatus *>::iterator it = BotModes.begin(), it_end = BotModes.end(); it != it_end; ++it)
- ci->c->SetMode(ci->bi, *it, ci->bi->nick, false);
- FOREACH_MOD(I_OnBotJoin, OnBotJoin(ci, ci->bi));
-}
-
-/*************************************************************************/
-
/** Check if a user should be banned by botserv
* @param ci The channel the user is on
* @param u The user
diff --git a/src/channels.cpp b/src/channels.cpp
index e6ba3700b..a90aa5a03 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -130,12 +130,12 @@ void Channel::JoinUser(User *user)
* But join persistant channels when syncing with our uplink- DP
**/
if (Config.s_BotServ && this->ci && this->ci->bi && (!Me->IsSynced() || !this->ci->HasFlag(CI_PERSIST)) && this->users.size() == Config.BSMinUsers)
- bot_join(this->ci);
+ this->ci->bi->Join(this);
/* Only display the greet if the main uplink we're connected
* to has synced, or we'll get greet-floods when the net
* recovers from a netsplit. -GD
*/
- if (Config.s_BotServ && this->ci && this->ci->bi && this->users.size() >= Config.BSMinUsers && this->ci->botflags.HasFlag(BS_GREET) && user->Account() && user->Account()->greet &&
+ if (Config.s_BotServ && this->ci && this->ci->bi && this->FindUser(this->ci->bi) && this->ci->botflags.HasFlag(BS_GREET) && user->Account() && user->Account()->greet &&
check_access(user, this->ci, CA_GREET) && user->server->IsSynced())
{
ircdproto->SendPrivmsg(this->ci->bi, this->name.c_str(), "[%s] %s", user->Account()->display, user->Account()->greet);
@@ -150,6 +150,8 @@ void Channel::DeleteUser(User *user)
{
if (this->ci)
update_cs_lastseen(user, this->ci);
+
+ Alog(LOG_DEBUG) << user->nick << " leaves " << this->name;
CUserList::iterator cit, cit_end = this->users.end();
for (cit = this->users.begin(); (*cit)->user != user && cit != cit_end; ++cit);
@@ -188,10 +190,9 @@ void Channel::DeleteUser(User *user)
if (this->ci && this->ci->HasFlag(CI_INHABIT))
return;
- if (Config.s_BotServ && this->ci && this->ci->bi && this->users.size() <= Config.BSMinUsers - 1)
- ircdproto->SendPart(this->ci->bi, this, NULL);
-
- if (this->users.empty())
+ if (Config.s_BotServ && this->ci && this->ci->bi && this->FindUser(this->ci->bi))
+ this->ci->bi->Part(this->ci->c);
+ else if (this->users.empty())
delete this;
}
@@ -273,11 +274,11 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string &param, bool En
return;
}
- /* We don't track bots */
- if (findbot(param))
- return;
+ BotInfo *bi = NULL;
+ if (Config.s_BotServ)
+ bi = findbot(param);
+ User *u = bi ? bi : finduser(param);
- User *u = finduser(param);
if (!u)
{
Alog(LOG_DEBUG) << "MODE " << this->name << " +" << cm->ModeChar << " for nonexistant user " << param;
@@ -399,17 +400,18 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string &param, bool
return;
}
+ BotInfo *bi = NULL;
+ if (Config.s_BotServ)
+ bi = findbot(param);
+ User *u = bi ? bi : finduser(param);
+
/* Reset modes on bots if we're supposed to */
- BotInfo *bi = findbot(param);
if (bi)
{
if (std::find(BotModes.begin(), BotModes.end(), cm) != BotModes.end())
this->SetMode(bi, cm, bi->nick);
- /* We don't track bots */
- return;
}
- User *u = finduser(param);
if (!u)
{
Alog() << "Channel::RemoveModeInternal() MODE " << this->name << "-" << cm->ModeChar << " for nonexistant user " << param;
@@ -455,8 +457,8 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string &param, bool
if (ci)
{
ci->UnsetFlag(CI_PERSIST);
- if (Config.s_BotServ && ci->bi && users.size() == Config.BSMinUsers - 1)
- ircdproto->SendPart(ci->bi, this, NULL);
+ if (Config.s_BotServ && ci->bi && this->FindUser(ci->bi))
+ this->ci->bi->Part(this);
}
}
@@ -859,17 +861,10 @@ void ChanSetInternalModes(Channel *c, int ac, const char **av)
*/
void Channel::KickInternal(const std::string &source, const std::string &nick, const std::string &reason)
{
- /* If it is the bot that is being kicked, we make it rejoin the
- * channel and stop immediately.
- * --lara
- */
- if (Config.s_BotServ && this->ci && findbot(nick))
- {
- bot_join(this->ci);
- return;
- }
-
- User *user = finduser(nick);
+ BotInfo *bi = NULL;
+ if (Config.s_BotServ && this->ci)
+ bi = findbot(nick);
+ User *user = bi ? bi : finduser(nick);
if (!user)
{
Alog(LOG_DEBUG) << "Channel::KickInternal got a nonexistent user " << nick << " on " << this->name << ": " << reason;
@@ -878,6 +873,8 @@ void Channel::KickInternal(const std::string &source, const std::string &nick, c
Alog(LOG_DEBUG) << "Channel::KickInternal kicking " << user->nick << " from " << this->name;
+ std::string chname = this->name;
+
if (user->FindChannel(this))
{
FOREACH_MOD(I_OnUserKicked, OnUserKicked(this, user, source, reason));
@@ -885,6 +882,10 @@ void Channel::KickInternal(const std::string &source, const std::string &nick, c
}
else
Alog(LOG_DEBUG) << "Channel::KickInternal got kick for user " << user->nick << " who isn't on channel " << this->name << " ?";
+
+ /* Bots get rejoined */
+ if (bi)
+ bi->Join(chname);
}
/** Kick a user from the channel
@@ -1125,8 +1126,8 @@ void do_join(const char *source, int ac, const char **av)
/* Cycle the bot to fix ts */
if (chan->ci->bi)
{
- ircdproto->SendPart(chan->ci->bi, chan, "TS reop");
- bot_join(chan->ci);
+ chan->ci->bi->Part(chan, "TS reop");
+ chan->ci->bi->Join(chan);
}
/* Be sure to set mlock again, else we could be -r etc.. */
check_modes(chan);
@@ -1398,7 +1399,7 @@ void chan_set_correct_modes(User *user, Channel *c, int give_modes)
c->SetMode(NULL, CMODE_VOICE, user->nick);
}
/* If this channel has secureops or the user matches autodeop or the channel is syncing and this is the first user and they are not ulined, check to remove modes */
- if ((ci->HasFlag(CI_SECUREOPS) || check_access(user, ci, CA_AUTODEOP) || (c->HasFlag(CH_SYNCING) && c->users.size() == 1)) && !user->server->IsULined())
+ if ((ci->HasFlag(CI_SECUREOPS) || check_access(user, ci, CA_AUTODEOP) || (c->HasFlag(CH_SYNCING) && c->users.size() == (ci->bi ? 2 : 1))) && !user->server->IsULined())
{
if (owner && c->HasUserStatus(user, CMODE_OWNER) && !check_access(user, ci, CA_FOUNDER))
c->RemoveMode(NULL, CMODE_OWNER, user->nick);
diff --git a/src/chanserv.cpp b/src/chanserv.cpp
index ff698d68f..3ca9694b3 100644
--- a/src/chanserv.cpp
+++ b/src/chanserv.cpp
@@ -522,12 +522,12 @@ void restore_topic(const char *chan)
}
if (ircd->join2set && whosends(ci) == ChanServ)
{
- ircdproto->SendJoin(ChanServ, chan, c->creation_time);
+ ChanServ->Join(chan);
c->SetMode(NULL, CMODE_OP, Config.s_ChanServ);
}
ircdproto->SendTopic(whosends(ci), c, c->topic_setter.c_str(), c->topic ? c->topic : "");
if (ircd->join2set && whosends(ci) == ChanServ)
- ircdproto->SendPart(ChanServ, c, NULL);
+ ChanServ->Part(c);
}
/*************************************************************************/
@@ -583,14 +583,14 @@ int check_topiclock(Channel *c, time_t topic_time)
if (ircd->join2set && whosends(ci) == ChanServ)
{
- ircdproto->SendJoin(ChanServ, c->name.c_str(), c->creation_time);
+ ChanServ->Join(c);
c->SetMode(NULL, CMODE_OP, Config.s_ChanServ);
}
ircdproto->SendTopic(whosends(ci), c, c->topic_setter.c_str(), c->topic ? c->topic : "");
if (ircd->join2set && whosends(ci) == ChanServ)
- ircdproto->SendPart(ChanServ, c, NULL);
+ ChanServ->Part(c);
return 1;
}
@@ -1048,7 +1048,7 @@ void ChanServTimer::Tick(time_t)
if (!c->users.empty())
return;
- ircdproto->SendPart(ChanServ, c, NULL);
+ ChanServ->Part(c);
/* Now delete the channel as it is empty */
if (!c->HasFlag(CH_PERSIST) && !c->ci->HasFlag(CI_PERSIST))
diff --git a/src/core/bs_act.cpp b/src/core/bs_act.cpp
index 2b89a67c0..aa054d11b 100644
--- a/src/core/bs_act.cpp
+++ b/src/core/bs_act.cpp
@@ -37,7 +37,7 @@ class CommandBSAct : public Command
return MOD_CONT;
}
- if (!ci->c || ci->c->users.size() < Config.BSMinUsers)
+ if (!ci->c || !ci->c->FindUser(ci->bi))
{
notice_lang(Config.s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name.c_str());
return MOD_CONT;
diff --git a/src/core/bs_bot.cpp b/src/core/bs_bot.cpp
index 657ac76cd..5217ecbc8 100644
--- a/src/core/bs_bot.cpp
+++ b/src/core/bs_bot.cpp
@@ -100,10 +100,7 @@ class CommandBSBot : public Command
return MOD_CONT;
}
- /* We check whether user with this nick is online, and kill it if so */
- EnforceQlinedNick(nick, Config.s_BotServ);
-
- notice_lang(Config.s_BotServ, u, BOT_BOT_ADDED, bi->nick.c_str(), bi->user.c_str(), bi->host.c_str(), bi->real.c_str());
+ notice_lang(Config.s_BotServ, u, BOT_BOT_ADDED, bi->nick.c_str(), bi->GetIdent().c_str(), bi->host, bi->realname);
FOREACH_MOD(I_OnBotCreate, OnBotCreate(bi));
return MOD_CONT;
@@ -166,7 +163,7 @@ class CommandBSBot : public Command
* And we must finally check that the nick is not already
* taken by another bot.
*/
- if (bi->nick == nick && (user ? bi->user == user : 1) && (host ? bi->host == host : 1) && (real ? bi->real == real : 1))
+ if (bi->nick == nick && (user ? bi->GetIdent() == user : 1) && (host ? !strcmp(bi->host, host) : 1) && (real ? !strcmp(bi->realname, real) : 1))
{
notice_lang(Config.s_BotServ, u, BOT_BOT_ANY_CHANGES);
return MOD_CONT;
@@ -250,25 +247,22 @@ class CommandBSBot : public Command
if (bi->nick != nick)
bi->ChangeNick(nick);
- if (user && bi->user != user)
- bi->user = user;
- if (host && bi->host != host)
- bi->host = host;
- if (real && bi->real != real)
- bi->real = real;
+ if (user && bi->GetIdent() != user)
+ bi->SetIdent(user);
+ if (host && strcmp(bi->host, host))
+ bi->host = sstrdup(host);
+ if (real && strcmp(bi->realname, real))
+ bi->realname = sstrdup(real);
if (user)
{
- if (ircd->ts6)
- // This isn't the nicest way to do this, unfortunately.
- bi->uid = ts6_uid_retrieve();
- ircdproto->SendClientIntroduction(bi->nick, bi->user, bi->host, bi->real, ircd->pseudoclient_mode, bi->uid);
+ ircdproto->SendClientIntroduction(bi->nick, bi->GetIdent(), bi->host, bi->realname, ircd->pseudoclient_mode, bi->GetUID());
XLine x(bi->nick.c_str(), "Reserved for services");
ircdproto->SendSQLine(&x);
bi->RejoinAll();
}
- notice_lang(Config.s_BotServ, u, BOT_BOT_CHANGED, oldnick, bi->nick.c_str(), bi->user.c_str(), bi->host.c_str(), bi->real.c_str());
+ notice_lang(Config.s_BotServ, u, BOT_BOT_CHANGED, oldnick, bi->nick.c_str(), bi->GetIdent().c_str(), bi->host, bi->realname);
FOREACH_MOD(I_OnBotChange, OnBotChange(bi));
return MOD_CONT;
diff --git a/src/core/bs_botlist.cpp b/src/core/bs_botlist.cpp
index fc24f8437..44848b5cb 100644
--- a/src/core/bs_botlist.cpp
+++ b/src/core/bs_botlist.cpp
@@ -39,7 +39,7 @@ class CommandBSBotList : public Command
if (!count)
notice_lang(Config.s_BotServ, u, BOT_BOTLIST_HEADER);
++count;
- u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str());
+ u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->GetIdent().c_str(), bi->host);
}
}
@@ -53,7 +53,7 @@ class CommandBSBotList : public Command
if (bi->HasFlag(BI_PRIVATE))
{
- u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str());
+ u->SendMessage(Config.s_BotServ, " %-15s (%s@%s)", bi->nick.c_str(), bi->GetIdent().c_str(), bi->host);
++count;
}
}
diff --git a/src/core/bs_info.cpp b/src/core/bs_info.cpp
index 3df82a3a8..7d8e6aea7 100644
--- a/src/core/bs_info.cpp
+++ b/src/core/bs_info.cpp
@@ -65,13 +65,13 @@ class CommandBSInfo : public Command
struct tm *tm;
notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_HEADER, bi->nick.c_str());
- notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_MASK, bi->user.c_str(), bi->host.c_str());
- notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_REALNAME, bi->real.c_str());
+ notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_MASK, bi->GetIdent().c_str(), bi->host);
+ notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_REALNAME, bi->realname);
tm = localtime(&bi->created);
strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_CREATED, buf);
notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_OPTIONS, getstring(u, (bi->HasFlag(BI_PRIVATE) ? BOT_INFO_OPT_PRIVATE : BOT_INFO_OPT_NONE)));
- notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_USAGE, bi->chancount);
+ notice_lang(Config.s_BotServ, u, BOT_INFO_BOT_USAGE, bi->chans.size());
if (u->Account()->HasPriv("botserv/administration"))
this->send_bot_channels(u, bi);
diff --git a/src/core/bs_say.cpp b/src/core/bs_say.cpp
index 71eb06fe2..88b298544 100644
--- a/src/core/bs_say.cpp
+++ b/src/core/bs_say.cpp
@@ -41,7 +41,7 @@ class CommandBSSay : public Command
return MOD_CONT;
}
- if (!ci->c || ci->c->users.size() < Config.BSMinUsers)
+ if (!ci->c || !ci->c->FindUser(ci->bi))
{
notice_lang(Config.s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name.c_str());
return MOD_CONT;
diff --git a/src/core/cs_set_persist.cpp b/src/core/cs_set_persist.cpp
index c32603104..d03e3874d 100644
--- a/src/core/cs_set_persist.cpp
+++ b/src/core/cs_set_persist.cpp
@@ -36,9 +36,9 @@ class CommandCSSetPersist : public Command
/* Channel doesn't exist, create it internally */
if (!ci->c)
{
- new Channel(ci->name);
+ Channel *c = new Channel(ci->name);
if (ci->bi)
- bot_join(ci);
+ ci->bi->Join(c);
}
/* No botserv bot, no channel mode */
@@ -64,8 +64,8 @@ class CommandCSSetPersist : public Command
/* Unset perm mode */
if (cm && ci->c && ci->c->HasMode(CMODE_PERM))
ci->c->RemoveMode(NULL, cm);
- if (Config.s_BotServ && ci->bi && ci->c->users.size() == Config.BSMinUsers - 1)
- ircdproto->SendPart(ci->bi, ci->c, NULL);
+ if (Config.s_BotServ && ci->bi && ci->c->FindUser(ci->bi))
+ ci->bi->Part(ci->c);
/* No channel mode, no BotServ, but using ChanServ as the botserv bot
* which was assigned when persist was set on
diff --git a/src/core/cs_topic.cpp b/src/core/cs_topic.cpp
index f267ee436..f408eaedf 100644
--- a/src/core/cs_topic.cpp
+++ b/src/core/cs_topic.cpp
@@ -56,12 +56,12 @@ class CommandCSTopic : public Command
Alog() << Config.s_NickServ << ": " << u->GetMask() << " changed topic of " << c->name << " as services admin.";
if (ircd->join2set && whosends(ci) == ChanServ)
{
- ircdproto->SendJoin(ChanServ, c->name.c_str(), c->creation_time);
- ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ);
+ ChanServ->Join(c);
+ ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ); // XXX
}
ircdproto->SendTopic(whosends(ci), c, u->nick.c_str(), topic ? topic : "");
if (ircd->join2set && whosends(ci) == ChanServ)
- ircdproto->SendPart(ChanServ, c, NULL);
+ ChanServ->Part(c);
}
return MOD_CONT;
}
diff --git a/src/core/db_plain.cpp b/src/core/db_plain.cpp
index cf41ea104..7aa2ada89 100644
--- a/src/core/db_plain.cpp
+++ b/src/core/db_plain.cpp
@@ -409,11 +409,12 @@ static void LoadBotInfo(const std::vector<std::string> &params)
BotInfo *bi = findbot(params[0]);
if (!bi)
bi = new BotInfo(params[0]);
- bi->user = params[1];
- bi->host = params[2];
+ bi->SetIdent(params[1]);
+ bi->host = sstrdup(params[2].c_str());
bi->created = atol(params[3].c_str());
- bi->chancount = atol(params[4].c_str());
- bi->real = params[5];
+ //bi no longer has a chancount, use bi->chans.size()
+ //bi->chancount = atol(params[4].c_str());
+ bi->realname = sstrdup(params[5].c_str());
Alog(LOG_DEBUG_2) << "[db_plain]: Loaded botinfo for " << bi->nick;
}
@@ -984,7 +985,7 @@ class DBPlain : public Module
{
BotInfo *bi = it->second;
- db << "BI " << bi->nick << " " << bi->user << " " << bi->host << " " << bi->created << " " << bi->chancount << " :" << bi->real << endl;
+ db << "BI " << bi->nick << " " << bi->GetIdent() << " " << bi->host << " " << bi->created << " " << bi->chans.size() << " :" << bi->realname << endl;
if (bi->FlagCount())
{
db << "MD FLAGS";
diff --git a/src/core/os_set.cpp b/src/core/os_set.cpp
index 9a84d1e05..229722e5a 100644
--- a/src/core/os_set.cpp
+++ b/src/core/os_set.cpp
@@ -113,7 +113,10 @@ class CommandOSSet : public Command
if (ircd->join2msg)
{
c = findchan(Config.LogChannel);
- ircdproto->SendJoin(Global, Config.LogChannel, c ? c->creation_time : time(NULL));
+ if (c)
+ Global->Join(c);
+ else
+ Global->Join(Config.LogChannel);
}
LogChan = true;
Alog() << "Now sending log messages to " << Config.LogChannel;
@@ -122,8 +125,9 @@ class CommandOSSet : public Command
else if (Config.LogChannel && setting == "OFF")
{
Alog() << "No longer sending log messages to a channel";
- if (ircd->join2msg)
- ircdproto->SendPart(Global, findchan(Config.LogChannel), NULL);
+ c = findchan(Config.LogChannel);
+ if (ircd->join2msg && c)
+ Global->Part(c);
LogChan = false;
notice_lang(Config.s_OperServ, u, OPER_SET_LOGCHAN_OFF);
}
diff --git a/src/init.cpp b/src/init.cpp
index 88a9e441b..07597c829 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -39,7 +39,7 @@ void introduce_user(const std::string &user)
ci::string ci_bi_nick(bi->nick.c_str());
if (user.empty() || ci_bi_nick == user)
{
- ircdproto->SendClientIntroduction(bi->nick, bi->user, bi->host, bi->real, ircd->pseudoclient_mode, bi->uid);
+ ircdproto->SendClientIntroduction(bi->nick, bi->GetIdent(), bi->host, bi->realname, ircd->pseudoclient_mode, bi->GetUID());
XLine x(bi->nick.c_str(), "Reserved for services");
ircdproto->SendSQLine(&x);
}
diff --git a/src/main.cpp b/src/main.cpp
index 06f10ab3e..c00b3a8f0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -179,8 +179,14 @@ void do_restart_services()
quitmsg = "Restarting";
/* Send a quit for all of our bots */
for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
+ {
/* Don't use quitmsg here, it may contain information you don't want people to see */
ircdproto->SendQuit(it->second, "Restarting");
+ /* Erase bots from the user list so they don't get nuked later on */
+ UserListByNick.erase(it->second->nick.c_str());
+ if (!it->second->GetUID().empty())
+ UserListByUID.erase(it->second->GetUID().c_str());
+ }
ircdproto->SendSquit(Config.ServerName, quitmsg);
/* Process to send the last bits of information before disconnecting */
socketEngine.Process();
@@ -218,8 +224,14 @@ static void services_shutdown()
{
/* Send a quit for all of our bots */
for (botinfo_map::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
+ {
/* Don't use quitmsg here, it may contain information you don't want people to see */
ircdproto->SendQuit(it->second, "Shutting down");
+ /* Erase bots from the user list so they don't get nuked later on */
+ UserListByNick.erase(it->second->nick.c_str());
+ if (!it->second->GetUID().empty())
+ UserListByUID.erase(it->second->GetUID());
+ }
ircdproto->SendSquit(Config.ServerName, quitmsg);
diff --git a/src/messages.cpp b/src/messages.cpp
index 804adac7d..857229f65 100644
--- a/src/messages.cpp
+++ b/src/messages.cpp
@@ -290,7 +290,7 @@ int m_whois(const char *source, const char *who)
BotInfo *bi = findbot(who);
if (bi)
{
- ircdproto->SendNumeric(Config.ServerName, 311, source, "%s %s %s * :%s", bi->nick.c_str(), bi->user.c_str(), bi->host.c_str(), bi->real.c_str());
+ ircdproto->SendNumeric(Config.ServerName, 311, source, "%s %s %s * :%s", bi->nick.c_str(), bi->GetIdent().c_str(), bi->host, bi->realname);
ircdproto->SendNumeric(Config.ServerName, 307, source, "%s :is a registered nick", bi->nick.c_str());
ircdproto->SendNumeric(Config.ServerName, 312, source, "%s %s :%s", bi->nick.c_str(), Config.ServerName, Config.ServerDesc);
ircdproto->SendNumeric(Config.ServerName, 317, source, "%s %ld %ld :seconds idle, signon time", bi->nick.c_str(), time(NULL) - bi->lastmsg, start_time);
diff --git a/src/modes.cpp b/src/modes.cpp
index 65e6f0613..38ac2ad00 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -268,11 +268,11 @@ void ChannelModeBan::AddMask(Channel *chan, const char *mask)
/* Check whether it matches a botserv bot after adding internally
* and parsing it through cidr support. ~ Viper */
- if (Config.s_BotServ && Config.BSSmartJoin && chan->ci && chan->ci->bi && chan->users.size() >= Config.BSMinUsers)
+ if (Config.s_BotServ && Config.BSSmartJoin && chan->ci && chan->ci->bi && chan->FindUser(chan->ci->bi))
{
BotInfo *bi = chan->ci->bi;
- if (entry_match(ban, bi->nick.c_str(), bi->user.c_str(), bi->host.c_str(), 0))
+ if (entry_match(ban, bi->nick.c_str(), bi->GetIdent().c_str(), bi->host, 0))
{
ircdproto->SendMode(bi, chan, "-b %s", mask);
entry_delete(chan->bans, ban);
diff --git a/src/modules/cs_appendtopic.cpp b/src/modules/cs_appendtopic.cpp
index 40c1cd374..a1c84d0ab 100644
--- a/src/modules/cs_appendtopic.cpp
+++ b/src/modules/cs_appendtopic.cpp
@@ -98,17 +98,17 @@ class CommandCSAppendTopic : public Command
Alog() << Config.s_ChanServ << ": " << u->GetMask() << " changed topic of " << c->name << " as services admin.";
if (ircd->join2set)
{
- if (whosends(ci) == findbot(Config.s_ChanServ))
+ if (whosends(ci) == ChanServ)
{
- ircdproto->SendJoin(findbot(Config.s_ChanServ), c->name.c_str(), c->creation_time);
- ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ);
+ ChanServ->Join(c);
+ ircdproto->SendMode(NULL, c, "+o %s", Config.s_ChanServ); // XXX
}
}
ircdproto->SendTopic(whosends(ci), c, u->nick.c_str(), topic);
if (ircd->join2set)
{
- if (whosends(ci) == findbot(Config.s_ChanServ))
- ircdproto->SendPart(findbot(Config.s_ChanServ), c, NULL);
+ if (whosends(ci) == ChanServ)
+ ChanServ->Part(c);
}
}
return MOD_CONT;
diff --git a/src/protocol.cpp b/src/protocol.cpp
index 761df1ca1..13ff84a24 100644
--- a/src/protocol.cpp
+++ b/src/protocol.cpp
@@ -10,34 +10,34 @@ void IRCDProto::SendMessageInternal(BotInfo *bi, const char *dest, const char *b
void IRCDProto::SendNoticeInternal(BotInfo *bi, const char *dest, const char *msg)
{
- send_cmd(ircd->ts6 ? bi->uid : bi->nick, "NOTICE %s :%s", dest, msg);
+ send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "NOTICE %s :%s", dest, msg);
}
void IRCDProto::SendPrivmsgInternal(BotInfo *bi, const char *dest, const char *buf)
{
- send_cmd(ircd->ts6 ? bi->uid : bi->nick, "PRIVMSG %s :%s", dest, buf);
+ send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "PRIVMSG %s :%s", dest, buf);
}
void IRCDProto::SendQuitInternal(BotInfo *bi, const char *buf)
{
if (buf)
- send_cmd(ircd->ts6 ? bi->uid : bi->nick, "QUIT :%s", buf);
+ send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "QUIT :%s", buf);
else
- send_cmd(ircd->ts6 ? bi->uid : bi->nick, "QUIT");
+ send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "QUIT");
}
void IRCDProto::SendPartInternal(BotInfo *bi, Channel *chan, const char *buf)
{
if (buf)
- send_cmd(ircd->ts6 ? bi->uid : bi->nick, "PART %s :%s", chan->name.c_str(), buf);
+ send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "PART %s :%s", chan->name.c_str(), buf);
else
- send_cmd(ircd->ts6 ? bi->uid : bi->nick, "PART %s", chan->name.c_str());
+ send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "PART %s", chan->name.c_str());
}
void IRCDProto::SendGlobopsInternal(BotInfo *source, const char *buf)
{
if (source)
- send_cmd(ircd->ts6 ? source->uid : source->nick, "GLOBOPS :%s", buf);
+ send_cmd(ircd->ts6 ? source->GetUID() : source->nick, "GLOBOPS :%s", buf);
else
send_cmd(Config.ServerName, "GLOBOPS :%s", buf);
}
@@ -45,7 +45,7 @@ void IRCDProto::SendGlobopsInternal(BotInfo *source, const char *buf)
void IRCDProto::SendCTCPInternal(BotInfo *bi, const char *dest, const char *buf)
{
char *s = normalizeBuffer(buf);
- send_cmd(ircd->ts6 ? bi->uid : bi->nick, "NOTICE %s :\1%s\1", dest, s);
+ send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "NOTICE %s :\1%s\1", dest, s);
delete [] s;
}
@@ -153,12 +153,12 @@ void IRCDProto::SendPrivmsg(BotInfo *bi, const char *dest, const char *fmt, ...)
void IRCDProto::SendGlobalNotice(BotInfo *bi, Server *dest, const char *msg)
{
- send_cmd(ircd->ts6 ? bi->uid : bi->nick, "NOTICE %s%s :%s", ircd->globaltldprefix, dest->GetName().c_str(), msg);
+ send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "NOTICE %s%s :%s", ircd->globaltldprefix, dest->GetName().c_str(), msg);
}
void IRCDProto::SendGlobalPrivmsg(BotInfo *bi, Server *dest, const char *msg)
{
- send_cmd(ircd->ts6 ? bi->uid : bi->nick, "PRIVMSG %s%s :%s", ircd->globaltldprefix, dest->GetName().c_str(), msg);
+ send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "PRIVMSG %s%s :%s", ircd->globaltldprefix, dest->GetName().c_str(), msg);
}
void IRCDProto::SendQuit(const char *nick, const char *)
@@ -200,7 +200,7 @@ void IRCDProto::SendPong(const char *servname, const char *who)
void IRCDProto::SendInvite(BotInfo *bi, const char *chan, const char *nick)
{
- send_cmd(ircd->ts6 ? bi->uid : bi->nick, "INVITE %s %s", nick, chan);
+ send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "INVITE %s %s", nick, chan);
}
void IRCDProto::SendPart(BotInfo *bi, Channel *chan, const char *fmt, ...)
@@ -234,7 +234,7 @@ void IRCDProto::SendSquit(const char *servname, const char *message)
void IRCDProto::SendChangeBotNick(BotInfo *bi, const char *newnick)
{
- send_cmd(ircd->ts6 ? bi->uid : bi->nick, "NICK %s %ld", newnick, static_cast<long>(time(NULL)));
+ send_cmd(ircd->ts6 ? bi->GetUID() : bi->nick, "NICK %s %ld", newnick, static_cast<long>(time(NULL)));
}
void IRCDProto::SendForceNickChange(User *u, const char *newnick, time_t when)
{
diff --git a/src/protocol/bahamut.cpp b/src/protocol/bahamut.cpp
index d9f575846..dc2790ac5 100644
--- a/src/protocol/bahamut.cpp
+++ b/src/protocol/bahamut.cpp
@@ -337,8 +337,8 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
/* Rejoin the bot to fix the TS */
if (c->ci->bi)
{
- ircdproto->SendPart(c->ci->bi, c, "TS reop");
- bot_join(c->ci);
+ c->ci->bi->Part(c, "TS reop");
+ c->ci->bi->Join(c);
}
/* Reset mlock */
check_modes(c);
diff --git a/src/protocol/inspircd11.cpp b/src/protocol/inspircd11.cpp
index a06e0f22c..0512b02ff 100644
--- a/src/protocol/inspircd11.cpp
+++ b/src/protocol/inspircd11.cpp
@@ -451,8 +451,8 @@ int anope_event_fjoin(const char *source, int ac, const char **av)
/* Rejoin the bot to fix the TS */
if (c->ci->bi)
{
- ircdproto->SendPart(c->ci->bi, c, "TS reop");
- bot_join(c->ci);
+ c->ci->bi->Part(c, "TS reop");
+ c->ci->bi->Join(c);
}
/* Reset mlock */
check_modes(c);
diff --git a/src/protocol/inspircd12.cpp b/src/protocol/inspircd12.cpp
index 9b742e64e..1746bdc57 100644
--- a/src/protocol/inspircd12.cpp
+++ b/src/protocol/inspircd12.cpp
@@ -99,7 +99,7 @@ void inspircd_cmd_chghost(const char *nick, const char *vhost)
}
BotInfo *bi = OperServ;
- send_cmd(bi->uid, "CHGHOST %s %s", nick, vhost);
+ send_cmd(bi->GetUID(), "CHGHOST %s %s", nick, vhost);
}
int anope_event_idle(const char *source, int ac, const char **av)
@@ -108,7 +108,7 @@ int anope_event_idle(const char *source, int ac, const char **av)
if (!bi)
return MOD_CONT;
- send_cmd(bi->uid, "IDLE %s %ld %ld", source, static_cast<long>(start_time), static_cast<long>(time(NULL) - bi->lastmsg));
+ send_cmd(bi->GetUID(), "IDLE %s %ld %ld", source, static_cast<long>(start_time), static_cast<long>(time(NULL) - bi->lastmsg));
return MOD_CONT;
}
@@ -126,12 +126,12 @@ class InspIRCdProto : public IRCDProto
void SendAkillDel(XLine *x)
{
BotInfo *bi = OperServ;
- send_cmd(bi->uid, "GLINE %s", x->Mask.c_str());
+ send_cmd(bi->GetUID(), "GLINE %s", x->Mask.c_str());
}
void SendTopic(BotInfo *whosets, Channel *c, const char *whosetit, const char *topic)
{
- send_cmd(whosets->uid, "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time), whosetit, topic);
+ send_cmd(whosets->GetUID(), "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time), whosetit, topic);
}
void SendVhostDel(User *u)
@@ -154,12 +154,12 @@ class InspIRCdProto : public IRCDProto
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
BotInfo *bi = OperServ;
- send_cmd(bi->uid, "ADDLINE G %s@%s %s %ld %ld :%s", x->GetUser().c_str(), x->GetHost().c_str(), x->By.c_str(), static_cast<long>(time(NULL)), static_cast<long>(timeleft), x->Reason.c_str());
+ send_cmd(bi->GetUID(), "ADDLINE G %s@%s %s %ld %ld :%s", x->GetUser().c_str(), x->GetHost().c_str(), x->By.c_str(), static_cast<long>(time(NULL)), static_cast<long>(timeleft), x->Reason.c_str());
}
void SendSVSKillInternal(BotInfo *source, User *user, const char *buf)
{
- send_cmd(source ? source->uid : TS6SID, "KILL %s :%s", user->GetUID().c_str(), buf);
+ send_cmd(source ? source->GetUID() : TS6SID, "KILL %s :%s", user->GetUID().c_str(), buf);
}
void SendSVSMode(User *u, int ac, const char **av)
@@ -179,13 +179,13 @@ class InspIRCdProto : public IRCDProto
void SendModeInternal(BotInfo *source, Channel *dest, const char *buf)
{
- send_cmd(source ? source->uid : TS6SID, "FMODE %s %u %s", dest->name.c_str(), static_cast<unsigned>(dest->creation_time), buf);
+ send_cmd(source ? source->GetUID() : TS6SID, "FMODE %s %u %s", dest->name.c_str(), static_cast<unsigned>(dest->creation_time), buf);
}
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
- send_cmd(bi ? bi->uid : TS6SID, "MODE %s %s", u->GetUID().c_str(), buf);
+ send_cmd(bi ? bi->GetUID() : TS6SID, "MODE %s %s", u->GetUID().c_str(), buf);
}
void SendClientIntroduction(const std::string &nick, const std::string &user, const std::string &host, const std::string &real, const char *modes, const std::string &uid)
@@ -196,9 +196,9 @@ class InspIRCdProto : public IRCDProto
void SendKickInternal(BotInfo *source, Channel *chan, User *user, const char *buf)
{
if (buf)
- send_cmd(source->uid, "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), buf);
+ send_cmd(source->GetUID(), "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), buf);
else
- send_cmd(source->uid, "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), user->nick.c_str());
+ send_cmd(source->GetUID(), "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), user->nick.c_str());
}
void SendNoticeChanopsInternal(BotInfo *source, Channel *dest, const char *buf)
@@ -215,7 +215,7 @@ class InspIRCdProto : public IRCDProto
/* JOIN */
void SendJoin(BotInfo *user, const char *channel, time_t chantime)
{
- send_cmd(TS6SID, "FJOIN %s %ld + :,%s", channel, static_cast<long>(chantime), user->uid.c_str());
+ send_cmd(TS6SID, "FJOIN %s %ld + :,%s", channel, static_cast<long>(chantime), user->GetUID().c_str());
}
/* UNSQLINE */
@@ -265,7 +265,7 @@ class InspIRCdProto : public IRCDProto
else
{
BotInfo *bi = OperServ;
- send_cmd(bi->uid, "CHGIDENT %s %s", nick, vIdent);
+ send_cmd(bi->GetUID(), "CHGIDENT %s %s", nick, vIdent);
}
}
@@ -273,14 +273,14 @@ class InspIRCdProto : public IRCDProto
void SendSVSHold(const char *nick)
{
BotInfo *bi = OperServ;
- send_cmd(bi->uid, "SVSHOLD %s %u :%s", nick, static_cast<unsigned>(Config.NSReleaseTimeout), "Being held for registered user");
+ send_cmd(bi->GetUID(), "SVSHOLD %s %u :%s", nick, static_cast<unsigned>(Config.NSReleaseTimeout), "Being held for registered user");
}
/* SVSHOLD - release */
void SendSVSHoldDel(const char *nick)
{
BotInfo *bi = OperServ;
- send_cmd(bi->uid, "SVSHOLD %s", nick);
+ send_cmd(bi->GetUID(), "SVSHOLD %s", nick);
}
/* UNSZLINE */
@@ -305,14 +305,14 @@ class InspIRCdProto : public IRCDProto
{
User *u = finduser(nick);
BotInfo *bi = findbot(source);
- send_cmd(bi->uid, "SVSJOIN %s %s", u->GetUID().c_str(), chan);
+ send_cmd(bi->GetUID(), "SVSJOIN %s %s", u->GetUID().c_str(), chan);
}
void SendSVSPart(const char *source, const char *nick, const char *chan)
{
User *u = finduser(nick);
BotInfo *bi = findbot(source);
- send_cmd(bi->uid, "SVSPART %s %s", u->GetUID().c_str(), chan);
+ send_cmd(bi->GetUID(), "SVSPART %s %s", u->GetUID().c_str(), chan);
}
void SendSWhois(const char *source, const char *who, const char *mask)
@@ -330,9 +330,9 @@ class InspIRCdProto : public IRCDProto
void SendGlobopsInternal(BotInfo *source, const char *buf)
{
if (has_globopsmod)
- send_cmd(source ? source->uid : TS6SID, "SNONOTICE g :%s", buf);
+ send_cmd(source ? source->GetUID() : TS6SID, "SNONOTICE g :%s", buf);
else
- send_cmd(source ? source->uid : TS6SID, "SNONOTICE A :%s", buf);
+ send_cmd(source ? source->GetUID() : TS6SID, "SNONOTICE A :%s", buf);
}
void SendAccountLogin(User *u, NickCore *account)
@@ -505,8 +505,8 @@ int anope_event_fjoin(const char *source, int ac, const char **av)
/* Rejoin the bot to fix the TS */
if (c->ci->bi)
{
- ircdproto->SendPart(c->ci->bi, c, "TS reop");
- bot_join(c->ci);
+ c->ci->bi->Part(c, "TS reop");
+ c->ci->bi->Join(c);
}
/* Reset mlock */
check_modes(c);
diff --git a/src/protocol/inspircd20.cpp b/src/protocol/inspircd20.cpp
index 885607a5f..262eab645 100644
--- a/src/protocol/inspircd20.cpp
+++ b/src/protocol/inspircd20.cpp
@@ -93,7 +93,7 @@ void inspircd_cmd_chghost(const char *nick, const char *vhost)
}
BotInfo *bi = OperServ;
- send_cmd(bi->uid, "CHGHOST %s %s", nick, vhost);
+ send_cmd(bi->GetUID(), "CHGHOST %s %s", nick, vhost);
}
int anope_event_idle(const char *source, int ac, const char **av)
@@ -102,7 +102,7 @@ int anope_event_idle(const char *source, int ac, const char **av)
if (!bi)
return MOD_CONT;
- send_cmd(bi->uid, "IDLE %s %ld %ld", source, static_cast<long>(start_time), static_cast<long>(time(NULL) - bi->lastmsg));
+ send_cmd(bi->GetUID(), "IDLE %s %ld %ld", source, static_cast<long>(start_time), static_cast<long>(time(NULL) - bi->lastmsg));
return MOD_CONT;
}
@@ -120,12 +120,12 @@ class InspIRCdProto : public IRCDProto
void SendAkillDel(XLine *x)
{
BotInfo *bi = OperServ;
- send_cmd(bi->uid, "GLINE %s", x->Mask.c_str());
+ send_cmd(bi->GetUID(), "GLINE %s", x->Mask.c_str());
}
void SendTopic(BotInfo *whosets, Channel *c, const char *whosetit, const char *topic)
{
- send_cmd(whosets->uid, "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time), whosetit, topic);
+ send_cmd(whosets->GetUID(), "FTOPIC %s %lu %s :%s", c->name.c_str(), static_cast<unsigned long>(c->topic_time), whosetit, topic);
}
void SendVhostDel(User *u)
@@ -148,12 +148,12 @@ class InspIRCdProto : public IRCDProto
if (timeleft > 172800 || !x->Expires)
timeleft = 172800;
BotInfo *bi = OperServ;
- send_cmd(bi->uid, "ADDLINE G %s@%s %s %ld %ld :%s", x->GetUser().c_str(), x->GetHost().c_str(), x->By.c_str(), static_cast<long>(time(NULL)), static_cast<long>(timeleft), x->Reason.c_str());
+ send_cmd(bi->GetUID(), "ADDLINE G %s@%s %s %ld %ld :%s", x->GetUser().c_str(), x->GetHost().c_str(), x->By.c_str(), static_cast<long>(time(NULL)), static_cast<long>(timeleft), x->Reason.c_str());
}
void SendSVSKillInternal(BotInfo *source, User *user, const char *buf)
{
- send_cmd(source ? source->uid : TS6SID, "KILL %s :%s", user->GetUID().c_str(), buf);
+ send_cmd(source ? source->GetUID() : TS6SID, "KILL %s :%s", user->GetUID().c_str(), buf);
}
void SendSVSMode(User *u, int ac, const char **av)
@@ -173,13 +173,13 @@ class InspIRCdProto : public IRCDProto
void SendModeInternal(BotInfo *source, Channel *dest, const char *buf)
{
- send_cmd(source ? source->uid : TS6SID, "FMODE %s %u %s", dest->name.c_str(), static_cast<unsigned>(dest->creation_time), buf);
+ send_cmd(source ? source->GetUID() : TS6SID, "FMODE %s %u %s", dest->name.c_str(), static_cast<unsigned>(dest->creation_time), buf);
}
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
- send_cmd(bi ? bi->uid : TS6SID, "MODE %s %s", u->GetUID().c_str(), buf);
+ send_cmd(bi ? bi->GetUID() : TS6SID, "MODE %s %s", u->GetUID().c_str(), buf);
}
void SendClientIntroduction(const std::string &nick, const std::string &user, const std::string &host, const std::string &real, const char *modes, const std::string &uid)
@@ -190,9 +190,9 @@ class InspIRCdProto : public IRCDProto
void SendKickInternal(BotInfo *source, Channel *chan, User *user, const char *buf)
{
if (buf)
- send_cmd(source->uid, "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), buf);
+ send_cmd(source->GetUID(), "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), buf);
else
- send_cmd(source->uid, "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), user->nick.c_str());
+ send_cmd(source->GetUID(), "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), user->nick.c_str());
}
void SendNoticeChanopsInternal(BotInfo *source, Channel *dest, const char *buf)
@@ -209,7 +209,7 @@ class InspIRCdProto : public IRCDProto
/* JOIN */
void SendJoin(BotInfo *user, const char *channel, time_t chantime)
{
- send_cmd(TS6SID, "FJOIN %s %ld + :,%s", channel, static_cast<long>(chantime), user->uid.c_str());
+ send_cmd(TS6SID, "FJOIN %s %ld + :,%s", channel, static_cast<long>(chantime), user->GetUID().c_str());
}
/* UNSQLINE */
@@ -262,7 +262,7 @@ class InspIRCdProto : public IRCDProto
else
{
BotInfo *bi = OperServ;
- send_cmd(bi->uid, "CHGIDENT %s %s", nick, vIdent);
+ send_cmd(bi->GetUID(), "CHGIDENT %s %s", nick, vIdent);
}
}
@@ -270,14 +270,14 @@ class InspIRCdProto : public IRCDProto
void SendSVSHold(const char *nick)
{
BotInfo *bi = OperServ;
- send_cmd(bi->uid, "SVSHOLD %s %u :%s", nick, static_cast<unsigned>(Config.NSReleaseTimeout), "Being held for registered user");
+ send_cmd(bi->GetUID(), "SVSHOLD %s %u :%s", nick, static_cast<unsigned>(Config.NSReleaseTimeout), "Being held for registered user");
}
/* SVSHOLD - release */
void SendSVSHoldDel(const char *nick)
{
BotInfo *bi = OperServ;
- send_cmd(bi->uid, "SVSHOLD %s", nick);
+ send_cmd(bi->GetUID(), "SVSHOLD %s", nick);
}
/* UNSZLINE */
@@ -302,14 +302,14 @@ class InspIRCdProto : public IRCDProto
{
User *u = finduser(nick);
BotInfo *bi = findbot(source);
- send_cmd(bi->uid, "SVSJOIN %s %s", u->GetUID().c_str(), chan);
+ send_cmd(bi->GetUID(), "SVSJOIN %s %s", u->GetUID().c_str(), chan);
}
void SendSVSPart(const char *source, const char *nick, const char *chan)
{
User *u = finduser(nick);
BotInfo *bi = findbot(source);
- send_cmd(bi->uid, "SVSPART %s %s", u->GetUID().c_str(), chan);
+ send_cmd(bi->GetUID(), "SVSPART %s %s", u->GetUID().c_str(), chan);
}
void SendSWhois(const char *source, const char *who, const char *mask)
@@ -326,7 +326,7 @@ class InspIRCdProto : public IRCDProto
void SendGlobopsInternal(BotInfo *source, const char *buf)
{
- send_cmd(source ? source->uid : TS6SID, "SNONOTICE g :%s", buf);
+ send_cmd(source ? source->GetUID() : TS6SID, "SNONOTICE g :%s", buf);
}
void SendAccountLogin(User *u, NickCore *account)
@@ -499,8 +499,8 @@ int anope_event_fjoin(const char *source, int ac, const char **av)
/* Rejoin the bot to fix the TS */
if (c->ci->bi)
{
- ircdproto->SendPart(c->ci->bi, c, "TS reop");
- bot_join(c->ci);
+ c->ci->bi->Part(c, "TS reop");
+ c->ci->bi->Join(c);
}
/* Reset mlock */
check_modes(c);
diff --git a/src/protocol/ratbox.cpp b/src/protocol/ratbox.cpp
index 6ffb91164..9285411c8 100644
--- a/src/protocol/ratbox.cpp
+++ b/src/protocol/ratbox.cpp
@@ -131,7 +131,7 @@ class RatboxProto : public IRCDTS6Proto
void SendGlobopsInternal(BotInfo *source, const char *buf)
{
if (source)
- send_cmd(source->uid, "OPERWALL :%s", buf);
+ send_cmd(source->GetUID(), "OPERWALL :%s", buf);
else
send_cmd(TS6SID, "OPERWALL :%s", buf);
}
@@ -144,19 +144,19 @@ class RatboxProto : public IRCDTS6Proto
void SendSGLineDel(XLine *x)
{
BotInfo *bi = OperServ;
- send_cmd(bi ? bi->uid : Config.s_OperServ, "UNXLINE * %s", x->Mask.c_str());
+ send_cmd(bi ? bi->GetUID() : Config.s_OperServ, "UNXLINE * %s", x->Mask.c_str());
}
void SendSGLine(XLine *x)
{
BotInfo *bi = OperServ;
- send_cmd(bi ? bi->uid : Config.s_OperServ, "XLINE * %s 0 :%s", x->Mask.c_str(), x->Reason.c_str());
+ send_cmd(bi ? bi->GetUID() : Config.s_OperServ, "XLINE * %s 0 :%s", x->Mask.c_str(), x->Reason.c_str());
}
void SendAkillDel(XLine *x)
{
BotInfo *bi = OperServ;
- send_cmd(bi ? bi->uid : Config.s_OperServ, "UNKLINE * %s %s", x->GetUser().c_str(), x->GetHost().c_str());
+ send_cmd(bi ? bi->GetUID() : Config.s_OperServ, "UNKLINE * %s %s", x->GetUser().c_str(), x->GetHost().c_str());
}
void SendSQLineDel(XLine *x)
@@ -166,18 +166,18 @@ class RatboxProto : public IRCDTS6Proto
void SendJoin(BotInfo *user, const char *channel, time_t chantime)
{
- send_cmd(NULL, "SJOIN %ld %s + :%s", static_cast<long>(chantime), channel, user->uid.c_str());
+ send_cmd(NULL, "SJOIN %ld %s + :%s", static_cast<long>(chantime), channel, user->GetUID().c_str());
}
void SendAkill(XLine *x)
{
BotInfo *bi = OperServ;
- send_cmd(bi ? bi->uid : Config.s_OperServ, "KLINE * %ld %s %s :%s", static_cast<long>(x->Expires - time(NULL)), x->GetUser().c_str(), x->GetHost().c_str(), x->Reason.c_str());
+ send_cmd(bi ? bi->GetUID() : Config.s_OperServ, "KLINE * %ld %s %s :%s", static_cast<long>(x->Expires - time(NULL)), x->GetUser().c_str(), x->GetHost().c_str(), x->Reason.c_str());
}
void SendSVSKillInternal(BotInfo *source, User *user, const char *buf)
{
- send_cmd(source ? source->uid : TS6SID, "KILL %s :%s", user->GetUID().c_str(), buf);
+ send_cmd(source ? source->GetUID() : TS6SID, "KILL %s :%s", user->GetUID().c_str(), buf);
}
void SendSVSMode(User *u, int ac, const char **av)
@@ -210,9 +210,9 @@ class RatboxProto : public IRCDTS6Proto
void SendPartInternal(BotInfo *bi, const char *chan, const char *buf)
{
if (buf)
- send_cmd(bi->uid, "PART %s :%s", chan, buf);
+ send_cmd(bi->GetUID(), "PART %s :%s", chan, buf);
else
- send_cmd(bi->uid, "PART %s", chan);
+ send_cmd(bi->GetUID(), "PART %s", chan);
}
void SendNumericInternal(const char *source, int numeric, const char *dest, const char *buf)
@@ -225,7 +225,7 @@ class RatboxProto : public IRCDTS6Proto
{
if (bi)
{
- send_cmd(bi->uid, "MODE %s %s", dest->name.c_str(), buf);
+ send_cmd(bi->GetUID(), "MODE %s %s", dest->name.c_str(), buf);
}
else send_cmd(TS6SID, "MODE %s %s", dest->name.c_str(), buf);
}
@@ -233,13 +233,13 @@ class RatboxProto : public IRCDTS6Proto
void SendModeInternal(BotInfo *bi, User *u, const char *buf)
{
if (!buf) return;
- send_cmd(bi ? bi->uid : TS6SID, "SVSMODE %s %s", u->nick.c_str(), buf);
+ send_cmd(bi ? bi->GetUID() : TS6SID, "SVSMODE %s %s", u->nick.c_str(), buf);
}
void SendKickInternal(BotInfo *bi, Channel *chan, User *user, const char *buf)
{
- if (buf) send_cmd(bi->uid, "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), buf);
- else send_cmd(bi->uid, "KICK %s %s", chan->name.c_str(), user->GetUID().c_str());
+ if (buf) send_cmd(bi->GetUID(), "KICK %s %s :%s", chan->name.c_str(), user->GetUID().c_str(), buf);
+ else send_cmd(bi->GetUID(), "KICK %s %s", chan->name.c_str(), user->GetUID().c_str());
}
void SendNoticeChanopsInternal(BotInfo *source, Channel *dest, const char *buf)
@@ -250,15 +250,15 @@ class RatboxProto : public IRCDTS6Proto
/* QUIT */
void SendQuitInternal(BotInfo *bi, const char *buf)
{
- if (buf) send_cmd(bi->uid, "QUIT :%s", buf);
- else send_cmd(bi->uid, "QUIT");
+ if (buf) send_cmd(bi->GetUID(), "QUIT :%s", buf);
+ else send_cmd(bi->GetUID(), "QUIT");
}
/* INVITE */
void SendInvite(BotInfo *source, const char *chan, const char *nick)
{
User *u = finduser(nick);
- send_cmd(source->uid, "INVITE %s %s", u ? u->GetUID().c_str(): nick, chan);
+ send_cmd(source->GetUID(), "INVITE %s %s", u ? u->GetUID().c_str(): nick, chan);
}
void SendAccountLogin(User *u, NickCore *account)
@@ -280,7 +280,7 @@ class RatboxProto : public IRCDTS6Proto
void SendTopic(BotInfo *bi, Channel *c, const char *whosetit, const char *topic)
{
- send_cmd(bi->uid, "TOPIC %s :%s", c->name.c_str(), topic);
+ send_cmd(bi->GetUID(), "TOPIC %s :%s", c->name.c_str(), topic);
}
void SetAutoIdentificationToken(User *u)
@@ -334,8 +334,8 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
/* Rejoin the bot to fix the TS */
if (c->ci->bi)
{
- ircdproto->SendPart(c->ci->bi, c, "TS reop");
- bot_join(c->ci);
+ c->ci->bi->Part(c, "TS reop");
+ c->ci->bi->Join(c);
}
/* Reset mlock */
check_modes(c);
@@ -669,7 +669,7 @@ int anope_event_whois(const char *source, int ac, const char **av)
if (source && ac >= 1) {
bi = findbot(av[0]);
- m_whois(source, bi->uid.c_str());
+ m_whois(source, bi->GetUID().c_str());
}
return MOD_CONT;
}
diff --git a/src/protocol/unreal32.cpp b/src/protocol/unreal32.cpp
index 2a8cc6b39..dff0421d2 100644
--- a/src/protocol/unreal32.cpp
+++ b/src/protocol/unreal32.cpp
@@ -1051,8 +1051,8 @@ int anope_event_sjoin(const char *source, int ac, const char **av)
/* Rejoin the bot to fix the TS */
if (c->ci->bi)
{
- ircdproto->SendPart(c->ci->bi, c, "TS reop");
- bot_join(c->ci);
+ c->ci->bi->Part(c, "TS reop");
+ c->ci->bi->Join(c);
}
/* Reset mlock */
check_modes(c);
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 9e28b5cb0..c4c29c0c4 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -72,13 +72,10 @@ ChannelInfo::~ChannelInfo()
Alog(LOG_DEBUG) << "Deleting channel " << this->name;
- if (this->bi)
- --this->bi->chancount;
-
if (this->c)
{
if (this->bi && this->c->users.size() >= Config.BSMinUsers)
- ircdproto->SendPart(this->bi, this->c, NULL);
+ this->bi->Part(this->c);
this->c->ci = NULL;
}
@@ -637,9 +634,11 @@ bool ChannelInfo::CheckKick(User *user)
Alog(LOG_DEBUG) << "Autokicking "<< user->GetMask() << " from " << this->name;
/* If the channel isn't syncing and doesn't have any users, join ChanServ
- * NOTE: we use usercount == 1 here as there is one user, but they are about to be destroyed
+ * Note that the user AND POSSIBLY the botserv bot exist here
+ * ChanServ always enforces channels like this to keep people from deleting bots etc
+ * that are holding channels.
*/
- if (this->c->users.size() == 1 && !this->HasFlag(CI_INHABIT) && !this->c->HasFlag(CH_SYNCING))
+ if (this->c->users.size() == (this->bi ? 2 : 1) && !this->HasFlag(CI_INHABIT) && !this->c->HasFlag(CH_SYNCING))
{
/* If channel was forbidden, etc, set it +si to prevent rejoin */
if (set_modes)
@@ -651,7 +650,7 @@ bool ChannelInfo::CheckKick(User *user)
}
/* Join ChanServ */
- ircdproto->SendJoin(ChanServ, this->name.c_str(), this->c->creation_time);
+ ChanServ->Join(this->c);
/* Set a timer for this channel to part ChanServ later */
new ChanServTimer(this->c);
diff --git a/src/servers.cpp b/src/servers.cpp
index 3a4a0233b..4ab8db197 100644
--- a/src/servers.cpp
+++ b/src/servers.cpp
@@ -75,8 +75,7 @@ Server::Server(Server *uplink, const std::string &name, unsigned int hops, const
/* And some IRCds needs Global joined in the logchan */
if (LogChan && ircd->join2msg)
- /* XXX might desync */
- ircdproto->SendJoin(Global, Config.LogChannel, time(NULL));
+ Global->Join(Config.LogChannel);
}
}
diff --git a/src/users.cpp b/src/users.cpp
index 7678f17c9..e4a0134eb 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -228,8 +228,6 @@ User::~User()
if (na)
na->OnCancel(this);
- Alog(LOG_DEBUG_2) << "User::~User(): free user data";
-
delete [] this->host;
if (this->vhost)