+ ConfigTag* tag = i->second;
+ std::string channel = tag->getString("channel");
+ std::string modes = tag->getString("modes");
+
+ if (!ServerInstance->IsChannel(channel))
+ {
+ ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Ignoring permchannels tag with invalid channel name (\"" + channel + "\")");
+ continue;
+ }
+
+ Channel *c = ServerInstance->FindChan(channel);
+
+ if (!c)
+ {
+ time_t TS = tag->getInt("ts", ServerInstance->Time(), 1);
+ c = new Channel(channel, TS);
+
+ time_t topicset = tag->getInt("topicts", 0);
+ std::string topic = tag->getString("topic");
+
+ if ((topicset != 0) || (!topic.empty()))
+ {
+ if (topicset == 0)
+ topicset = ServerInstance->Time();
+ std::string topicsetby = tag->getString("topicsetby");
+ if (topicsetby.empty())
+ topicsetby = ServerInstance->Config->ServerName;
+ c->SetTopic(ServerInstance->FakeClient, topic, topicset, &topicsetby);
+ }
+
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Added %s with topic %s", channel.c_str(), c->topic.c_str());
+
+ if (modes.empty())
+ continue;
+
+ irc::spacesepstream list(modes);
+ std::string modeseq;
+ std::string par;
+
+ list.GetToken(modeseq);
+
+ // XXX bleh, should we pass this to the mode parser instead? ugly. --w00t
+ for (std::string::iterator n = modeseq.begin(); n != modeseq.end(); ++n)
+ {
+ ModeHandler* mode = ServerInstance->Modes->FindMode(*n, MODETYPE_CHANNEL);
+ if (mode)
+ {
+ if (mode->NeedsParam(true))
+ list.GetToken(par);
+ else
+ par.clear();
+
+ mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, c, par, true);
+ }
+ }
+
+ // We always apply the permchannels mode to permanent channels.
+ par.clear();
+ p.OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, c, par, true);
+ }