diff options
author | Adam <Adam@anope.org> | 2010-08-21 01:40:36 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-08-21 01:40:36 -0400 |
commit | fb551f0d5d412246a5221e8e9e310c191033b317 (patch) | |
tree | e737cdf9db93d53313701695c338ab9c96e83e9f /modules/protocol/bahamut.cpp | |
parent | 931b0777fbd961a4ca961ddfa763af92dcce946c (diff) |
Made Anope keep track of channels its clients are in if it splits from its uplink, then burst them back to its uplink once connection is reestablished.
Also made Anope use TS enforcement to change persistant channels creation time to the time they were registered.
Diffstat (limited to 'modules/protocol/bahamut.cpp')
-rw-r--r-- | modules/protocol/bahamut.cpp | 65 |
1 files changed, 27 insertions, 38 deletions
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp index 572b91367..9c3e107a4 100644 --- a/modules/protocol/bahamut.cpp +++ b/modules/protocol/bahamut.cpp @@ -197,6 +197,19 @@ class BahamutIRCdProto : public IRCDProto send_cmd(user->nick, "SJOIN %ld %s", static_cast<long>(chantime), channel.c_str()); } + void SendJoin(BotInfo *user, const ChannelContainer *cc) + { + SendJoin(user, cc->chan->name, cc->chan->creation_time); + for (std::map<char, ChannelMode *>::iterator it = ModeManager::ChannelModesByChar.begin(), it_end = ModeManager::ChannelModesByChar.end(); it != it_end; ++it) + { + if (cc->Status->HasFlag(it->second->Name)) + { + cc->chan->SetMode(user, it->second, user->nick); + } + } + cc->chan->SetModes(user, false, "%s", cc->chan->GetModes(true, true).c_str()); + } + void SendAkill(const XLine *x) { // Calculate the time left before this would expire, capping it at 2 days @@ -226,6 +239,11 @@ class BahamutIRCdProto : public IRCDProto this->SendModeInternal(NULL, u, merge_args(ac, av)); } + void SendBOB() + { + send_cmd("", "BURST"); + } + void SendEOB() { send_cmd("", "BURST 0"); @@ -290,56 +308,26 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av) { Channel *c = findchan(av[1]); time_t ts = Anope::string(av[0]).is_number_only() ? convertTo<time_t>(av[0]) : 0; - bool was_created = false; bool keep_their_modes = false; if (!c) { c = new Channel(av[1], ts); - was_created = true; + c->SetFlag(CH_SYNCING); } /* Our creation time is newer than what the server gave us */ else if (c->creation_time > ts) { c->creation_time = ts; + c->Reset(); - /* Remove status from all of our users */ - for (std::list<Mode *>::const_iterator it = ModeManager::Modes.begin(), it_end = ModeManager::Modes.end(); it != it_end; ++it) - { - Mode *m = *it; - - if (m->Type != MODE_STATUS) - continue; - - ChannelMode *cm = debug_cast<ChannelMode *>(m); - - for (CUserList::const_iterator uit = c->users.begin(), uit_end = c->users.end(); uit != uit_end; ++uit) - { - UserContainer *uc = *uit; - - c->RemoveMode(NULL, cm, uc->user->nick); - } - } - if (c->ci) - { - /* Rejoin the bot to fix the TS */ - if (c->ci->bi) - { - c->ci->bi->Part(c, "TS reop"); - c->ci->bi->Join(c); - } - /* Reset mlock */ - check_modes(c); - } + /* Reset mlock */ + check_modes(c); } /* Their TS is newer than ours, our modes > theirs, unset their modes if need be */ - else + else if (ts > c->creation_time) keep_their_modes = false; - /* Mark the channel as syncing */ - if (was_created) - c->SetFlag(CH_SYNCING); - /* If we need to keep their modes, and this SJOIN string contains modes */ if (keep_their_modes && ac >= 4) { @@ -350,7 +338,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av) /* For a reason unknown to me, bahamut will send a SJOIN from the user joining a channel * if the channel already existed */ - if (!was_created && ac == 2) + if (!c->HasFlag(CH_SYNCING) && ac == 2) { User *u = finduser(source); if (!u) @@ -396,7 +384,8 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av) continue; } - Status.push_back(cm); + if (keep_their_modes) + Status.push_back(cm); } User *u = finduser(buf); @@ -433,7 +422,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av) } /* Channel is done syncing */ - if (was_created) + if (c->HasFlag(CH_SYNCING)) { /* Unset the syncing flag */ c->UnsetFlag(CH_SYNCING); |