From 87b995d5072d116917c2cb571e0f10554e0f434d Mon Sep 17 00:00:00 2001 From: Gluzskiy Alexandr Date: Fri, 2 Oct 2009 19:05:46 +0300 Subject: another logic fix --- stopspam_mod/trunk/stopspam.cpp | 54 +++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 18 deletions(-) (limited to 'stopspam_mod/trunk/stopspam.cpp') diff --git a/stopspam_mod/trunk/stopspam.cpp b/stopspam_mod/trunk/stopspam.cpp index 596e986..035d3d9 100644 --- a/stopspam_mod/trunk/stopspam.cpp +++ b/stopspam_mod/trunk/stopspam.cpp @@ -61,9 +61,20 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam) if(gbSpecialGroup) DBWriteContactSettingTString(hcntct, "CList", "Group", gbSpammersGroup.c_str()); - if(!gbInvisDisable || ((gbInvisDisable && (DBGetContactSettingWord(hContact,dbei.szModule,"ApparentMode",0) != ID_STATUS_OFFLINE)) || - (gbInvisDisable && (CallProtoService(dbei.szModule, PS_GETSTATUS, 0, 0) != ID_STATUS_INVISIBLE)))) - int a = CallService(allowService.c_str(), (WPARAM)hDbEvent, (LPARAM)(variables_parse(gbAuthRepl, hcntct).c_str())); + 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(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; @@ -183,29 +194,36 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l) 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)) + && (!gbMaxQuestCount || DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0) < gbMaxQuestCount) && msg) { - if(!gbInvisDisable || ((gbInvisDisable && (DBGetContactSettingWord(hContact,dbei->szModule,"ApparentMode",0) != ID_STATUS_OFFLINE)) || - (gbInvisDisable && (CallProtoService(dbei->szModule, PS_GETSTATUS, 0, 0) != ID_STATUS_INVISIBLE)))) - { - // send question - tstring q = _T("StopSpam automatic message:\r\n") + variables_parse(gbQuestion, hContact); + // 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); - } + + // increment question count + DWORD questCount = DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0); + DBWriteContactSettingDword(hContact, pluginName, "QuestionCount", questCount + 1); } else { -- cgit v1.2.3