Example #1
0
	void FilterIncoming(const CString& sTarget, CNick& Nick, CString& sMessage) {
		if (sMessage.Left(5) == "+OK *") {
			MCString::iterator it = FindNV(sTarget.AsLower());

			if (it != EndNV()) {
				sMessage.LeftChomp(5);
				sMessage.Base64Decode();
				sMessage.Decrypt(it->second);
				sMessage.LeftChomp(8);
				sMessage = sMessage.c_str();
				Nick.SetNick("\244" + Nick.GetNick());
			}
		}

	}
Example #2
0
	virtual EModRet OnUserMsg(CString& sTarget, CString& sMessage) {
		sTarget.TrimLeft("\244");

		if (sMessage.Left(2) == "``") {
			sMessage.LeftChomp(2);
			return CONTINUE;
		}

		MCString::iterator it = FindNV(sTarget.AsLower());

		if (it != EndNV()) {
			CChan* pChan = m_pUser->FindChan(sTarget);
			if (pChan) {
				if (pChan->KeepBuffer())
					pChan->AddBuffer(":\244" + m_pUser->GetIRCNick().GetNickMask() + " PRIVMSG " + sTarget + " :" + sMessage);
				m_pUser->PutUser(":\244" + m_pUser->GetIRCNick().GetNickMask() + " PRIVMSG " + sTarget + " :" + sMessage, NULL, m_pClient);
			}

			CString sMsg = MakeIvec() + sMessage;
			sMsg.Encrypt(it->second);
			sMsg.Base64Encode();
			sMsg = "+OK *" + sMsg;

			PutIRC("PRIVMSG " + sTarget + " :" + sMsg);
			return HALTCORE;
		}

		return CONTINUE;
	}
Example #3
0
    CString ParsePerform(const CString& sArg) const {
        CString sPerf = sArg;

        if (sPerf.Left(1) == "/") sPerf.LeftChomp();

        if (sPerf.Token(0).Equals("MSG")) {
            sPerf = "PRIVMSG " + sPerf.Token(1, true);
        }

        if ((sPerf.Token(0).Equals("PRIVMSG") ||
             sPerf.Token(0).Equals("NOTICE")) &&
            sPerf.Token(2).Left(1) != ":") {
            sPerf = sPerf.Token(0) + " " + sPerf.Token(1) + " :" +
                    sPerf.Token(2, true);
        }

        return sPerf;
    }
Example #4
0
    virtual EModRet OnUserRaw(CString& sLine) {
        //Handle ISON
        if (sLine.Token(0).Equals("ison")) {
            VCString vsNicks;
            VCString::const_iterator it;

            // Get the list of nicks which are being asked for
            sLine.Token(1, true).TrimLeft_n(":").Split(" ", vsNicks, false);

            CString sBNCNicks;
            for (it = vsNicks.begin(); it != vsNicks.end(); ++it) {
                if (IsOnlineModNick(*it)) {
                    sBNCNicks += " " + *it;
                }
            }
            // Remove the leading space
            sBNCNicks.LeftChomp();

            if (!m_pNetwork->GetIRCSock()) {
                // if we are not connected to any IRC server, send
                // an empty or module-nick filled response.
                PutUser(":irc.znc.in 303 " + m_pClient->GetNick() + " :" + sBNCNicks);
            } else {
                // We let the server handle this request and then act on
                // the 303 response from the IRC server.
                m_ISONRequests.push_back(sBNCNicks);
            }
        }

        //Handle WHOIS
        if (sLine.Token(0).Equals("whois")) {
            CString sNick = sLine.Token(1);

            if (IsOnlineModNick(sNick)) {
                PutUser(":znc.in 311 " + m_pNetwork->GetCurNick() + " " + sNick + " " + sNick + " znc.in * :" + sNick);
                PutUser(":znc.in 312 " + m_pNetwork->GetCurNick() + " " + sNick + " *.znc.in :Bouncer");
                PutUser(":znc.in 318 " + m_pNetwork->GetCurNick() + " " + sNick + " :End of /WHOIS list.");

                return HALT;
            }
        }

        return CONTINUE;
    }