Fixed issues with key when joining a 'trying' chan

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@347 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
prozacx
2005-05-20 21:21:40 +00:00
parent c3a191d885
commit 41b5ea4398
3 changed files with 17 additions and 8 deletions

View File

@@ -44,10 +44,11 @@ void CChan::Cycle() const {
m_pUser->PutIRC("PART " + GetName() + "\r\nJOIN " + GetName() + " " + GetKey());
}
void CChan::JoinUser(bool bForce) {
void CChan::JoinUser(bool bForce, const CString& sKey) {
if (!bForce && (!IsOn() || !IsDetached())) {
IncClientRequests();
m_pUser->PutIRC("JOIN " + GetName());
m_pUser->PutIRC("JOIN " + GetName() + " " + ((sKey.empty()) ? GetKey() : sKey));
return;
}
@@ -124,7 +125,7 @@ CString CChan::GetModeString() const {
void CChan::SetModes(const CString& sModes) {
m_musModes.clear();
m_uLimit = 0;
m_sKey = "";
m_sCurKey = "";
ModeChange(sModes);
}
@@ -244,6 +245,10 @@ void CChan::ModeChange(const CString& sModes, const CString& sOpNick) {
break;
}
if (uMode == M_Key) {
m_sCurKey = (bAdd) ? sArg : "";
}
(bAdd) ? AddMode(uMode, sArg) : RemMode(uMode, sArg);
}
}

6
Chan.h
View File

@@ -1,6 +1,7 @@
#ifndef _CHAN_H
#define _CHAN_H
#include "main.h"
#include "Nick.h"
#include "String.h"
#include <vector>
@@ -45,7 +46,7 @@ public:
void Reset();
void Joined();
void Cycle() const;
void JoinUser(bool bForce = false);
void JoinUser(bool bForce = false, const CString& sKey = "");
void DetachUser();
void SendBuffer();
@@ -110,7 +111,7 @@ public:
const bool IsOn() const { return m_bIsOn; }
const CString& GetName() const { return m_sName; }
const map<unsigned char, CString>& GetModes() const { return m_musModes; }
const CString& GetKey() const { return m_sKey; }
const CString& GetKey() const { return (!m_sCurKey.empty()) ? m_sCurKey : m_sKey; }
unsigned int GetLimit() const { return m_uLimit; }
const CString& GetTopic() const { return m_sTopic; }
const CString& GetTopicOwner() const { return m_sTopicOwner; }
@@ -134,6 +135,7 @@ protected:
bool m_bAutoCycle;
CString m_sName;
CString m_sKey;
CString m_sCurKey;
CString m_sTopic;
CString m_sTopicOwner;
unsigned long m_ulTopicDate;

View File

@@ -112,6 +112,8 @@ void CUserSock::ReadLine(const CString& sData) {
return; // Don't forward this msg. ZNC has already registered us.
} else if (sCommand.CaseCmp("JOIN") == 0) {
CString sChan = sLine.Token(1);
CString sKey = sLine.Token(2);
if (sChan.Left(1) == ":") {
sChan.LeftChomp();
}
@@ -120,7 +122,7 @@ void CUserSock::ReadLine(const CString& sData) {
CChan* pChan = m_pUser->FindChan(sChan);
if (pChan) {
pChan->JoinUser();
pChan->JoinUser(false, sKey);
return;
}
}
@@ -524,11 +526,11 @@ void CUserSock::UserCommand(const CString& sLine) {
Table.SetCell("Buf", CString((pChan->KeepBuffer()) ? "*" : "") + CString::ToString(pChan->GetBufferCount()));
CString sModes = pChan->GetModeString();
unsigned int uLimit = pChan->GetLimit();
/*unsigned int uLimit = pChan->GetLimit();
const CString& sKey = pChan->GetKey();
if (uLimit) { sModes += " " + CString::ToString(uLimit); }
if (!sKey.empty()) { sModes += " " + sKey; }
if (!sKey.empty()) { sModes += " " + sKey; }*/
Table.SetCell("Modes", sModes);
Table.SetCell("Users", CString::ToString(pChan->GetNickCount()));