mirror of
https://github.com/znc/znc.git
synced 2026-07-01 15:31:52 +02:00
Keepnick: Dont forward nick change errors which we generated ourselves
This blocks 433 replies from the irc server if the keepnick module tries to change our nick. This way the user isn't flooded with those errors. Oh and the actual logic is a little more complicated than this... This patch is inspired and implemented by SilverLeo. Thanks :) git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1209 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -124,6 +124,41 @@ public:
|
||||
m_pTimer = NULL;
|
||||
}
|
||||
|
||||
virtual EModRet OnUserRaw(CString& sLine) {
|
||||
// We dont care if we are not connected to IRC
|
||||
if (!m_pUser->IsIRCConnected())
|
||||
return CONTINUE;
|
||||
|
||||
// We are trying to get the config nick and this is a /nick?
|
||||
if (!m_pTimer || sLine.Token(0).CaseCmp("NICK") != 0)
|
||||
return CONTINUE;
|
||||
|
||||
// Is the nick change for the nick we are trying to get?
|
||||
CString sNick = sLine.Token(1);
|
||||
|
||||
// Don't even think of using spaces in your nick!
|
||||
if (sNick.Left(1) == ":")
|
||||
sNick.LeftChomp();
|
||||
|
||||
if (sNick.CaseCmp(GetNick()) != 0)
|
||||
return CONTINUE;
|
||||
|
||||
// Indeed trying to change to this nick, generate a 433 for it.
|
||||
// This way we can *always* block incoming 433s from the server.
|
||||
PutUser(":" + m_pUser->GetIRCServer() + " 433 " + m_pUser->GetIRCNick().GetNick()
|
||||
+ " " + sNick + " :ZNC is already trying to get this nickname");
|
||||
return CONTINUE;
|
||||
}
|
||||
|
||||
virtual EModRet OnRaw(CString& sLine) {
|
||||
// Are we trying to get our primary nick and we caused this error?
|
||||
// :irc.server.net 433 mynick badnick :Nickname is already in use.
|
||||
if (m_pTimer && sLine.Token(1) == "433" && sLine.Token(3).CaseCmp(GetNick()) == 0)
|
||||
return HALT;
|
||||
|
||||
return CONTINUE;
|
||||
}
|
||||
|
||||
void OnModCommand(const CString& sCommand) {
|
||||
CString sCmd = sCommand.AsUpper();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user