Move dcc file transfers to their own module

This commit is contained in:
Kyle Fuller
2011-05-30 22:24:40 +01:00
parent 8f508cb4a5
commit 16047eaf81
9 changed files with 479 additions and 559 deletions
-43
View File
@@ -85,54 +85,11 @@ public:
}
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 OnModCTCP(const CString& sMessage) {
if (sMessage.Equals("DCC SEND ", false, 9)) {
CString sLocalFile = CDir::ChangeDir(m_sPath, sMessage.Token(2), CZNC::Get().GetHomePath());
unsigned long uLongIP = sMessage.Token(3).ToULong();
unsigned short uPort = sMessage.Token(4).ToUShort();
unsigned long uFileSize = sMessage.Token(5).ToULong();
m_pUser->GetFile(m_pUser->GetCurNick(), CUtils::GetIP(uLongIP), uPort, sLocalFile, uFileSize, GetModName());
}
}
void PutShell(const CString& sMsg) {
CString sPath = m_sPath.Replace_n(" ", "_");
CString sSource = ":" + GetModNick() + "!shell@" + sPath;