diff options
| author | Adam <Adam@anope.org> | 2010-06-27 02:41:48 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2010-06-27 02:41:48 -0400 |
| commit | 57caa0b53f53927c72811ffffda8bb527975860f (patch) | |
| tree | 7fef9b12d2d86758acb9198001f88f072e8a31d6 /src/core | |
| parent | d49aee6cf88c79220eb785245257544c8051247f (diff) | |
Made Anope track its own clients internally as if they were real users
Diffstat (limited to 'src/core')
| -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 |
9 files changed, 37 insertions, 38 deletions
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); } |
