From 7b3818d042772e56dd0f2a59a99baf464d415f29 Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Thu, 8 Oct 2009 10:42:43 +0300 Subject: fixed invis mode --- stopspam_mod/trunk/stopspam.cpp | 100 ++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'stopspam_mod/trunk/stopspam.cpp') diff --git a/stopspam_mod/trunk/stopspam.cpp b/stopspam_mod/trunk/stopspam.cpp index 035d3d9..e3cdae7 100644 --- a/stopspam_mod/trunk/stopspam.cpp +++ b/stopspam_mod/trunk/stopspam.cpp @@ -61,20 +61,16 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam) if(gbSpecialGroup) DBWriteContactSettingTString(hcntct, "CList", "Group", gbSpammersGroup.c_str()); - BYTE msg = 0; - if(!gbInvisDisable) - msg = 1; - else if(gbInvisDisable) + BYTE msg = 1; + if(gbInvisDisable) { - if(CallProtoService(dbei.szModule, PS_GETSTATUS, 0, 0) != ID_STATUS_INVISIBLE) - msg = 1; - else if(DBGetContactSettingWord(hContact,dbei.szModule,"ApparentMode",0) != ID_STATUS_OFFLINE) - msg = 1; + if(CallProtoService(dbei.szModule, PS_GETSTATUS, 0, 0) == ID_STATUS_INVISIBLE) + msg = 0; + else if(DBGetContactSettingWord(hContact,dbei.szModule,"ApparentMode",0) == ID_STATUS_OFFLINE) + msg = 0; //is it useful ? } if(msg) - { int a = CallService(allowService.c_str(), (WPARAM)hDbEvent, (LPARAM)(variables_parse(gbAuthRepl, hcntct).c_str())); - } //CallProtoService(dbei.szModule,PS_AUTHDENY,(WPARAM)hDbEvent,(LPARAM)GetAuthRepl().c_str()); delete dbei.pBlob; @@ -168,7 +164,16 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l) // if message contains right answer... // if( tstring::npos!=message.find(gbAnswer) ) - int Answered = 0; +// int Answered = 0; + BYTE msg = 1; + if(gbInvisDisable) + { + if(CallProtoService(dbei->szModule, PS_GETSTATUS, 0, 0) == ID_STATUS_INVISIBLE) + msg = 0; + else if(DBGetContactSettingWord(hContact,dbei->szModule,"ApparentMode",0) == ID_STATUS_OFFLINE) + msg = 0; //is it useful ? + } + if(gbCaseInsensitive?(!stricmp(message.c_str(), (variables_parse(gbAnswer, hContact).c_str()))):( !_tcscmp(message.c_str(), (variables_parse(gbAnswer, hContact).c_str())))) { // unhide contact @@ -182,63 +187,58 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l) DBDeleteContactSetting(hContact, "CList", "NotOnList"); // send congratulation + if(msg) + { #ifdef _UNICODE - char * buf=mir_utf8encodeW(variables_parse(gbCongratulation, hContact).c_str()); - CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf); - mir_free(buf); + char * buf=mir_utf8encodeW(variables_parse(gbCongratulation, hContact).c_str()); + CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf); + mir_free(buf); #else - CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)GetCongratulation().c_str()); + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)GetCongratulation().c_str()); #endif + } // process the event return 0; } - BYTE msg = 0; - if(!gbInvisDisable) - msg = 1; - else if(gbInvisDisable) - { - if(CallProtoService(dbei->szModule, PS_GETSTATUS, 0, 0) != ID_STATUS_INVISIBLE) - msg = 1; - else if(DBGetContactSettingWord(hContact,dbei->szModule,"ApparentMode",0) != ID_STATUS_OFFLINE) - msg = 1; - } - // if message message does not contain infintite talk protection prefix // and question count for this contact is less then maximum - if((!gbInfTalkProtection || tstring::npos==message.find(_T("StopSpam automatic message:\r\n"))) - && (!gbMaxQuestCount || DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0) < gbMaxQuestCount) && msg) + if(msg) { - // send question - tstring q = _T("StopSpam automatic message:\r\n") + variables_parse(gbQuestion, hContact); + if((!gbInfTalkProtection || tstring::npos==message.find(_T("StopSpam automatic message:\r\n"))) + && (!gbMaxQuestCount || DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0) < gbMaxQuestCount)) + { + // send question + tstring q = _T("StopSpam automatic message:\r\n") + variables_parse(gbQuestion, hContact); #ifdef _UNICODE - char * buf=mir_utf8encodeW(q.c_str()); - CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf); - mir_free(buf); + char * buf=mir_utf8encodeW(q.c_str()); + CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf); + mir_free(buf); #else - CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)q.c_str()); + CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)q.c_str()); #endif - - // increment question count - DWORD questCount = DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0); - DBWriteContactSettingDword(hContact, pluginName, "QuestionCount", questCount + 1); - } - else - { - if (gbDosServiceExist) + + // increment question count + DWORD questCount = DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0); + DBWriteContactSettingDword(hContact, pluginName, "QuestionCount", questCount + 1); + } + else { - if(gbDosServiceIntegration) + if (gbDosServiceExist) { - int i; - i = rand()%255*13; - CallService(MS_DOS_SERVICE, (WPARAM)hContact, (LPARAM)i); + if(gbDosServiceIntegration) + { + int i; + i = rand()%255*13; + CallService(MS_DOS_SERVICE, (WPARAM)hContact, (LPARAM)i); + } + } + if(gbIgnoreContacts) + { + DBWriteContactSettingDword(hContact, "Ignore", "Mask1", 0x0000007F); } - } - if(gbIgnoreContacts) - { - DBWriteContactSettingDword(hContact, "Ignore", "Mask1", 0x0000007F); } } if(gbHideContacts) -- cgit v1.2.3