+ void LoadDatabase()
+ {
+ /*
+ * Process config-defined list of permanent channels.
+ * -- w00t
+ */
+ ConfigTagList permchannels = ServerInstance->Config->ConfTags("permchannels");
+ for (ConfigIter i = permchannels.first; i != permchannels.second; ++i)
+ {
+ ConfigTag* tag = i->second;
+ std::string channel = tag->getString("channel");
+ std::string modes = tag->getString("modes");
+
+ if ((channel.empty()) || (channel.length() > ServerInstance->Config->Limits.ChanMax))
+ {
+ ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "Ignoring permchannels tag with empty or too long 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);
+
+ unsigned int topicset = tag->getInt("topicts");
+ c->topic = tag->getString("topic");
+
+ if ((topicset != 0) || (!c->topic.empty()))
+ {
+ if (topicset == 0)
+ topicset = ServerInstance->Time();
+ c->topicset = topicset;
+ c->setby = tag->getString("topicsetby");
+ if (c->setby.empty())
+ c->setby = ServerInstance->Config->ServerName;
+ }
+
+ 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->GetNumParams(true))
+ list.GetToken(par);
+ else
+ par.clear();
+
+ mode->OnModeChange(ServerInstance->FakeClient, ServerInstance->FakeClient, c, par, true);
+ }
+ }
+ }
+ }
+ }
+
+ ModResult OnRawMode(User* user, Channel* chan, const char mode, const std::string ¶m, bool adding, int pcnt) CXX11_OVERRIDE
+ {
+ if (chan && (chan->IsModeSet(p) || mode == p.GetModeChar()))
+ dirty = true;
+
+ return MOD_RES_PASSTHRU;
+ }
+
+ void OnPostTopicChange(User*, Channel *c, const std::string&) CXX11_OVERRIDE
+ {
+ if (c->IsModeSet(p))
+ dirty = true;
+ }
+
+ void OnBackgroundTimer(time_t) CXX11_OVERRIDE
+ {
+ if (dirty)
+ WriteDatabase(p, this, save_listmodes);
+ dirty = false;
+ }
+
+ void Prioritize()