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->c