virtual void OnModCommand(const CString& sLine) { CString sCommand = sLine.Token(0); if (sCommand.Equals("cd")) { CString sArg = sLine.Token(1, true); CString sPath = CDir::ChangeDir(m_sPath, (sArg.empty() ? CString(CZNC::Get().GetHomePath()) : sArg), CZNC::Get().GetHomePath()); CFile Dir(sPath); if (Dir.IsDir()) { m_sPath = sPath; } else if (Dir.Exists()) { PutShell("cd: not a directory [" + sPath + "]"); } else { PutShell("cd: no such directory [" + sPath + "]"); } PutShell("znc$"); } else if (sCommand.Equals("SEND")) { CString sToNick = sLine.Token(1); CString sFile = sLine.Token(2); if ((sToNick.empty()) || (sFile.empty())) { PutShell("usage: Send <nick> <file>"); } else { sFile = CDir::ChangeDir(m_sPath, sFile, CZNC::Get().GetHomePath()); if (!CFile::Exists(sFile)) { PutShell("get: no such file [" + sFile + "]"); } else if (!CFile::IsReg(sFile)) { PutShell("get: not a file [" + sFile + "]"); } else { m_pUser->SendFile(sToNick, sFile, GetModName()); } } } else if (sCommand.Equals("GET")) { CString sFile = sLine.Token(1); if (sFile.empty()) { PutShell("usage: Get <file>"); } else { sFile = CDir::ChangeDir(m_sPath, sFile, CZNC::Get().GetHomePath()); if (!CFile::Exists(sFile)) { PutShell("get: no such file [" + sFile + "]"); } else if (!CFile::IsReg(sFile)) { PutShell("get: not a file [" + sFile + "]"); } else { m_pUser->SendFile(m_pUser->GetCurNick(), sFile, GetModName()); } } } else { RunCommand(sLine); } }
virtual void OnModCommand(const CString& sLine) { CString sCommand = sLine.Token(0); if (sCommand.Equals("cd")) { CString sArg = sLine.Token(1, true); CString sPath = CDir::ChangeDir(m_sPath, (sArg.empty() ? CString(CZNC::Get().GetHomePath()) : sArg), CZNC::Get().GetHomePath()); CFile Dir(sPath); if (Dir.IsDir()) { m_sPath = sPath; } else if (Dir.Exists()) { PutShell("cd: not a directory [" + sPath + "]"); } else { PutShell("cd: no such directory [" + sPath + "]"); } PutShell("znc$"); } else { RunCommand(sLine); } }