📄 commandsstoz.cpp
字号:
while(pEvent != NULL)
{
if (pEvent->strGroup == strGroup)
{
pBuf = strText.GetBuffer(pEvent->strName.GetLength()+pEvent->strEvent.GetLength()+pEvent->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%cevent {%s} {%d} {%s} {%s}",_config.chCommand,
(const char *)pEvent->strName,
pEvent->nSeconds,
(const char *)pEvent->strEvent,
(const char *)pEvent->strGroup);
strText.ReleaseBuffer(nResult);
if (nIndex)
_chat.SendCommand(CHAT_SEND_EVENT,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_EVENT,strPerson,strText);
nEvents++;
}
pEvent = _events.GetNext();
}
int nGags = 0;
GAG *pGag = _gags.GetFirst();
while(pGag != NULL)
{
if (pGag->strGroup == strGroup)
{
_gags.GagToMask(pGag,strTemp);
pBuf = strText.GetBuffer(strTemp.GetLength()+pGag->strGroup.GetLength()+30);
nResult = sprintf(pBuf,"%cgag {%s} {%s}",
_config.chCommand,
(const char *)strTemp,
(const char *)pGag->strGroup);
strText.ReleaseBuffer(nResult);
if (nIndex)
_chat.SendCommand(CHAT_SEND_GAG,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_GAG,strPerson,strText);
nGags++;
}
pGag = _gags.GetNext();
}
CString strColor;
int nHighs = 0;
HIGHLIGHT *pHigh = _highlights.GetFirst();
while(pHigh != NULL)
{
if (pHigh->strGroup == strGroup)
{
_highlights.HighlightToMask(pHigh,strTemp);
_highlights.AttrToText(pHigh->wAttr,strColor);
pBuf = strText.GetBuffer(strTemp.GetLength()+strColor.GetLength()+pHigh->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%chighlight {%s} {%s} {%s}",
_config.chCommand,
(const char *)strTemp,
(const char *)strColor,
(const char *)pHigh->strGroup);
strText.ReleaseBuffer(nResult);
if (nIndex)
_chat.SendCommand(CHAT_SEND_HIGHLIGHT,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_HIGHLIGHT,strPerson,strText);
nHighs++;
}
pHigh = _highlights.GetNext();
}
int nSubs = 0;
SUB *pSub = _subs.GetFirst();
while(pSub != NULL)
{
if (pSub->strGroup == strGroup)
{
_subs.SubToTrigger(pSub,strTemp);
pBuf = strText.GetBuffer(strTemp.GetLength()+pSub->strSub.GetLength()+pSub->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%csubstitute {%s} {%s} {%s}\n",
_config.chCommand,
(const char *)strTemp,
(const char *)pSub->strSub,
(const char *)pSub->strGroup);
strText.ReleaseBuffer(nResult);
if (nIndex)
_chat.SendCommand(CHAT_SEND_SUBSTITUTE,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_SUBSTITUTE,strPerson,strText);
nSubs++;
}
pSub = _subs.GetNext();
}
int nLists = 0;
USER_LIST *pList = _lists.GetFirst();
while(pList != NULL)
{
if (pList->strGroup == strGroup)
{
pBuf = strText.GetBuffer(pList->strListName.GetLength()+pList->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%clistadd {%s} {%s}",_config.chCommand,
(const char *)pList->strListName,
(const char *)pList->strGroup);
strText.ReleaseBuffer(nResult);
if (nIndex)
_chat.SendCommand(CHAT_SEND_LIST,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_LIST,strPerson,strText);
// Write the items in the list out.
pStringMap = pList->mapList.GetFirst();
while(pStringMap != NULL)
{
pBuf = strText.GetBuffer(pList->strListName.GetLength()+pStringMap->strKey.GetLength()+40);
nResult = sprintf(pBuf,"%citemadd {%s} {%s}",_config.chCommand,
(const char *)pList->strListName,
(const char *)pStringMap->strKey);
strText.ReleaseBuffer(nResult);
if (nIndex)
_chat.SendCommand(CHAT_SEND_LIST,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_LIST,strPerson,strText);
pStringMap = pList->mapList.GetNext();
}
nLists++;
}
pList = _lists.GetNext();
}
int nArrays = 0;
ARRAY *ptr = _arrays.GetFirst();
while(ptr != NULL)
{
if (ptr->strGroup == strGroup)
{
if (ptr->bSingleDim)
{
pBuf = strText.GetBuffer(ptr->strName.GetLength()+ptr->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%carray {%s} {%d} {%s}",
_config.chCommand,
(const char *)ptr->strName,
ptr->nDim[0],
(const char *)ptr->strGroup);
strText.ReleaseBuffer(nResult);
}
else
{
pBuf = strText.GetBuffer(ptr->strName.GetLength()+ptr->strGroup.GetLength()+50);
nResult = sprintf(pBuf,"%carray {%s} {%d,%d} {%s}",
_config.chCommand,
(const char *)ptr->strName,
ptr->nDim[0],
ptr->nDim[1],
(const char *)ptr->strGroup);
strText.ReleaseBuffer(nResult);
}
if (nIndex)
_chat.SendCommand(CHAT_SEND_ARRAY,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_ARRAY,strPerson,strText);
// Write out the items.
if (ptr->bSingleDim)
{
for (int i=1;i<=ptr->nDim[0];i++)
{
_arrays.GetItem(ptr,i,0,strTemp);
if (!strTemp.IsEmpty())
{
pBuf = strText.GetBuffer(ptr->strName.GetLength()+strTemp.GetLength()+40);
nResult = sprintf(pBuf,"%cassign {%s} {%d} {%s}",
_config.chCommand,
(const char *)ptr->strName,
i,
(const char *)strTemp);
strText.ReleaseBuffer(nResult);
if (nIndex)
_chat.SendCommand(CHAT_SEND_ARRAY,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_ARRAY,strPerson,strText);
}
}
}
else
{
int j;
for (int i=1;i<=ptr->nDim[0];i++)
for (j=1;j<=ptr->nDim[1];j++)
{
_arrays.GetItem(ptr,i,j,strTemp);
if (!strTemp.IsEmpty())
{
pBuf = strText.GetBuffer(ptr->strName.GetLength()+strTemp.GetLength()+40);
nResult = sprintf(pBuf,"%cassign {%s} {%d,%d} {%s}",
_config.chCommand,
(const char *)ptr->strName,
i,j,
(const char *)strTemp);
strText.ReleaseBuffer(nResult);
if (nIndex)
_chat.SendCommand(CHAT_SEND_ARRAY,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_ARRAY,strPerson,strText);
}
}
}
}
ptr = _arrays.GetNext();
}
int nBarItems = 0;
BAR_ITEM *pItem = _statusBar.GetFirst();
while(pItem != NULL)
{
if (pItem->strGroup == strGroup)
{
if (pItem->bSeparator)
{
pBuf = strText.GetBuffer(pItem->strItem.GetLength()+pItem->strGroup.GetLength()+40);
nResult = sprintf(pBuf,"%cbarseparator {%s} {%d} {%s}\n",
_config.chCommand,
(const char *)pItem->strItem,
pItem->nPos,
(const char *)pItem->strGroup);
strText.ReleaseBuffer(nResult);
}
else
{
pBuf = strText.GetBuffer(pItem->strItem.GetLength()+pItem->strText.GetLength()+pItem->strGroup.GetLength()+80);
nResult = sprintf(pBuf,"%cbaritem {%s} {%s} {%d} {%d} {%d} {%d} {%s}\n",
_config.chCommand,
(const char *)pItem->strItem,
(const char *)pItem->strText,
pItem->nPos,
pItem->nLen,
pItem->nFore,
pItem->nBack,
pItem->strGroup);
strText.ReleaseBuffer(nResult);
}
if (nIndex)
_chat.SendCommand(CHAT_SEND_BARITEM,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_BARITEM,strPerson,strText);
nBarItems++;
}
pItem = _statusBar.GetNext();
}
}
void SendHighlight(CString &strLine)
{
CString strPerson;
CString strHigh;
FindStatement(strLine,strPerson);
FindStatement(strLine,strHigh);
ReplaceVariables(strPerson);
ReplaceVariables(strHigh);
if (strPerson.IsEmpty() || strHigh.IsEmpty())
return;
HIGHLIGHT *pHigh;
int nIndex = atoi(strHigh);
if (nIndex)
pHigh = _highlights.GetAt(nIndex-1);
else
pHigh = _highlights.FindExact(strHigh);
if (pHigh == NULL)
return;
CString strTemp, strText, strColor;
_highlights.HighlightToMask(pHigh,strTemp);
_highlights.AttrToText(pHigh->wAttr,strColor);
char *pBuf = strText.GetBuffer(strTemp.GetLength()+strColor.GetLength()+pHigh->strGroup.GetLength()+40);
int nResult = sprintf(pBuf,"%chighlight {%s} {%s} {%s}",
_config.chCommand,
(const char *)strTemp,
(const char *)strColor,
(const char *)pHigh->strGroup);
strText.GetBuffer(nResult);
nIndex = atoi(strPerson);
if (nIndex)
_chat.SendCommand(CHAT_SEND_HIGHLIGHT,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_HIGHLIGHT,strPerson,strText);
}
void SendList(CString &strLine)
{
CString strPerson;
CString strList;
FindStatement(strLine,strPerson);
FindStatement(strLine,strList);
ReplaceVariables(strPerson);
ReplaceVariables(strList);
if (strPerson.IsEmpty() || strList.IsEmpty())
return;
USER_LIST *pList;
int nIndex = atoi(strList);
if (nIndex)
pList = _lists.GetAt(nIndex-1);
else
pList = _lists.FindByName(strList);
if (pList == NULL)
return;
CString strText;
char *pBuf = strText.GetBuffer(pList->strListName.GetLength()+pList->strGroup.GetLength()+40);
int nResult = sprintf(pBuf,"%clistadd {%s} {%s}",_config.chCommand,
(const char *)pList->strListName,
(const char *)pList->strGroup);
strText.ReleaseBuffer(nResult);
nIndex = atoi(strPerson);
if (nIndex)
_chat.SendCommand(CHAT_SEND_LIST,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_LIST,strPerson,strText);
// Write the items in the list out.
CString strPrepare;
STRING_MAP *pStringMap = pList->mapList.GetFirst();
while(pStringMap != NULL)
{
PrepareForWrite(pStringMap->strKey,strPrepare);
pBuf = strText.GetBuffer(pList->strListName.GetLength()+strPrepare.GetLength()+40);
nResult = sprintf(pBuf,"%citemadd {%s} {%s}",_config.chCommand,
(const char *)pList->strListName,
(const char *)strPrepare);
strText.ReleaseBuffer(nResult);
if (nIndex)
_chat.SendCommand(CHAT_SEND_LIST,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_LIST,strPerson,strText);
pStringMap = pList->mapList.GetNext();
}
}
void SendMacro(CString &strLine)
{
CString strPerson;
CString strMacro;
FindStatement(strLine,strPerson);
FindStatement(strLine,strMacro);
ReplaceVariables(strPerson);
ReplaceVariables(strMacro);
if (strPerson.IsEmpty() || strMacro.IsEmpty())
return;
MACRO *pMac = _macros.FindKeyByName(strMacro);
if (pMac == NULL)
return;
CString strText;
char *pBuf = strText.GetBuffer(pMac->strKeyName.GetLength()+pMac->strText.GetLength()+pMac->strGroup.GetLength()+40);
int nResult = sprintf(pBuf,"%cmacro {%s} {%s} {%s}",_config.chCommand,
(const char *)pMac->strKeyName,
(const char *)pMac->strText,
(const char *)pMac->strGroup);
strText.ReleaseBuffer(nResult);
int nIndex = atoi(strPerson);
if (nIndex)
_chat.SendCommand(CHAT_SEND_MACRO,nIndex-1,strText);
else
_chat.SendCommand(CHAT_SEND_MACRO,strPerson,strText);
}
void SendSub(CString &strLine)
{
CString strPerson;
CString strSub;
FindStatement(strLine,strPerson);
FindStatement(strLine,strSub);
ReplaceVariables(strPerson);
ReplaceVariables(strSub);
if (strPerson.IsEmpty() || strSub.IsEmpty())
return;
SUB *pSub;
int nIndex = atoi(strSub);
if (nIndex)
pSub = _subs.GetAt(nIndex-1);
else
pSub = _subs.FindExact(strSub);
if (pSub == NULL)
return;
CString strTemp;
_subs.SubToTrigger(pSub,strTemp);
char *pBuf = strSub.GetBuffer(strTemp.GetLength()+pSub->strSub.GetLength()+pSub->strGroup.GetLength()+40);
int nResult = sprintf(pBuf,"%csubstitute {%s} {%s} {%s}",
_config.chCommand,
(const char *)strTemp,
(const char *)pSub->strSub,
(const char *)pSub->strGroup);
strSub.ReleaseBuffer(nResult);
nIndex = atoi(strPerson);
if (nIndex)
_chat.SendCommand(CHAT_SEND_SUBSTITUTE,nIndex-1,strSub);
else
_chat.SendCommand(CHAT_SEND_SUBSTITUTE,strPerson,strSub);
}
void SendVariable(CString &strLine)
{
CString strPerson;
CString strVar;
FindStatement(strLine,strPerson);
FindStatement(strLine,strVar);
ReplaceVariables(strPerson);
ReplaceVariables(strVar);
if (strPerson.IsEmpty() || strVar.IsEmpty())
return;
STRING_MAP *pVar;
int nIndex = atoi(strVar);
if (nIndex)
pVar = _mapVars.GetAt(nIndex-1);
else
pVar = _mapVars.FindExactByKey(strVar);
if (pVar == NULL)
return;
CString strTemp;
CString strPrepare;
char *pBuf;
int nResult;
if (pVar->strText.IsEmpty())
{
pBuf = strTemp.GetBuffer(pVar->strKey.GetLength()+pVar->strGroup.GetLength()+30);
nResult = sprintf(pBuf,"%cempty {%s} {%s}",
_config.chCommand,
(const char *)pVar->strKey,
(const char *)pVar->strGroup);
strTemp.ReleaseBuffer(nResult);
}
else
{
PrepareForWrite(pVar->strText,strPrepare);
pBuf = strTemp.GetBuffer(pVar->strKey.GetLength()+strPrepare.GetLength()+pVar->strGroup.GetLength()+30);
nResult = sprintf(pBuf,"%cvariable {%s} {%s} {%s}",
_config.chCommand,
(const char *)pVar->strKey,
(const char *)strPrepare,
(const char *)pVar->strGroup);
strTemp.ReleaseBuffer(nResult);
}
nIndex = atoi(strPerson);
if (nIndex)
_chat.SendCommand(CHAT_SEND_VARIABLE,nIndex-1,strTemp);
else
_chat.SendCommand(CHAT_SEND_VARIABLE,strPerson,strTemp);
}
void Session(CString &strLine)
{
GetIPAddress();
CString strParam1, strParam2, strParam3;
FindStatement(strLine,strParam1);
FindStatement(strLine,strParam2);
FindStatement(strLine,strParam3);
if (strParam1.IsEmpty())
PrintMessage("Session name missing.");
else
if (strParam2.IsEmpty())
PrintMessage("Network Address is missing.");
else
if (strParam3.IsEmpty())
PrintMessage("Need to specifiy a port.");
else
Connect(strParam1,strParam2,strParam3);
}
void SetEventTime(CString &strLine)
{
CString strEvent;
CString strTime;
FindStatement(strLine,strEvent);
FindStatement(strLine,strTime);
ReplaceVariables(strEvent);
ReplaceVariables(strTime);
int nTime = atoi(strTime);
if (nTime < 1)
{
PrintMessage("Invalid event time.");
return;
}
EVENT *pEvent;
int nIndex = atoi(strEvent);
if (nIndex)
pEvent = _events.GetAt(nIndex-1);
else
pEvent = _events.FindByName(strEvent);
if (pEvent != NULL)
{
pEvent->nSeconds = nTime;
pEvent->dwElapse = nTime;
pEvent->dwStarted = _dwTime;
PrintMessage("Event time changed.");
}
else
PrintMessage("Event not found.");
}
void SetIP(CString &strLine)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -