Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #416 from schoentoon/master

Implemented a nick compare function
  • Loading branch information...
commit 8a205483f1d65a892dbe2c08216e1ef3cae14d49 2 parents b7ce935 + 98ceafb
@DarthGandalf DarthGandalf authored
View
1  include/znc/Nick.h
@@ -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);
View
2  modules/autocycle.cpp
@@ -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());
}
View
6 modules/keepnick.cpp
@@ -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();
}
}
View
2  modules/nickserv.cpp
@@ -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
View
4 modules/q.cpp
@@ -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) {
View
6 modules/savebuff.cpp
@@ -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 */
View
6 src/Chan.cpp
@@ -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]);
}
View
13 src/IRCSock.cpp
@@ -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);
View
6 src/Nick.cpp
@@ -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; }
Please sign in to comment.
Something went wrong with that request. Please try again.