From 57e51d9f74dfddd4d09c8952cb60ca5874381037 Mon Sep 17 00:00:00 2001 From: prozacx Date: Sat, 16 Sep 2006 07:47:29 +0000 Subject: [PATCH] Patched using modified partyline_topics.patch by x-x git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@760 726aef4b-f618-498e-8847-2d620e286838 --- modules/partyline.cpp | 53 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/modules/partyline.cpp b/modules/partyline.cpp index a585b160..d5cb67d8 100644 --- a/modules/partyline.cpp +++ b/modules/partyline.cpp @@ -96,7 +96,15 @@ public: set& ssNicks = it->second; if (ssNicks.find(m_pUser->GetUserName()) != ssNicks.end()) { + MCString::iterator itb = m_msTopics.find(it->first.AsLower()); + m_pClient->PutClient(":" + m_pUser->GetIRCNick().GetNickMask() + " JOIN " + it->first); + + if (itb != m_msTopics.end()) { + m_pClient->PutClient(":" + m_pUser->GetIRCNick().GetNickMask() + " JOIN " + it->first); + m_pClient->PutClient(":" + m_pUser->GetIRCServer() + " 332 " + m_pUser->GetIRCNick().GetNickMask() + " " + it->first + " :" + itb->second); + } + SendNickList(ssNicks, it->first); PutChan(ssNicks, ":*" + GetModName() + "!znc@rottenboy.com MODE " + it->first + " +" + CString(m_pUser->IsAdmin() ? "o" : "v") + " ?" + m_pUser->GetUserName(), true); } @@ -120,6 +128,38 @@ public: return HALT; } else if (sLine.Left(6).CaseCmp("MODE ~") == 0) { return HALT; + } else if (sLine.Left(8).CaseCmp("TOPIC ~#") == 0) { + CString sChannel = sLine.Token(1); + CString sTopic = sLine.Token(2, true); + + if (sTopic.Left(1) == ":") { + sTopic.LeftChomp(); + } + + set& ssNicks = m_msChans[sChannel.AsLower()]; // @todo do a lookup first + const CString& sNick = m_pUser->GetUserName(); + + if (ssNicks.find(sNick) != ssNicks.end()) { + if (!sTopic.empty()) { + if (m_pUser->IsAdmin()) { + PutChan(ssNicks, ":" + m_pUser->GetIRCNick().GetNickMask() + " TOPIC " + sChannel + " :" + sTopic); + m_msTopics[sChannel.AsLower()] = sTopic; + } else { + m_pUser->PutUser(":irc.znc.com 482 " + m_pUser->GetIRCNick().GetNick() + " " + sChannel + " :You're not channel operator"); + } + } else { + sTopic = m_msTopics[sChannel.AsLower()]; + + if (sTopic.empty()) { + m_pUser->PutUser(":irc.znc.com 331 " + m_pUser->GetIRCNick().GetNick() + " " + sChannel + " :No topic is set."); + } else { + m_pUser->PutUser(":irc.znc.com 332 " + m_pUser->GetIRCNick().GetNick() + " " + sChannel + " :" + sTopic); + } + } + } else { + m_pUser->PutUser(":irc.znc.com 442 " + m_pUser->GetIRCNick().GetNick() + " " + sChannel + " :You're not on that channel"); + } + return HALT; } return CONTINUE; @@ -151,6 +191,7 @@ public: if (ssNicks.empty()) { m_msChans.erase(sChannel.AsLower()); + m_msTopics.erase(sChannel.AsLower()); } } @@ -181,6 +222,13 @@ public: } m_pUser->PutUser(":" + m_pUser->GetIRCNick().GetNickMask() + " JOIN " + sChannel); + + MCString::iterator it = m_msTopics.find(sChannel.AsLower()); + + if (it != m_msTopics.end()) { + m_pUser->PutUser(":" + m_pUser->GetIRCServer() + " 332 " + m_pUser->GetIRCNick().GetNickMask() + " " + sChannel + " :" + it->second); + } + PutChan(ssNicks, ":?" + sNick + "!" + m_pUser->GetIdent() + "@" + sHost + " JOIN " + sChannel, false); SendNickList(ssNicks, sChannel); @@ -330,8 +378,9 @@ public: private: map > m_msChans; - set m_spInjectedPrefixes; - set m_ssDefaultChans; + set m_spInjectedPrefixes; + set m_ssDefaultChans; + MCString m_msTopics; }; GLOBALMODULEDEFS(CPartylineMod, "Internal channels and queries for users connected to znc");