INT_PTR __cdecl CIrcProto::Scripting_InsertGuiOut(WPARAM, LPARAM lParam) { GCHOOK* gch = (GCHOOK*)lParam; if (m_scriptingEnabled && gch) { GCHOOK* gchook = new GCHOOK; gchook->pDest = new GCDEST; gchook->dwData = gch->dwData; gchook->pDest->iType = gch->pDest->iType; if (gch->ptszText) gchook->ptszText = _tcsdup(gch->ptszText); else gchook->ptszText = NULL; if (gch->ptszUID) gchook->ptszUID = _tcsdup(gch->ptszUID); else gchook->ptszUID = NULL; if (gch->pDest->ptszID) { CMString S = MakeWndID(gch->pDest->ptszID); gchook->pDest->ptszID = _tcsdup(S.c_str()); } else gchook->pDest->ptszID = NULL; if (gch->pDest->pszModule) gchook->pDest->pszModule = _strdup(gch->pDest->pszModule); else gchook->pDest->pszModule = NULL; mir_forkthread(GuiOutThread, gchook); return 0; } return 1; }
INT_PTR CIrcProto::CallChatEvent(WPARAM wParam, LPARAM lParam) { GCEVENT * gce = (GCEVENT *)lParam; INT_PTR iVal = 0; // first see if the scripting module should modify or stop this event if ( m_bMbotInstalled && m_scriptingEnabled && gce && gce->time != 0 && (gce->pDest->pszID == NULL || lstrlen(gce->pDest->ptszID) != 0 && lstrcmpi(gce->pDest->ptszID , SERVERWINDOW))) { GCEVENT *gcevent= (GCEVENT*) lParam; GCEVENT *gcetemp = NULL; WPARAM wp = wParam; gcetemp = (GCEVENT *)mir_alloc(sizeof(GCEVENT)); gcetemp->pDest = (GCDEST *)mir_alloc(sizeof(GCDEST)); gcetemp->pDest->iType = gcevent->pDest->iType; gcetemp->dwFlags = gcevent->dwFlags; gcetemp->bIsMe = gcevent->bIsMe; gcetemp->cbSize = sizeof(GCEVENT); gcetemp->dwItemData = gcevent->dwItemData; gcetemp->time = gcevent->time; gcetemp->pDest->ptszID = mir_tstrdup( gcevent->pDest->ptszID ); gcetemp->pDest->pszModule = mir_strdup( gcevent->pDest->pszModule ); gcetemp->ptszText = mir_tstrdup( gcevent->ptszText ); gcetemp->ptszUID = mir_tstrdup( gcevent->ptszUID ); gcetemp->ptszNick = mir_tstrdup( gcevent->ptszNick ); gcetemp->ptszStatus = mir_tstrdup( gcevent->ptszStatus ); gcetemp->ptszUserInfo = mir_tstrdup( gcevent->ptszUserInfo ); if ( Scripting_TriggerMSPGuiIn( &wp, gcetemp ) && gcetemp ) { //MBOT CORRECTIONS //if ( gcetemp && gcetemp->pDest && gcetemp->pDest->ptszID ) { if ( gcetemp && gcetemp->pDest && gcetemp->pDest->ptszID && !my_strstri(gcetemp->pDest->ptszID, (IsConnected()) ? m_info.sNetwork.c_str() : TranslateT("Offline")) ) { CMString sTempId = MakeWndID( gcetemp->pDest->ptszID ); mir_realloc( gcetemp->pDest->ptszID, sizeof(TCHAR)*(sTempId.GetLength() + 1)); lstrcpyn(gcetemp->pDest->ptszID, sTempId.c_str(), sTempId.GetLength()+1); } iVal = CallServiceSync(MS_GC_EVENT, wp, (LPARAM) gcetemp); } if ( gcetemp ) { mir_free(( void* )gcetemp->pszNick); mir_free(( void* )gcetemp->pszUID); mir_free(( void* )gcetemp->pszStatus); mir_free(( void* )gcetemp->pszUserInfo); mir_free(( void* )gcetemp->pszText); mir_free(( void* )gcetemp->pDest->pszID); mir_free(( void* )gcetemp->pDest->pszModule); mir_free(( void* )gcetemp->pDest); mir_free(( void* )gcetemp); } return iVal; } return CallServiceSync( MS_GC_EVENT, wParam, ( LPARAM )gce ); }
INT_PTR __cdecl CIrcProto::Scripting_GetIrcData(WPARAM, LPARAM lparam) { if (m_scriptingEnabled && lparam) { CMStringA sString = (char*)lparam, sRequest; CMString sOutput, sChannel; int i = sString.Find("|"); if (i != -1) { sRequest = sString.Mid(0, i); TCHAR* p = mir_a2t(sString.Mid(i + 1)); sChannel = p; mir_free(p); } else sRequest = sString; sRequest.MakeLower(); if (sRequest == "ownnick" && IsConnected()) sOutput = m_info.sNick; else if (sRequest == "network" && IsConnected()) sOutput = m_info.sNetwork; else if (sRequest == "primarynick") sOutput = m_nick; else if (sRequest == "secondarynick") sOutput = m_alternativeNick; else if (sRequest == "myip") return (INT_PTR)mir_strdup(m_manualHost ? m_mySpecifiedHostIP : (m_IPFromServer) ? m_myHost : m_myLocalHost); else if (sRequest == "usercount" && !sChannel.IsEmpty()) { CMString S = MakeWndID(sChannel.c_str()); GC_INFO gci = { 0 }; gci.Flags = GCF_BYID | GCF_COUNT; gci.pszModule = m_szModuleName; gci.pszID = S.c_str(); if (!CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci)) { TCHAR szTemp[40]; mir_sntprintf(szTemp, _T("%u"), gci.iCount); sOutput = szTemp; } } else if (sRequest == "userlist" && !sChannel.IsEmpty()) { CMString S = MakeWndID(sChannel.c_str()); GC_INFO gci = { 0 }; gci.Flags = GCF_BYID | GCF_USERS; gci.pszModule = m_szModuleName; gci.pszID = S.c_str(); if (!CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci)) return (INT_PTR)mir_strdup(gci.pszUsers); } else if (sRequest == "channellist") { CMString S = _T(""); int n = CallServiceSync(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)m_szModuleName); if (n >= 0) { int j = 0; while (j < n) { GC_INFO gci = { 0 }; gci.Flags = GCF_BYINDEX | GCF_ID; gci.pszModule = m_szModuleName; gci.iItem = j; if (!CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci)) { if (mir_tstrcmpi(gci.pszID, SERVERWINDOW)) { CMString S1 = gci.pszID; int k = S1.Find(_T(" ")); if (k != -1) S1 = S1.Mid(0, k); S += S1 + _T(" "); } } j++; } } if (!S.IsEmpty()) sOutput = (TCHAR*)S.c_str(); } // send it to mbot if (!sOutput.IsEmpty()) return (INT_PTR)mir_t2a(sOutput.c_str()); } return 0; }