Example #1
0
	CIgnore(const CString& sHostMask, const CString& sType) {
		CNick Nick;
		Nick.Parse(sHostMask);

		m_sHostMask = ((Nick.GetNick().empty()) ? "*" : Nick.GetNick());

		m_sHostMask += "!";
		m_sHostMask += (Nick.GetIdent().empty()) ? "*" : Nick.GetIdent();

		m_sHostMask += "@";
		m_sHostMask += (Nick.GetHost().empty()) ? "*" : Nick.GetHost();

		m_sType = sType;
	}
Example #2
0
File: q.cpp Project: Adam-/znc
 EModRet OnInvite(const CNick& Nick, const CString& sChan) override {
     if (!Nick.NickEquals("Q") ||
         !Nick.GetHost().Equals("CServe.quakenet.org"))
         return CONTINUE;
     if (m_bJoinOnInvite) GetNetwork()->AddChan(sChan, false);
     return CONTINUE;
 }
Example #3
0
File: Nick.cpp Project: jimloco/znc
void CNick::Clone(const CNick& SourceNick) {
	SetNick(SourceNick.GetNick());
	SetIdent(SourceNick.GetIdent());
	SetHost(SourceNick.GetHost());

	m_sChanPerms = SourceNick.m_sChanPerms;
	m_pNetwork = SourceNick.m_pNetwork;
}
Example #4
0
File: log.cpp Project: Adam-/znc
void CLogMod::OnQuit(const CNick& Nick, const CString& sMessage,
                     const vector<CChan*>& vChans) {
    if (!HasNV("quits") || GetNV("quits").ToBool()) {
        for (CChan* pChan : vChans)
            PutLog("*** Quits: " + Nick.GetNick() + " (" + Nick.GetIdent() +
                       "@" + Nick.GetHost() + ") (" + sMessage + ")",
                   *pChan);
    }
}
Example #5
0
// #124: OnChanMsg(): nick doesn't have perms
static void FixupChanNick(CNick& Nick, CChan* pChan) {
    // A channel nick has up-to-date channel perms, but might be
    // lacking (usernames-in-host) the associated ident & host.
    // An incoming message, on the other hand, has normally a full
    // nick!ident@host prefix. Sync the two so that channel nicks
    // get the potentially missing piece of info and module hooks
    // get the perms.
    CNick* pChanNick = pChan->FindNick(Nick.GetNick());
    if (pChanNick) {
        if (!Nick.GetIdent().empty()) {
            pChanNick->SetIdent(Nick.GetIdent());
        }
        if (!Nick.GetHost().empty()) {
            pChanNick->SetHost(Nick.GetHost());
        }
        Nick.Clone(*pChanNick);
    }
}
Example #6
0
 void HandleMessage(CNick& Nick, const CString& sMessage)
 {
     if (!m_sAuth.empty()
             && Nick.GetNick().CaseCmp("Q") == 0
             && Nick.GetHost().CaseCmp("CServe.quakenet.org")  == 0
             && sMessage.find("AUTH") != CString::npos
             && sMessage.find("authenticate") != CString::npos) {
         PutIRC("PRIVMSG [email protected] :auth " + m_sAuth);
     }
 }
Example #7
0
	virtual void OnKick(const CNick& OpNick, const CString& sKickedNick, CChan& Channel, const CString& sMessage) {
		CString sOpNick = TclEscape(CString(OpNick.GetNick()));
		CString sNick = TclEscape(sKickedNick);
		CString sOpHost = TclEscape(CString(OpNick.GetIdent() + "@" + OpNick.GetHost()));

		CString sCommand = "Binds::ProcessKick {" + sOpNick + "} {" + sOpHost + "} - {" + Channel.GetName() + "} {" + sNick + "} {" + sMessage + "}";
		i = Tcl_Eval(interp, sCommand.c_str());
		if (i != TCL_OK) {
			PutModule(Tcl_GetStringResult(interp));
		}
	}
Example #8
0
	virtual EModRet OnPrivMsg(CNick& Nick, CString& sMessage) {
		CString sMes = TclEscape(sMessage);
		CString sNick = TclEscape(CString(Nick.GetNick()));
		CString sHost = TclEscape(CString(Nick.GetIdent() + "@" + Nick.GetHost()));

		CString sCommand = "Binds::ProcessMsgm {" + sNick + "} {" + sHost + "} - {" + sMes + "}";
		i = Tcl_Eval(interp, sCommand.c_str());
		if (i != TCL_OK) {
			PutModule(Tcl_GetStringResult(interp));
		}
		return CONTINUE;
	}
Example #9
0
	EModRet OnChanMsg(CNick& Nick, CChan& Channel, CString& sMessage) override {
		CString sMes = TclEscape(sMessage);
		CString sNick = TclEscape(CString(Nick.GetNick()));
		CString sHost = TclEscape(CString(Nick.GetIdent() + "@" + Nick.GetHost()));
		CString sChannel = TclEscape(CString(Channel.GetName()));

		CString sCommand = "Binds::ProcessPubm {" + sNick + "} {" + sHost + "} - {" + sChannel + "} {" + sMes + "}";
		i = Tcl_Eval(interp, sCommand.c_str());
		if (i != TCL_OK) {
			PutModule(Tcl_GetStringResult(interp));
		}
		return CONTINUE;
	}
Example #10
0
	virtual void OnNick(const CNick& OldNick, const CString& sNewNick, const vector<CChan*>& vChans) {
		CString sOldNick = TclEscape(CString(OldNick.GetNick()));
		CString sNewNickTmp = TclEscape(sNewNick);
		CString sHost = TclEscape(CString(OldNick.GetIdent() + "@" + OldNick.GetHost()));

		CString sCommand;
		// Nick change is triggered for each common chan so that binds can be chan specific
		unsigned int nLength = vChans.size();
		for (unsigned int n = 0; n < nLength; n++) {
			sCommand = "Binds::ProcessNick {" + sOldNick + "} {" + sHost + "} - {" + vChans[n]->GetName() + "} {" + sNewNickTmp + "}";
			i = Tcl_Eval(interp, sCommand.c_str());
			if (i != TCL_OK) {
				PutModule(Tcl_GetStringResult(interp));
			}
		}
	}
Example #11
0
File: log.cpp Project: GDXN/znc
void CLogMod::OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage)
{
    PutLog("*** Parts: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ") (" + sMessage + ")", Channel);
}
Example #12
0
File: log.cpp Project: GDXN/znc
void CLogMod::OnJoin(const CNick& Nick, CChan& Channel)
{
    PutLog("*** Joins: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ")", Channel);
}
Example #13
0
File: log.cpp Project: GDXN/znc
void CLogMod::OnQuit(const CNick& Nick, const CString& sMessage, const vector<CChan*>& vChans)
{
    for (std::vector<CChan*>::const_iterator pChan = vChans.begin(); pChan != vChans.end(); ++pChan)
        PutLog("*** Quits: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" + Nick.GetHost() + ") (" + sMessage + ")", **pChan);
}
Example #14
0
File: q.cpp Project: Adam-/znc
    EModRet HandleMessage(const CNick& Nick, CString sMessage) {
        if (!Nick.NickEquals("Q") ||
            !Nick.GetHost().Equals("CServe.quakenet.org"))
            return CONTINUE;

        sMessage.Trim();

#if Q_DEBUG_COMMUNICATION
        PutModule("[ZNC <-- Q] " + sMessage);
#endif

        // WHOAMI
        if (sMessage.find("WHOAMI is only available to authed users") !=
            CString::npos) {
            m_bAuthed = false;
            Auth();
            m_bCatchResponse = m_bRequestedWhoami;
        } else if (sMessage.find("Information for user") != CString::npos) {
            m_bAuthed = true;
            m_msChanModes.clear();
            m_bCatchResponse = m_bRequestedWhoami;
            m_bRequestedWhoami = true;
        } else if (m_bRequestedWhoami && sMessage.WildCmp("#*")) {
            CString sChannel = sMessage.Token(0);
            CString sFlags = sMessage.Token(1, true).Trim_n().TrimLeft_n("+");
            m_msChanModes[sChannel] = sFlags;
        } else if (m_bRequestedWhoami && m_bCatchResponse &&
                   (sMessage.Equals("End of list.") ||
                    sMessage.Equals(
                        "account, or HELLO to create an account."))) {
            m_bRequestedWhoami = m_bCatchResponse = false;
            return HALT;
        }

        // AUTH
        else if (sMessage.Equals("Username or password incorrect.")) {
            m_bAuthed = false;
            PutModule("Auth failed: " + sMessage);
            return HALT;
        } else if (sMessage.WildCmp("You are now logged in as *.")) {
            m_bAuthed = true;
            PutModule("Auth successful: " + sMessage);
            WhoAmI();
            return HALT;
        } else if (m_bRequestedChallenge &&
                   sMessage.Token(0).Equals("CHALLENGE")) {
            m_bRequestedChallenge = false;
            if (sMessage.find("not available once you have authed") !=
                CString::npos) {
                m_bAuthed = true;
            } else {
                if (sMessage.find("HMAC-SHA-256") != CString::npos) {
                    ChallengeAuth(sMessage.Token(1));
                } else {
                    PutModule(
                        "Auth failed: Q does not support HMAC-SHA-256 for "
                        "CHALLENGEAUTH, falling back to standard AUTH.");
                    SetUseChallenge(false);
                    Auth();
                }
            }
            return HALT;
        }

        // prevent buffering of Q's responses
        return !m_bCatchResponse && GetUser()->IsUserAttached() ? CONTINUE
                                                                : HALT;
    }
Example #15
0
	virtual void OnPart(const CNick& Nick, CChan& Channel, const CString& sMessage) {
		PutModule("* Parts: " + Nick.GetNick() + " (" + Nick.GetIdent() + "!" + Nick.GetHost() + ")");
	}
Example #16
0
	virtual void OnJoin(const CNick& Nick, CChan& Channel) {
		PutModule("* Joins: " + Nick.GetNick() + " (" + Nick.GetIdent() + "!" + Nick.GetHost() + ")");
	}
Example #17
0
	virtual void OnQuit(const CNick& Nick, const CString& sMessage, const vector<CChan*>& vChans) {
		PutModule("* Quits: " + Nick.GetNick() + " (" + Nick.GetIdent() + "!" + Nick.GetHost() + ") (" + sMessage + ")");
	}
Example #18
0
File: log.cpp Project: Adam-/znc
void CLogMod::OnJoin(const CNick& Nick, CChan& Channel) {
    if (!HasNV("joins") || GetNV("joins").ToBool())
        PutLog("*** Joins: " + Nick.GetNick() + " (" + Nick.GetIdent() + "@" +
                   Nick.GetHost() + ")",
               Channel);
}