diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/bots.cpp | 77 | ||||
| -rw-r--r-- | src/botserv.cpp | 46 | ||||
| -rw-r--r-- | src/channels.cpp | 61 | ||||
| -rw-r--r-- | src/chanserv.cpp | 10 | ||||
| -rw-r--r-- | src/core/bs_act.cpp | 2 | ||||
| -rw-r--r-- | src/core/bs_bot.cpp | 26 | ||||
| -rw-r--r-- | src/core/bs_botlist.cpp | 4 | ||||
| -rw-r--r-- | src/core/bs_info.cpp | 6 | ||||
| -rw-r--r-- | src/core/bs_say.cpp | 2 | ||||
| -rw-r--r-- | src/core/cs_set_persist.cpp | 8 | ||||
| -rw-r--r-- | src/core/cs_topic.cpp | 6 | ||||
| -rw-r--r-- | src/core/db_plain.cpp | 11 | ||||
| -rw-r--r-- | src/core/os_set.cpp | 10 | ||||
| -rw-r--r-- | src/init.cpp | 2 | ||||
| -rw-r--r-- | src/main.cpp | 12 | ||||
| -rw-r--r-- | src/messages.cpp | 2 | ||||
| -rw-r--r-- | src/modes.cpp | 4 | ||||
| -rw-r--r-- | src/modules/cs_appendtopic.cpp | 10 | ||||
| -rw-r--r-- | src/protocol.cpp | 24 | ||||
| -rw-r--r-- | src/protocol/bahamut.cpp | 4 | ||||
| -rw-r--r-- | src/protocol/inspircd11.cpp | 4 | ||||
| -rw-r--r-- | src/protocol/inspircd12.cpp | 40 | ||||
| -rw-r--r-- | src/protocol/inspircd20.cpp | 38 | ||||
| -rw-r--r-- | src/protocol/ratbox.cpp | 40 | ||||
| -rw-r--r-- | src/protocol/unreal32.cpp | 4 | ||||
| -rw-r--r-- | src/regchannel.cpp | 13 | ||||
| -rw-r--r-- | src/servers.cpp | 3 | ||||
| -rw-r--r-- | src/users.cpp | 2 |
28 files changed, 243 insertions, 228 deletions
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 ¶m, 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 ¶m, 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 ¶m, 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> ¶ms) 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 } } ircdp |
