📄 commandsgtol.cpp
字号:
(const char *)_config.strDownloadPath);
_terminal.Print(strText);
strText.Format(" Uploads: %s\n",
(const char *)_config.strUploadPath);
_terminal.Print(strText);
strText.Format(" Scripts: %s\n",
(const char *)_config.strScriptPath);
_terminal.Print(strText);
strText.Format(" Sounds: %s\n",
(const char *)_config.strSoundPath);
_terminal.Print(strText);
strText.Format(" MSP: %s\n\n",
(const char *)_msp.GetPath());
_terminal.Print(strText);
CommandPrintOff();
return;
}
if (IsPartial(strCommand,"chat"))
{
CommandPrintOn();
strText.Format("\n#%s%s%s Chat%s:\n\n",
ANSI_RESET,
ANSI_BOLD,
ANSI_F_WHITE,
ANSI_RESET);
_terminal.Print(strText);
strText.Format(" Host Name: %s\n",(const char *)_config.strHostName);
_terminal.Print(strText);
strText.Format(" IP Address: %s\n",
(const char *)_config.strIPAddress);
_terminal.Print(strText);
strText.Format(" Listen Port: %d\n",_nListenPort);
_terminal.Print(strText);
strText.Format(" Chat Name: %s\n",(const char *)_chat.GetChatName());
_terminal.Print(strText);
strText.Format("Active Chats: %d\n",_chat.GetCount());
_terminal.Print(strText);
strText.Format(" Auto-Accept: %s\n",
(_config.bAutoAccept ? "On" : "Off"));
_terminal.Print(strText);
strText.Format(" Ignore All: %s\n",
(_chat.GetIgnoreAll() ? "True" : "False"));
_terminal.Print(strText);
strText.Format(" DnD: %s\n\n",
(_config.bDoNotDisturb ? "On" : "Off"));
_terminal.Print(strText);
CommandPrintOff();
return;
}
if (IsPartial(strCommand,"sound"))
{
CommandPrintOn();
strText.Format("\n#%s%s%s Sounds%s:\n\n",
ANSI_RESET,
ANSI_BOLD,
ANSI_F_WHITE,
ANSI_RESET);
_terminal.Print(strText);
CString strTemp;
WAVEOUTCAPS caps;
_sound.GetWaveDeviceCaps(&caps);
strText.Format(" Product: %s\n", caps.szPname);
_terminal.Print(strText);
strText.Format(" Output: %s\n", (caps.wChannels == 1 ? "Mono" : "Stereo"));
_terminal.Print(strText);
if (caps.dwSupport & WAVECAPS_VOLUME)
{
strTemp = "Supported (";
if (caps.dwSupport & WAVECAPS_LRVOLUME)
strTemp += "Stereo)";
else
strTemp += "Mono)";
}
else
strTemp = "Not Supported";
strText.Format(" Volume: %s\n", (const char *)strTemp);
_terminal.Print(strText);
strText.Format(" Volume Level: %d bit\n\n", _sound.GetVolumeBits());
_terminal.Print(strText);
strText.Format(" Cache Size: %d\n", _sound.GetCacheSize());
_terminal.Print(strText);
strText.Format(" Bytes Cached: %d\n", _sound.GetBytesCached());
_terminal.Print(strText);
strText.Format(" Files Cached: %d\n\n", _sound.GetCount());
_terminal.Print(strText);
strText.Format(" Max Volume: %d%%\n",_sound.GetMaxVolume());
_terminal.Print(strText);
strText.Format(" Default Volume: %d%%\n\n",_config.nDefaultVolume);
_terminal.Print(strText);
_terminal.Print("To view files in cache - /info soundcache\n\n");
CommandPrintOff();
return;
}
if (IsPartial(strCommand,"soundcache"))
{
CommandPrintOn();
strText.Format("\n#%s%s%s Sound Cache%s:\n\n",
ANSI_RESET,
ANSI_BOLD,
ANSI_F_WHITE,
ANSI_RESET);
_terminal.Print(strText);
_terminal.Print(" Name Size Bits Freq Chan Pri Volume Hits\n");
_terminal.Print(" ============================== ======= ==== ===== ==== === ========== ====\n");
CString strTemp, strText;
char *ptr;
int nResult;
int nLineCount = 1;
int nNumLines = _terminal.GetWindowLines()-2;
int nInc;
CWave *pWave = _sound.GetFirst();
while(pWave != NULL)
{
if (pWave->m_strFilename.GetLength() > 30)
strTemp = CString("...") + pWave->m_strFilename.Right(27);
else
strTemp = pWave->m_strFilename;
ptr = strText.GetBuffer(strTemp.GetLength()+80);
nResult = sprintf(ptr,"%s%03d:%s %-30s %7d %4d %4.2f %4d %3d 0x%08lx %4d\n",
ANSI_F_BOLDWHITE,
_sound.GetFindIndex()+1,
ANSI_RESET,
(const char *)strTemp,
pWave->m_lSize,
((WAVEFORMATEX *)(pWave->m_pWfx))->wBitsPerSample,
((WAVEFORMATEX *)(pWave->m_pWfx))->nSamplesPerSec / 1000.0,
((WAVEFORMATEX *)(pWave->m_pWfx))->nChannels,
pWave->m_nPriority,
pWave->m_dwVolume,
pWave->m_nHits);
strText.ReleaseBuffer(nResult);
_terminal.Print(strText);
if (_config.bPause)
{
nInc = strText.GetLength() / 80 + 1;
nLineCount += nInc;
if (nLineCount >= nNumLines)
if (PausePrompt())
nLineCount = 0;
else
break;
}
pWave = _sound.GetNext();
}
CommandPrintOff();
return;
}
}
void ItemAdd(CString &strLine)
{
CString strListName, strItem;
FindStatement(strLine,strListName);
FindStatement(strLine,strItem);
ReplaceVariables(strListName);
ReplaceVariables(strItem);
if (strListName.IsEmpty() || strItem.IsEmpty())
return;
BOOL bResult;
int nIndex = atoi(strListName);
if (!nIndex)
bResult = _lists.AddItem(strListName,strItem);
else
bResult = _lists.AddItem(nIndex-1,strItem);
if (bResult && _config.bItemMessages)
PrintMessage("Item Added.");
}
void ItemDelete(CString &strLine)
{
CString strListName, strItem;
FindStatement(strLine,strListName);
FindStatement(strLine,strItem);
ReplaceVariables(strListName);
ReplaceVariables(strItem);
if (strListName.IsEmpty() || strItem.IsEmpty())
return;
USER_LIST *pList;
int nListIndex = atoi(strListName);
if (!nListIndex)
pList = _lists.FindByName(strListName);
else
pList = _lists.GetAt(nListIndex-1);
if (pList == NULL)
return;
BOOL bResult;
int nItemIndex = atoi(strItem);
if (!nItemIndex)
bResult = pList->mapList.Remove(strItem);
else
bResult = pList->mapList.Remove(nItemIndex-1);
if (bResult && _config.bItemMessages)
PrintMessage("Item Deleted.");
}
void ListAdd(CString &strLine)
{
CString strListName, strGroup;
CString strTemp;
int nListNum;
FindStatement(strLine,strListName);
FindStatement(strLine,strGroup);
ReplaceVariables(strListName);
if (strListName.IsEmpty())
return;
// Make sure it doesn't already exist.
USER_LIST *pList = _lists.FindByName(strListName);
if (pList != NULL)
{
pList->strGroup = strGroup;
return;
}
pList = new USER_LIST;
pList->strListName = strListName;
pList->strGroup = strGroup;
nListNum = _lists.AddList(pList);
if (!nListNum)
delete pList;
if (_config.bListMessages)
{
if (nListNum)
{
strTemp.Format("List added as #%d.",nListNum);
PrintMessage(strTemp);
}
else
PrintMessage("List not added.");
}
}
void ListDelete(CString &strLine)
{
CString strListName;
FindStatement(strLine,strListName);
ReplaceVariables(strListName);
if (strListName.IsEmpty())
return;
BOOL bResult;
int nIndex = atoi(strListName);
if (!nIndex)
bResult = _lists.RemoveList(strListName);
else
bResult = _lists.RemoveList(nIndex-1);
if (bResult && _config.bListMessages)
PrintMessage("List Removed.");
}
void ListItems(CString &strLine)
{
CString strListName;
FindStatement(strLine,strListName);
ReplaceVariables(strListName);
if (strListName.IsEmpty())
return;
USER_LIST *pList;
int nIndex = atoi(strListName);
if (!nIndex)
pList = _lists.FindByName(strListName);
else
pList = _lists.GetAt(nIndex-1);
if (pList == NULL)
return;
CString strText;
strText.Format("Items in list %s(%d):",
(const char *)pList->strListName,pList->mapList.GetCount());
PrintMessage(strText);
CommandPrintOn();
char *pBuf;
int nResult;
int nLineCount = 1;
int nNumLines = _terminal.GetWindowLines()-2;
int nInc;
STRING_MAP *pMap = pList->mapList.GetFirst();
while(pMap != NULL)
{
pBuf = strText.GetBuffer(pMap->strKey.GetLength()+30);
nResult = sprintf(pBuf,"%s%03d:%s %s\n",
ANSI_F_BOLDWHITE,
pList->mapList.GetFindIndex()+1,
ANSI_RESET,
(const char *)pMap->strKey);
strText.ReleaseBuffer(nResult);
_terminal.Print(strText);
if (_config.bPause)
{
nInc = strText.GetLength() / 80 + 1;
nLineCount += nInc;
if (nLineCount >= nNumLines)
if (PausePrompt())
nLineCount = 0;
else
break;
}
pMap = pList->mapList.GetNext();
}
CommandPrintOff();
}
void Lists(CString &strLine)
{
PrintMessage("Defined Lists:");
CommandPrintOn();
CString strText;
char *pBuf;
int nResult;
int nLineCount = 1;
int nNumLines = _terminal.GetWindowLines()-2;
int nInc;
USER_LIST *pList = _lists.GetFirst();
while(pList != NULL)
{
pBuf = strText.GetBuffer(pList->strListName.GetLength()+pList->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%s%03d:%s %s(%d) {%s}\n",
ANSI_F_BOLDWHITE,
_lists.GetFindIndex()+1,
ANSI_RESET,
(const char *)pList->strListName,
pList->mapList.GetCount(),
(const char *)pList->strGroup);
strText.ReleaseBuffer(nResult);
_terminal.Print(strText);
if (_config.bPause)
{
nInc = strText.GetLength() / 80 + 1;
nLineCount += nInc;
if (nLineCount >= nNumLines)
if (PausePrompt())
nLineCount = 0;
else
break;
}
pList = _lists.GetNext();
}
CommandPrintOff();
}
void LogClose(CString &strLine)
{
if (!_bLogOpen)
return;
_logFile.Close();
_bLogOpen = FALSE;
if (_logFile.IsOpen())
PrintMessage("Failed to close log file.");
else
PrintMessage("Log file closed.");
}
void LogOpen(CString &strLine)
{
if (_bLogOpen)
{
PrintMessage("Already logging to a file.");
return;
}
CString strFilename;
FindStatement(strLine,strFilename);
ReplaceVariables(strFilename);
if (strFilename.IsEmpty())
{
PrintMessage("Need a filename.");
return;
}
if (_logFile.Open(strFilename))
{
_bLogOpen = TRUE;
PrintMessage("Log file open.");
}
else
PrintMessage("Failed to open log file.");
}
void LogOpenAppend(CString &strLine)
{
if (_bLogOpen)
{
PrintMessage("Already logging to a file.");
return;
}
CString strFilename;
FindStatement(strLine,strFilename);
ReplaceVariables(strFilename);
if (strFilename.IsEmpty())
{
PrintMessage("Need a filename.");
return;
}
if (_logFile.Open(strFilename,TRUE))
{
_bLogOpen = TRUE;
PrintMessage("Log file open.");
}
else
PrintMessage("Failed to open log file.");
}
void LogStatus(CString &strLine)
{
if (!_bLogOpen)
return;
CString strText;
strText.Format("Filename: %s, Bytes Written: %ld",
(const char *)_logFile.GetFilename(),
_logFile.GetBytesWritten());
PrintMessage(strText);
}
void Loop(CString &strLine)
{
CString strRange, strCommand;
FindStatement(strLine,strRange);
FindStatement(strLine,strCommand);
if (strRange.IsEmpty() || strCommand.IsEmpty())
return;
ReplaceVariables(strRange);
char *pBuf = new char[strRange.GetLength()+1];
strcpy(pBuf,strRange);
char *ptr = strtok(pBuf,",");
if (ptr == NULL)
{
delete [] pBuf;
return;
}
int nStart = atoi(ptr);
ptr = strtok(NULL,",");
if (ptr == NULL)
{
delete [] pBuf;
return;
}
int nEnd = atoi(ptr);
ptr = strtok(NULL,",");
CString strVar(ptr);
char szNum[20];
CString strTemp;
if (nEnd >= nStart)
{
for (int i=nStart;i<=nEnd;i++)
{
if (strVar.IsEmpty())
_nLoopCount = i;
else
{
itoa(i,szNum,10);
_mapVars.Add(strVar,szNum,"");
}
strTemp = strCommand;
HandleInput(strTemp);
}
}
else
{
for (int i=nStart;i>=nEnd;i--)
{
if (strVar.IsEmpty())
_nLoopCount = i;
else
{
itoa(i,szNum,10);
_mapVars.Add(strVar,szNum,"");
}
strTemp = strCommand;
HandleInput(strTemp);
}
}
if (!strVar.IsEmpty())
_mapVars.Remove(strVar);
delete [] pBuf;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -