diff --git a/modules/partyline.cpp b/modules/partyline.cpp index d1f67672..20f67da0 100644 --- a/modules/partyline.cpp +++ b/modules/partyline.cpp @@ -87,23 +87,41 @@ public: } void Load() { - VCString vsChannels; + CString sAction, sKey; + CPartylineChannel* pChannel; for (MCString::iterator it = BeginNV(); it != EndNV(); ++it) { - CUser* pUser = CZNC::Get().FindUser(it->first); - CPartylineChannel* pChannel; - it->second.Split(",", vsChannels, false); - - if (!pUser) { - // TODO: give some usefull message? - continue; + if (it->first.find(":") != CString::npos) { + sAction = it->first.Token(0, false, ":"); + sKey = it->first.Token(1, true, ":"); + } else { + // backwards compatibility for older NV data + sAction = "fixedchan"; + sKey = it->first; } - for (VCString::iterator i = vsChannels.begin(); i != vsChannels.end(); ++i) { - if (i->Trim_n().empty()) + if (sAction == "fixedchan") { + CUser* pUser = CZNC::Get().FindUser(sKey); + if (!pUser) { + // TODO: give some useful message? continue; - pChannel = GetChannel(*i); - JoinUser(pUser, pChannel); - pChannel->AddFixedNick(it->first); + } + + VCString vsChannels; + it->second.Split(",", vsChannels, false); + for (VCString::iterator i = vsChannels.begin(); i != vsChannels.end(); ++i) { + if (i->Trim_n().empty()) + continue; + pChannel = GetChannel(*i); + JoinUser(pUser, pChannel); + pChannel->AddFixedNick(sKey); + } + } + + if (sAction == "topic") { + pChannel = FindChannel(sKey); + if (pChannel && !sKey.empty()) { + pChannel->SetTopic(it->second); + } } } @@ -122,9 +140,16 @@ public: } if (!sChans.empty()) - SetNV(sUser, sChans.substr(1)); // Strip away the first , + SetNV("fixedchan:" + sUser, sChans.substr(1)); // Strip away the first , else - DelNV(sUser); + DelNV("fixedchan:" + sUser); + } + + void SaveTopic(CPartylineChannel* pChannel) { + if (!pChannel->GetTopic().empty()) + SetNV("topic:" + pChannel->GetName(), pChannel->GetTopic()); + else + DelNV("topic:" + pChannel->GetName()); } virtual EModRet OnDeleteUser(CUser& User) { @@ -230,6 +255,7 @@ public: if (m_pUser->IsAdmin()) { PutChan(ssNicks, ":" + m_pUser->GetIRCNick().GetNickMask() + " TOPIC " + sChannel + " :" + sTopic); pChannel->SetTopic(sTopic); + SaveTopic(pChannel); } else { m_pUser->PutUser(":irc.znc.in 482 " + m_pUser->GetIRCNick().GetNick() + " " + sChannel + " :You're not channel operator"); }