mirror of
https://github.com/znc/znc.git
synced 2026-07-30 13:33:42 +02:00
Merge pull request #416 from schoentoon/master
Implemented a nick compare function
This commit is contained in:
@@ -37,6 +37,7 @@ public:
|
||||
void Parse(const CString& sNickMask);
|
||||
CString GetHostMask() const;
|
||||
size_t GetCommonChans(std::vector<CChan*>& vChans, CIRCNetwork* pNetwork) const;
|
||||
bool NickEquals(const CString& nickname) const;
|
||||
|
||||
// Setters
|
||||
void SetNetwork(CIRCNetwork* pNetwork);
|
||||
|
||||
@@ -142,7 +142,7 @@ protected:
|
||||
|
||||
// Is that person us and we don't have op?
|
||||
const CNick& pNick = Channel.GetNicks().begin()->second;
|
||||
if (!pNick.HasPerm(CChan::Op) && pNick.GetNick().Equals(m_pNetwork->GetCurNick())) {
|
||||
if (!pNick.HasPerm(CChan::Op) && pNick.NickEquals(m_pNetwork->GetCurNick())) {
|
||||
Channel.Cycle();
|
||||
m_recentlyCycled.AddItem(Channel.GetName());
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
void OnNick(const CNick& Nick, const CString& sNewNick, const vector<CChan*>& vChans) {
|
||||
if (sNewNick == m_pNetwork->GetIRCSock()->GetNick()) {
|
||||
// We are changing our own nick
|
||||
if (Nick.GetNick().Equals(GetNick())) {
|
||||
if (Nick.NickEquals(GetNick())) {
|
||||
// We are changing our nick away from the conf setting.
|
||||
// Let's assume the user wants this and disable
|
||||
// this module (to avoid fighting nickserv).
|
||||
@@ -92,14 +92,14 @@ public:
|
||||
}
|
||||
|
||||
// If the nick we want is free now, be fast and get the nick
|
||||
if (Nick.GetNick().Equals(GetNick())) {
|
||||
if (Nick.NickEquals(GetNick())) {
|
||||
KeepNick();
|
||||
}
|
||||
}
|
||||
|
||||
void OnQuit(const CNick& Nick, const CString& sMessage, const vector<CChan*>& vChans) {
|
||||
// If someone with the nick we want quits, be fast and get the nick
|
||||
if (Nick.GetNick().Equals(GetNick())) {
|
||||
if (Nick.NickEquals(GetNick())) {
|
||||
KeepNick();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ public:
|
||||
void HandleMessage(CNick& Nick, const CString& sMessage) {
|
||||
CString sNickServName = (!GetNV("NickServName").empty()) ? GetNV("NickServName") : "NickServ";
|
||||
if (!GetNV("Password").empty()
|
||||
&& Nick.GetNick().Equals(sNickServName)
|
||||
&& Nick.NickEquals(sNickServName)
|
||||
&& (sMessage.find("msg") != CString::npos
|
||||
|| sMessage.find("authenticate") != CString::npos
|
||||
|| sMessage.find("choose a different nickname") != CString::npos
|
||||
|
||||
+2
-2
@@ -312,7 +312,7 @@ private:
|
||||
}
|
||||
|
||||
EModRet HandleMessage(const CNick& Nick, CString sMessage) {
|
||||
if (!Nick.GetNick().Equals("Q") || !Nick.GetHost().Equals("CServe.quakenet.org"))
|
||||
if (!Nick.NickEquals("Q") || !Nick.GetHost().Equals("CServe.quakenet.org"))
|
||||
return CONTINUE;
|
||||
|
||||
sMessage.Trim();
|
||||
@@ -418,7 +418,7 @@ private:
|
||||
}
|
||||
|
||||
bool IsSelf(const CNick& Nick) {
|
||||
return Nick.GetNick().Equals(m_pNetwork->GetCurNick());
|
||||
return Nick.NickEquals(m_pNetwork->GetCurNick());
|
||||
}
|
||||
|
||||
bool PackHex(const CString& sHex, CString& sPackedHex) {
|
||||
|
||||
@@ -297,7 +297,7 @@ public:
|
||||
{
|
||||
AddBuffer(*vChans[a], SpoofChanMsg(vChans[a]->GetName(), cNick.GetNickMask() + " QUIT " + sMessage));
|
||||
}
|
||||
if (cNick.GetNick().Equals(m_pUser->GetNick()))
|
||||
if (cNick.NickEquals(m_pUser->GetNick()))
|
||||
SaveBufferToDisk(); // need to force a save here to see this!
|
||||
}
|
||||
|
||||
@@ -314,7 +314,7 @@ public:
|
||||
}
|
||||
virtual void OnJoin(const CNick& cNick, CChan& cChannel)
|
||||
{
|
||||
if (cNick.GetNick().Equals(m_pUser->GetNick()) && cChannel.GetBuffer().empty())
|
||||
if (cNick.NickEquals(m_pUser->GetNick()) && cChannel.GetBuffer().empty())
|
||||
{
|
||||
BootStrap((CChan *)&cChannel);
|
||||
if (!cChannel.GetBuffer().empty())
|
||||
@@ -325,7 +325,7 @@ public:
|
||||
virtual void OnPart(const CNick& cNick, CChan& cChannel)
|
||||
{
|
||||
AddBuffer(cChannel, SpoofChanMsg(cChannel.GetName(), cNick.GetNickMask() + " PART"));
|
||||
if (cNick.GetNick().Equals(m_pUser->GetNick()))
|
||||
if (cNick.NickEquals(m_pUser->GetNick()))
|
||||
SaveBufferToDisk(); // need to force a save here to see this!
|
||||
}
|
||||
#endif /* LEGACY_SAVEBUFF */
|
||||
|
||||
+3
-3
@@ -286,13 +286,13 @@ void CChan::ModeChange(const CString& sModes, const CNick* pOpNick) {
|
||||
if (bAdd) {
|
||||
pNick->AddPerm(uPerm);
|
||||
|
||||
if (pNick->GetNick().Equals(m_pNetwork->GetCurNick())) {
|
||||
if (pNick->NickEquals(m_pNetwork->GetCurNick())) {
|
||||
AddPerm(uPerm);
|
||||
}
|
||||
} else {
|
||||
pNick->RemPerm(uPerm);
|
||||
|
||||
if (pNick->GetNick().Equals(m_pNetwork->GetCurNick())) {
|
||||
if (pNick->NickEquals(m_pNetwork->GetCurNick())) {
|
||||
RemPerm(uPerm);
|
||||
}
|
||||
}
|
||||
@@ -464,7 +464,7 @@ bool CChan::AddNick(const CString& sNick) {
|
||||
pNick->AddPerm(sPrefix[i]);
|
||||
}
|
||||
|
||||
if (pNick->GetNick().Equals(m_pNetwork->GetCurNick())) {
|
||||
if (pNick->NickEquals(m_pNetwork->GetCurNick())) {
|
||||
for (CString::size_type i = 0; i < sPrefix.length(); i++) {
|
||||
AddPerm(sPrefix[i]);
|
||||
}
|
||||
|
||||
+5
-8
@@ -512,8 +512,7 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
}
|
||||
}
|
||||
|
||||
// Todo: use nick compare function here
|
||||
if (Nick.GetNick().Equals(GetNick())) {
|
||||
if (Nick.NickEquals(GetNick())) {
|
||||
// We are changing our own nick, the clients always must see this!
|
||||
bIsVisible = false;
|
||||
SetNick(sNewNick);
|
||||
@@ -531,7 +530,7 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
|
||||
// :nick!ident@host.com QUIT :message
|
||||
|
||||
if (Nick.GetNick().Equals(GetNick())) {
|
||||
if (Nick.NickEquals(GetNick())) {
|
||||
m_pNetwork->PutStatus("You quit [" + sMessage + "]");
|
||||
// We don't call module hooks and we don't
|
||||
// forward this quit to clients (Some clients
|
||||
@@ -563,8 +562,7 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
CString sChan = sRest.Token(0).TrimPrefix_n();
|
||||
CChan* pChan;
|
||||
|
||||
// Todo: use nick compare function
|
||||
if (Nick.GetNick().Equals(GetNick())) {
|
||||
if (Nick.NickEquals(GetNick())) {
|
||||
m_pNetwork->AddChan(sChan, false);
|
||||
pChan = m_pNetwork->FindChan(sChan);
|
||||
if (pChan) {
|
||||
@@ -598,8 +596,7 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
bDetached = true;
|
||||
}
|
||||
|
||||
// Todo: use nick compare function
|
||||
if (Nick.GetNick().Equals(GetNick())) {
|
||||
if (Nick.NickEquals(GetNick())) {
|
||||
m_pNetwork->DelChan(sChan);
|
||||
}
|
||||
|
||||
@@ -703,7 +700,7 @@ void CIRCSock::ReadLine(const CString& sData) {
|
||||
}
|
||||
}
|
||||
|
||||
if (Nick.GetNick().Equals(m_pNetwork->GetIRCServer())) {
|
||||
if (Nick.NickEquals(m_pNetwork->GetIRCServer())) {
|
||||
m_pNetwork->PutUser(":" + Nick.GetNick() + " NOTICE " + sTarget + " :" + sMsg);
|
||||
} else {
|
||||
m_pNetwork->PutUser(":" + Nick.GetNickMask() + " NOTICE " + sTarget + " :" + sMsg);
|
||||
|
||||
@@ -78,6 +78,12 @@ size_t CNick::GetCommonChans(vector<CChan*>& vRetChans, CIRCNetwork* pNetwork) c
|
||||
return vRetChans.size();
|
||||
}
|
||||
|
||||
bool CNick::NickEquals(const CString& nickname) const {
|
||||
//TODO add proper IRC case mapping here
|
||||
//https://tools.ietf.org/html/draft-brocklesby-irc-isupport-03#section-3.1
|
||||
return m_sNick.Equals(nickname);
|
||||
}
|
||||
|
||||
void CNick::SetNetwork(CIRCNetwork* pNetwork) { m_pNetwork = pNetwork; }
|
||||
void CNick::SetNick(const CString& s) { m_sNick = s; }
|
||||
void CNick::SetIdent(const CString& s) { m_sIdent = s; }
|
||||
|
||||
Reference in New Issue
Block a user