/* :0MC BMASK 1350157102 #channel b :*!*@*.test.com */ void hybrid::BMask::Run(MessageSource &source, const std::vector<Anope::string> ¶ms) { Channel *c = Channel::Find(params[1]); ChannelMode *mode = ModeManager::FindChannelModeByChar(params[2][0]); if (c && mode) { spacesepstream bans(params[3]); Anope::string token; while (bans.GetToken(token)) c->SetModeInternal(source, mode, token); } }
bool OnSJoin(const Anope::string &source, const std::vector<Anope::string> ¶ms) { Channel *c = findchan(params[1]); time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0; bool keep_their_modes = true; if (!c) { c = new Channel(params[1], ts); 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(); } /* Their TS is newer than ours, our modes > theirs, unset their modes if need be */ else if (ts > c->creation_time) keep_their_modes = false; /* If we need to keep their modes, and this SJOIN string contains modes */ if (keep_their_modes && params.size() >= 4) { /* Set the modes internally */ Anope::string modes; for (unsigned i = 2; i < params.size(); ++i) modes += " " + params[i]; if (!modes.empty()) modes.erase(modes.begin()); c->SetModesInternal(NULL, modes); } /* For some reason, bahamut will send a SJOIN from the user joining a channel * if the channel already existed */ if (!c->HasFlag(CH_SYNCING) && params.size() == 2) { User *u = finduser(source); if (!u) Log(LOG_DEBUG) << "SJOIN for nonexistant user " << source << " on " << c->name; else { EventReturn MOD_RESULT; FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); /* Add the user to the channel */ c->JoinUser(u); /* Now set whatever modes this user is allowed to have on the channel */ chan_set_correct_modes(u, c, 1); /* Check to see if modules want the user to join, if they do * check to see if they are allowed to join (CheckKick will kick/ban them) * Don't trigger OnJoinChannel event then as the user will be destroyed */ if (MOD_RESULT == EVENT_STOP && (!c->ci || !c->ci->CheckKick(u))) { FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); } } } else { spacesepstream sep(params[params.size() - 1]); Anope::string buf; while (sep.GetToken(buf)) { std::list<ChannelMode *> Status; char ch; /* Get prefixes from the nick */ while ((ch = ModeManager::GetStatusChar(buf[0]))) { buf.erase(buf.begin()); ChannelMode *cm = ModeManager::FindChannelModeByChar(ch); if (!cm) { Log() << "Received unknown mode prefix " << cm << " in SJOIN string"; continue; } if (keep_their_modes) Status.push_back(cm); } User *u = finduser(buf); if (!u) { Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name; continue; } EventReturn MOD_RESULT; FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c)); /* Add the user to the channel */ c->JoinUser(u); /* Update their status internally on the channel * This will enforce secureops etc on the user */ for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it) c->SetModeInternal(*it, buf); /* Now set whatever modes this user is allowed to have on the channel */ chan_set_correct_modes(u, c, 1); /* Check to see if modules want the user to join, if they do * check to see if they are allowed to join (CheckKick will kick/ban them) * Don't trigger OnJoinChannel event then as the user will be destroyed */ if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u)) continue; FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c)); } } /* Channel is done syncing */ if (c->HasFlag(CH_SYNCING)) { /* Unset the syncing flag */ c->UnsetFlag(CH_SYNCING); c->Sync(); } return true; }
Server::Server(Server *up, const Anope::string &sname, unsigned shops, const Anope::string &desc, const Anope::string &ssid, bool jupe) : name(sname), hops(shops), description(desc), sid(ssid), uplink(up), users(0) { syncing = true; juped = jupe; quitting = false; Servers::ByName[sname] = this; if (!ssid.empty()) Servers::ByID[ssid] = this; Log(this, "connect") << "has connected to the network (uplinked to " << (this->uplink ? this->uplink->GetName() : "no uplink") << ")"; /* Add this server to our uplinks leaf list */ if (this->uplink) { this->uplink->AddLink(this); /* Check to be sure this isn't a juped server */ if (Me == this->uplink && !juped) { /* Now do mode related stuff as we know what modes exist .. */ for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it) { BotInfo *bi = it->second; Anope::string modes = !bi->botmodes.empty() ? ("+" + bi->botmodes) : IRCD->DefaultPseudoclientModes; bi->SetModesInternal(bi, modes.c_str()); for (unsigned i = 0; i < bi->botchannels.size(); ++i) { size_t h = bi->botchannels[i].find('#'); if (h == Anope::string::npos) continue; Anope::string chname = bi->botchannels[i].substr(h); Channel *c = Channel::Find(chname); if (c && c->FindUser(bi)) { Anope::string want_modes = bi->botchannels[i].substr(0, h); for (unsigned j = 0; j < want_modes.length(); ++j) { ChannelMode *cm = ModeManager::FindChannelModeByChar(want_modes[j]); if (cm == NULL) cm = ModeManager::FindChannelModeByChar(ModeManager::GetStatusChar(want_modes[j])); if (cm && cm->type == MODE_STATUS) { MessageSource ms = bi; c->SetModeInternal(ms, cm, bi->nick); } } } } } IRCD->SendBOB(); for (unsigned i = 0; i < Me->GetLinks().size(); ++i) { Server *s = Me->GetLinks()[i]; if (s->juped) IRCD->SendServer(s); } /* We make the bots go online */ for (user_map::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it) { User *u = it->second; BotInfo *bi = BotInfo::Find(u->GetUID()); if (bi) { XLine x(bi->nick, "Reserved for services"); IRCD->SendSQLine(NULL, &x); } IRCD->SendClientIntroduction(u); if (bi) bi->introduced = true; } for (channel_map::const_iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it) { Channel *c = it->second; if (c->users.empty()) IRCD->SendChannel(c); else for (Channel::ChanUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit) IRCD->SendJoin(cit->second->user, c, &cit->second->status); for (Channel::ModeList::const_iterator it2 = c->GetModes().begin(); it2 != c->GetModes().end(); ++it2) { ChannelMode *cm = ModeManager::FindChannelModeByName(it2->first); if (!cm || cm->type != MODE_LIST) continue; ModeManager::StackerAdd(c->ci->WhoSends(), c, cm, true, it2->second); } if (!c->topic.empty() && !c->topic_setter.empty()) IRCD->SendTopic(c->ci->WhoSends(), c); c->syncing = true; } } } FOREACH_MOD(OnNewServer, (this)); }