Beispiel #1
0
    EModRet OnUserRaw(CString& sLine) override {
        // Handle ISON
        if (sLine.Token(0).Equals("ison")) {
            VCString vsNicks;

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

            CString sBNCNicks;
            for (const CString& sNick : vsNicks) {
                if (IsOnlineModNick(sNick)) {
                    sBNCNicks += " " + sNick;
                }
            }
            // Remove the leading space
            sBNCNicks.LeftChomp();

            if (!GetNetwork()->GetIRCSock()) {
                // if we are not connected to any IRC server, send
                // an empty or module-nick filled response.
                PutUser(":irc.znc.in 303 " + GetClient()->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)) {
                CIRCNetwork* pNetwork = GetNetwork();
                PutUser(":znc.in 311 " + pNetwork->GetCurNick() + " " + sNick +
                        " znc znc.in * :" + sNick);
                PutUser(":znc.in 312 " + pNetwork->GetCurNick() + " " + sNick +
                        " *.znc.in :Bouncer");
                PutUser(":znc.in 318 " + pNetwork->GetCurNick() + " " + sNick +
                        " :End of /WHOIS list.");

                return HALT;
            }
        }

        return CONTINUE;
    }
Beispiel #2
0
	virtual void OnModCTCP(const CString& sMessage) {
		if (sMessage.Equals("DCC RESUME ", false, 11)) {
			CString sFile = sMessage.Token(2);
			unsigned short uResumePort = sMessage.Token(3).ToUShort();
			unsigned long uResumeSize = sMessage.Token(4).ToULong();

			set<CSocket*>::const_iterator it;
			for (it = BeginSockets(); it != EndSockets(); ++it) {
				CDCCSock* pSock = (CDCCSock*) *it;

				if (pSock->GetLocalPort() == uResumePort) {
					if (pSock->Seek(uResumeSize)) {
						PutModule("DCC -> [" + pSock->GetRemoteNick() + "][" + pSock->GetFileName() + "] - Attempting to resume from file position [" + CString(uResumeSize) + "]");
						PutUser(":*[email protected] PRIVMSG " + m_pUser->GetNick() + " :\001DCC ACCEPT " + sFile + " " + CString(uResumePort) + " " + CString(uResumeSize) + "\001");
					} else {
						PutModule("DCC -> [" + m_pUser->GetNick() + "][" + sFile + "] Unable to find send to initiate resume.");
					}
				}

			}
		} else if (sMessage.Equals("DCC SEND ", false, 9)) {
			CString sLocalFile = CDir::CheckPathPrefix(GetSavePath(), sMessage.Token(2));
			if (sLocalFile.empty()) {
				PutModule("Bad DCC file: " + sMessage.Token(2));
			}
			unsigned long uLongIP = sMessage.Token(3).ToULong();
			unsigned short uPort = sMessage.Token(4).ToUShort();
			unsigned long uFileSize = sMessage.Token(5).ToULong();
			GetFile(m_pUser->GetCurNick(), CUtils::GetIP(uLongIP), uPort, sLocalFile, uFileSize);
		}
	}
Beispiel #3
0
	virtual EModRet OnUserRaw(CString& sLine) {
		// We dont care if we are not connected to IRC
		if (!m_pNetwork->IsIRCConnected())
			return CONTINUE;

		// We are trying to get the config nick and this is a /nick?
		if (!m_pTimer || !sLine.Token(0).Equals("NICK"))
			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.Equals(GetNick()))
			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_pNetwork->GetIRCServer() + " 433 " + m_pNetwork->GetIRCNick().GetNick()
				+ " " + sNick + " :ZNC is already trying to get this nickname");
		return CONTINUE;
	}
Beispiel #4
0
	void ReplayCommand(const CString& sCommand) {
		CString nick = GetClient()->GetNick();
		for (u_int a = 0; a < m_vMessages.size(); a++) {
			CString sWhom = m_vMessages[a].Token(1, false, ":");
			CString sMessage = m_vMessages[a].Token(2, true, ":");
			PutUser(":" + sWhom + " PRIVMSG " + nick + " :" + sMessage);
		}
	}
Beispiel #5
0
	void Replay(const CString & sChan)
	{
		CString sFile;
		PutUser(":***[email protected] PRIVMSG " + sChan + " :Buffer Playback...");
		if (DecryptChannel(sChan, sFile))
		{
			VCString vsLines;
			VCString::iterator it;

			sFile.Split("\n", vsLines);

			for (it = vsLines.begin(); it != vsLines.end(); ++it) {
				CString sLine(*it);
				sLine.Trim();
				PutUser(sLine);
			}
		}
		PutUser(":***[email protected] PRIVMSG " + sChan + " :Playback Complete.");
	}
Beispiel #6
0
void TwitchTMI::PutUserChanMessage(CChan *chan, const CString &from, const CString &msg)
{
	std::stringstream ss;
	ss << ":" << from << " PRIVMSG " << chan->GetName() << " :";
	CString s = ss.str();

	PutUser(s + msg);

	if(!chan->AutoClearChanBuffer() || !GetNetwork()->IsUserOnline() || chan->IsDetached())
		chan->AddBuffer(s + "{text}", msg);
}
Beispiel #7
0
bool CUser::PutAllUser(const CString& sLine, CClient* pClient, CClient* pSkipClient) {
	PutUser(sLine, pClient, pSkipClient);

	for (vector<CIRCNetwork*>::iterator it = m_vIRCNetworks.begin(); it != m_vIRCNetworks.end(); ++it) {
		CIRCNetwork* pNetwork = *it;
		if (pNetwork->PutUser(sLine, pClient, pSkipClient)) {
			return true;
		}
	}

	return (pClient == NULL);
}
	void OnIRCDisconnected()
	{
		const vector<CChan*>& vChans = m_pUser->GetChans();

		for(vector<CChan*>::const_iterator it = vChans.begin(); it != vChans.end(); ++it)
		{
			if((*it)->IsOn()) {
				PutUser(":[email protected] KICK " + (*it)->GetName() + " " + m_pUser->GetIRCNick().GetNick()
					+ " :You have been disconnected from the IRC server");
			}
		}
	}
Beispiel #9
0
	virtual void OnIRCConnected()
	{
		// dropped this into here because there seems to have been a changed where the module is loaded before the channels.
		// this is a good trigger to tell it to backfill the channels
		if( !m_bFirstLoad )
		{
			m_bFirstLoad = true;
			AddTimer(new CSaveBuffJob(this, 60, 0, "SaveBuff", "Saves the current buffer to disk every 1 minute"));
			const vector<CChan *>& vChans = m_pUser->GetChans();
			for (u_int a = 0; a < vChans.size(); a++)
			{
				if (!vChans[a]->KeepBuffer())
					continue;

				if (!BootStrap(vChans[a]))
				{
					PutUser(":***[email protected] PRIVMSG " + vChans[a]->GetName() + " :Failed to decrypt this channel, did you change the encryption pass?");
				}
			}
		}
	}
Beispiel #10
0
bool CUser::SendFile(const CString& sRemoteNick, const CString& sFileName, const CString& sModuleName) {
	CString sFullPath = CDir::ChangeDir(GetDLPath(), sFileName, CZNC::Get().GetHomePath());
	CDCCSock* pSock = new CDCCSock(this, sRemoteNick, sFullPath, sModuleName);

	CFile* pFile = pSock->OpenFile(false);

	if (!pFile) {
		delete pSock;
		return false;
	}

	unsigned short uPort = CZNC::Get().GetManager().ListenRand("DCC::LISTEN::" + sRemoteNick, GetLocalDCCIP(), false, SOMAXCONN, pSock, 120);

	if (GetNick().Equals(sRemoteNick)) {
		PutUser(":" + GetStatusPrefix() + "[email protected] PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString(CUtils::GetLongIP(GetLocalDCCIP())) + " "
				+ CString(uPort) + " " + CString(pFile->GetSize()) + "\001");
	} else {
		PutIRC("PRIVMSG " + sRemoteNick + " :\001DCC SEND " + pFile->GetShortName() + " " + CString(CUtils::GetLongIP(GetLocalDCCIP())) + " "
			    + CString(uPort) + " " + CString(pFile->GetSize()) + "\001");
	}

	PutModule(sModuleName, "DCC -> [" + sRemoteNick + "][" + pFile->GetShortName() + "] - Attempting Send.");
	return true;
}
Beispiel #11
0
 void HandleMessage(CNick& Nick, const CString& sMessage) {
         // Flip the NOTICE into PRIVMSG
         PutUser(":" + Nick.GetNickMask() + " PRIVMSG " + GetUser()->GetNick() + " :" + sMessage);
 }
	void SendSkypeMsgToIRC(const CReceivedSkypeMsg *a_msg)
	{
		CString l_msgBuffer;

		if(a_msg->timestamp < time(0) - 120 && !a_msg->edited)
		{
			char l_timeBuf[100];
			strftime(l_timeBuf, 100, "[%a %H:%M:%S] ", localtime(&a_msg->timestamp));
			l_msgBuffer = l_timeBuf;
		}

		if(!a_msg->edited)
		{
			if(a_msg->type == "EMOTED")
			{
				l_msgBuffer += a_msg->fromDispname + " ";
			}
			else
			{
				l_msgBuffer += "<" + a_msg->fromDispname + "> ";
			}

			l_msgBuffer += a_msg->body;
		}
		else
		{
			char l_timeBuf[100];
			strftime(l_timeBuf, 100, "%H:%M:%S", localtime(&a_msg->timestamp));

			if(a_msg->body == "[deleted]")
			{
				l_msgBuffer += "(" + a_msg->fromDispname + " deleted their message from " + CString(l_timeBuf) + ")";
			}
			else
			{
				l_msgBuffer += a_msg->fromDispname + " edited their message from " + CString(l_timeBuf) + ": " + a_msg->body;
			}
		}

		l_msgBuffer.Replace("\r", "");
		l_msgBuffer.Replace("\n", " ");

		for(MCString::iterator it = m_chanNameMap.begin(); it != m_chanNameMap.end(); it++)
		{
			if(it->second.Equals(a_msg->chatName))
			{
				std::wstring l_buffer = Utf8ToWide(l_msgBuffer);
				std::wstring l_line;
				CString l_utfLine;

				do
				{
					l_line = l_buffer.substr(0, 400);
					l_buffer.erase(0, 400);

					if(!l_buffer.empty())
					{
						l_line += L"...";
						l_buffer = L"..." + l_buffer;
					}

					l_utfLine = WideToUtf8(l_line);

					PutIRC("PRIVMSG " + it->first + " :" + l_utfLine);
					PutUser(":" + m_pUser->GetIRCNick().GetNick() + "!x@y PRIVMSG " + it->first + " :" + l_utfLine);
				} while(!l_buffer.empty());

				return;
			}
		}

		PutModule("WARNING: Group chat " + a_msg->chatName + " not mapped to any channel. A message has been lost.");
	}
Beispiel #13
0
	void PutShell(const CString& sMsg) {
		CString sPath = m_sPath.Replace_n(" ", "_");
		CString sSource = ":" + GetModNick() + "!shell@" + sPath;
		CString sLine = sSource + " PRIVMSG " + m_pUser->GetCurNick() + " :" + sMsg;
		PutUser(sLine);
	}
Beispiel #14
0
	virtual void OnClientLogin() {
		PutUser(":irc.znc.in 422 :MOTD File is missing");
	}