📄 commandsatof.cpp
字号:
ReplaceVariables(strGroup);
if (strName.IsEmpty() || strGroup.IsEmpty())
return;
if (strGroup.GetLength() > 15)
{
PrintMessage("Group name cannot be more than 15 characters.");
return;
}
BOOL bResult;
int nIndex = atoi(strName);
if (!nIndex)
bResult = _chat.AddGroup(strName,strGroup);
else
bResult = _chat.AddGroup(nIndex-1,strGroup);
if (!bResult)
PrintMessage("Chat name not found.");
else
PrintMessage("Chat group set.");
}
void ChatIgnore(CString &strLine)
{
CString strName;
FindStatement(strLine,strName);
ReplaceVariables(strName);
CHAT *pChat;
int nIndex = atoi(strName);
if (!nIndex)
pChat = _chat.FindName(strName);
else
pChat = _chat.GetAt(nIndex-1);
if (pChat == NULL)
{
PrintMessage("Chat name not found.");
return;
}
if (pChat->bIgnore)
{
CString strText;
strText.Format("No longer ignoring %s.",(const char *)pChat->strName);
PrintMessage(strText);
pChat->bIgnore = FALSE;
}
else
{
CString strText;
strText.Format("Now ignoring %s.",(const char *)pChat->strName);
PrintMessage(strText);
pChat->bIgnore = TRUE;
}
}
void ChatIgnoreAll(CString &strLine)
{
BOOL bValue = _chat.GetIgnoreAll();
if (bValue)
{
bValue = FALSE;
PrintMessage("No longer ignoring general chats and emotes.");
}
else
{
bValue = TRUE;
PrintMessage("Now ignoring general chats chats and emotes.");
}
_chat.SetIgnoreAll(bValue);
}
void ChatName(CString &strLine)
{
CString strName;
FindStatement(strLine,strName);
ReplaceVariables(strName);
if (strName.GetLength() > 30)
{
PrintMessage("Chat name cannot be more than 30 characters.");
return;
}
strName.TrimRight();
if (strName.IsEmpty())
return;
// Only allow alpha numerics in the name.
int nLen = strName.GetLength();
for (int i=0;i<nLen;i++)
if ((unsigned char)strName[i] < 32 || (unsigned char)strName[i]>122)
break;
if (i != nLen)
{
PrintMessage("You can only use letters and numbers in your chat name.");
return;
}
// Only change it if it is different.
if (strName == _chat.GetChatName())
return;
_chat.SetChatName(strName);
CString strText;
strText.Format("Chat name changed: %s",(const char *)strName);
PrintMessage(strText);
_chat.BroadcastNameChange(strName);
}
void ChatPrivate(CString &strLine)
{
CString strName;
FindStatement(strLine,strName);
ReplaceVariables(strName);
CHAT *pChat;
int nIndex = atoi(strName);
if (!nIndex)
pChat = _chat.FindName(strName);
else
pChat = _chat.GetAt(nIndex-1);
if (pChat == NULL)
{
PrintMessage("Chat name not found.");
return;
}
if (pChat->bPrivate)
{
CString strText;
strText.Format("%s marked as public.",(const char *)pChat->strName);
PrintMessage(strText);
pChat->bPrivate = FALSE;
strText.Format("\n<CHAT> %s has marked your connection public.\n",
(const char *)_chat.GetChatName());
_chat.SendMessage(pChat,strText);
}
else
{
CString strText;
strText.Format("%s marked as private.",(const char *)pChat->strName);
PrintMessage(strText);
pChat->bPrivate = TRUE;
strText.Format("\n<CHAT> %s has marked your connection private.\n",
(const char *)_chat.GetChatName());
_chat.SendMessage(pChat,strText);
}
}
void ChatServe(CString &strLine)
{
CString strName;
FindStatement(strLine,strName);
ReplaceVariables(strName);
CHAT *pChat;
int nIndex = atoi(strName);
if (!nIndex)
pChat = _chat.FindName(strName);
else
pChat = _chat.GetAt(nIndex-1);
if (pChat == NULL)
{
PrintMessage("Chat name not found.");
return;
}
if (pChat->bServe)
{
CString strText;
strText.Format("%s is no longer being served.",(const char *)pChat->strName);
PrintMessage(strText);
pChat->bServe = FALSE;
strText.Format("\n<CHAT> You are no longer being ChatServed by %s.\n",
(const char *)_chat.GetChatName());
_chat.SendMessage(pChat,strText);
}
else
{
CString strText;
strText.Format("%s is being served.",(const char *)pChat->strName);
PrintMessage(strText);
pChat->bServe = TRUE;
strText.Format("\n<CHAT> You are now being ChatServed by %s.\n",
(const char *)_chat.GetChatName());
_chat.SendMessage(pChat,strText);
}
}
void ChatSnoop(CString &strLine)
{
CString strName;
FindStatement(strLine,strName);
ReplaceVariables(strName);
CHAT *pChat;
int nIndex = atoi(strName);
if (!nIndex)
pChat = _chat.FindName(strName);
else
pChat = _chat.GetAt(nIndex-1);
if (pChat == NULL)
{
PrintMessage("Chat name not found.");
return;
}
if (pChat->bAllowSnoop)
{
CString strText;
strText.Format("%s is no longer allowed to snoop you.",(const char *)pChat->strName);
PrintMessage(strText);
pChat->bAllowSnoop = FALSE;
pChat->bSnooped = FALSE;
strText.Format("\n<CHAT> You are no longer allowed to snoop %s.\n",
(const char *)_chat.GetChatName());
_chat.SendMessage(pChat,strText);
}
else
{
CString strText;
strText.Format("%s is now allowed to snoop you.",(const char *)pChat->strName);
PrintMessage(strText);
pChat->bAllowSnoop = TRUE;
strText.Format("\n<CHAT> You are now allowed to snoop %s.\n",
(const char *)_chat.GetChatName());
_chat.SendMessage(pChat,strText);
}
}
void ChatTransfers(CString &strLine)
{
CString strName;
FindStatement(strLine,strName);
ReplaceVariables(strName);
CHAT *pChat;
int nIndex = atoi(strName);
if (!nIndex)
pChat = _chat.FindName(strName);
else
pChat = _chat.GetAt(nIndex-1);
if (pChat == NULL)
{
PrintMessage("Chat name not found.");
return;
}
if (pChat->bTransfers)
{
CString strText;
strText.Format("%s is no longer allowed to send you files.",(const char *)pChat->strName);
PrintMessage(strText);
pChat->bTransfers = FALSE;
strText.Format("\n<CHAT> %s is no longer accepting file transfers from you.\n",
(const char *)_chat.GetChatName());
_chat.SendMessage(pChat,strText);
}
else
{
CString strText;
strText.Format("%s is allowed to send you files.",(const char *)pChat->strName);
PrintMessage(strText);
pChat->bTransfers = TRUE;
strText.Format("\n<CHAT> %s is accepting file transfers from you.\n",
(const char *)_chat.GetChatName());
_chat.SendMessage(pChat,strText);
}
}
void ChatVersions(CString &strLine)
{
PrintMessage("Chat Connections:\n");
CommandPrintOn();
_terminal.Print(" Name Version\n");
_terminal.Print(" ============================== ==============================\n");
CString strText;
int nLineCount = 1;
int nNumLines = _terminal.GetWindowLines()-2;
int nInc;
CHAT *pChat = _chat.GetFirst();
while(pChat != NULL)
{
if (pChat->nDndId == 0)
{
strText.Format("%s%03d:%s %-30s %s\n",
ANSI_F_BOLDWHITE,
_chat.GetFindIndex()+1,
ANSI_RESET,
(const char *)pChat->strName,
(const char *)pChat->strVersion);
_terminal.Print(strText);
if (_config.bPause)
{
nInc = strText.GetLength() / 80 + 1;
nLineCount += nInc;
if (nLineCount >= nNumLines)
if (PausePrompt())
nLineCount = 0;
else
break;
}
}
pChat = _chat.GetNext();
}
CommandPrintOff();
}
void CheckVersion(CString &strLine)
{
CString strCheck;
FindStatement(strLine,strCheck);
ReplaceVariables(strCheck);
if (strCheck.IsEmpty())
{
if (_config.bCheckVersion)
_config.bCheckVersion = FALSE;
else
_config.bCheckVersion = TRUE;
}
else
{
strCheck.MakeLower();
if (strCheck.Left(2) == "on")
_config.bCheckVersion = TRUE;
else
_config.bCheckVersion = FALSE;
}
strCheck.Format("Version checking is now %s.",
(_config.bCheckVersion ? "On" : "Off"));
PrintMessage(strCheck);
WriteIniInt("Miscellaneous","CheckVersion",_config.bCheckVersion);
}
void ClearList(CString &strLine)
{
CString strListName;
FindStatement(strLine,strListName);
ReplaceVariables(strListName);
if (strListName.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;
pList->mapList.RemoveAll();
if (_config.bItemMessages)
PrintMessage("List Cleared.");
}
void CR(CString &strLine)
{
if (_config.bEcho)
_terminal.Print("\n");
SendText("\r");
}
void DebugDepth(CString &strLine)
{
CString strNum;
FindStatement(strLine,strNum);
ReplaceVariables(strNum);
if (strNum.IsEmpty())
return;
int nNum;
nNum = atoi(strNum);
if (nNum < 0 || nNum > STACK_DEPTH)
return;
CString strText;
strText.Format("The debug depth has been set to %d.",nNum);
PrintMessage(strText);
WriteIniInt("Miscellaneous","Debug Depth",nNum);
}
void DebugMessages(CString &strLine)
{
if (_config.bDebugMessages)
{
PrintMessage("Debug messages are now disabled.");
_config.bDebugMessages = FALSE;
}
else
{
PrintMessage("Debug messages are now enabled.");
_config.bDebugMessages = TRUE;
}
WriteIniInt("Miscellaneous","Debug Messages",_config.bDebugMessages);
}
void Default(CString &strLine)
{
CString strFile;
FindStatement(strLine,strFile);
ReplaceVariables(strFile);
if (strFile.IsEmpty())
return;
CString strText;
strText.Format("Default command file set: %s",(const char *)strFile);
PrintMessage(strText);
WriteIniString("Miscellaneous","Default File",strFile);
}
void Dir(CString &strLine)
{
CString strMask, strList;
FindStatement(strLine,strMask);
FindStatement(strLine,strList);
ReplaceVariables(strMask);
ReplaceVariables(strList);
if (strMask.IsEmpty() || strList.IsEmpty())
return;
// Remove the current list if it exists and re-add it.
_lists.RemoveList(strList);
USER_LIST *pList = new USER_LIST;
pList->strListName = strList;
_lists.AddList(pList);
CString strFileData;
CString strName;
CString strFileSize;
CString strDate;
CString strTime;
int nHour;
FILETIME ftLocal;
SYSTEMTIME stCreated;
int nFileCount = 0;
unsigned long nTotalBytes = 0;
unsigned long nFileSize;
WIN32_FIND_DATA fd;
HANDLE hSearch = FindFirstFile(strMask,&fd);
BOOL bResult = (hSearch != INVALID_HANDLE_VALUE);
while(bResult)
{
nFileCount++;
nFileSize = (fd.nFileSizeHigh * MAXDWORD) + fd.nFileSizeLow;
nTotalBytes += nFileSize;
// Conver file size.
strFileSize.Format("%lu",nFileSize);
Commatize(strFileSize);
// Filename.
strName = fd.cFileName;
if (strName.GetLength() > 20)
strName = strName.Left(20);
strFileData.Format("%-20s %11s ",
(const char *)strName,
(const char *)strFileSize);
// File date and time.
FileTimeToLocalFileTime(&fd.ftCreationTime,&ftLocal);
FileTimeToSystemTime(&ftLocal,&stCreated);
strDate.Format("%02d-%02d-%4d",
stCreated.wMonth,
stCreated.wDay,
stCreated.wYear);
nHour = stCreated.wHour;
if (nHour > 12)
nHour -= 12;
if (!nHour)
nHour++;
strTime.Format(" %02d:%02d%c",
nHour,
stCreated.wMinute,
(nHour > 11 ? 'p' : 'a'));
strFileData += strDate + strTime;
pList->mapList.Add(strFileData,"","");
bResult = FindNextFile(hSearch,&fd);
}
strFileData.Format("
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -