mirror of
https://github.com/znc/znc.git
synced 2026-07-02 16:02:02 +02:00
partyline: Save channel topics across restarts
This implements some feature request on sf.net. Patch by Reed Loden (r33d), thanks a lot. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1898 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
+41
-15
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user