Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: znc/znc
base: b7ce935cb39b
...
head fork: znc/znc
compare: 8a205483f1d6
  • 4 commits
  • 9 files changed
  • 0 commit comments
  • 2 contributors
Commits on Oct 10, 2013
Toon Schoenmakers schoentoon Implemented a nick compare function
As suggested by the todos in IRCSock, added IsNick(CString) method
so the ugly Nick.GetNick().Equals(GetNick()) could be simplified.

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>
83b9a28
Toon Schoenmakers schoentoon Renamed IsNick to NickEquals
Also added a TODO to add proper IRC case comparing.

Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>
9166f5a
Toon Schoenmakers schoentoon Replaced the GetNick().Equals() with NickEquals() where possible
Signed-off-by: Toon Schoenmakers <nighteyes1993@gmail.com>
98ceafb
Alexey Sokolov DarthGandalf Merge pull request #416 from schoentoon/master
Implemented a nick compare function
8a20548
1  include/znc/Nick.h
View
@@ -37,6 +37,7 @@ class CNick
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);
2  modules/autocycle.cpp
View
@@ -142,7 +142,7 @@ class CAutoCycleMod : public CModule {
// 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());
}
6 modules/keepnick.cpp
View
@@ -78,7 +78,7 @@ class CKeepNickMod : public CModule {
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 @@ class CKeepNickMod : public CModule {
}
// 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();
}
}
2  modules/nickserv.cpp
View
@@ -157,7 +157,7 @@ class CNickServ : public CModule {
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
4 modules/q.cpp
View
@@ -312,7 +312,7 @@ class CQModule : public CModule {
}
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 @@ class CQModule : public CModule {
}
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) {
6 modules/savebuff.cpp
View
@@ -297,7 +297,7 @@ class CSaveBuff : public CModule
{
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 @@ class CSaveBuff : public CModule
}
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 @@ class CSaveBuff : public CModule
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 */
6 src/Chan.cpp
View
@@ -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]);
}
13 src/IRCSock.cpp
View
@@ -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);
6 src/Nick.cpp
View
@@ -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; }

No commit comments for this range

Something went wrong with that request. Please try again.