mirror of
https://github.com/znc/znc.git
synced 2026-07-05 01:11:53 +02:00
Move dcc file transfers to their own module
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user