summaryrefslogtreecommitdiff
path: root/stopspam.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-10-31 03:17:54 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-10-31 03:17:54 +0300
commitc73d5cfe85557d038e21f35712a679ca8061f6f1 (patch)
tree3eb98f75b0e3fe8a22645f92277f60e9c20379b1 /stopspam.cpp
parent805aae34900744c6904cad9437506fdf860e12e7 (diff)
another cleanup method
regex history log
Diffstat (limited to 'stopspam.cpp')
-rw-r--r--stopspam.cpp44
1 files changed, 25 insertions, 19 deletions
diff --git a/stopspam.cpp b/stopspam.cpp
index cc876af..d76d79a 100644
--- a/stopspam.cpp
+++ b/stopspam.cpp
@@ -62,14 +62,9 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam)
}
if(msg)
{
-#ifdef _UNICODE
char * buff=mir_utf8encodeW(variables_parse(gbAuthRepl, hcntct).c_str());
CallContactService(hcntct, PSS_MESSAGE, PREF_UTF, (LPARAM) buff);
mir_free(buff);
-#else
- CallContactService(hcntct, PSS_MESSAGE, 0, (LPARAM) variables_parse(gbAuthRepl, hcntct).c_str());
-#endif
-
};
delete dbei.pBlob;
return 1;
@@ -125,23 +120,15 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
tstring message;
- if(dbei->flags & DBEF_UTF){
- WCHAR* msg_u;
+ if(dbei->flags & DBEF_UTF)
+ {
+ wchar_t* msg_u;
char* msg_a = mir_strdup(( char* )dbei->pBlob );
mir_utf8decode( msg_a, &msg_u );
-#ifdef _UNICODE
message = msg_u;
-#else
- message = mir_u2a(msg_u);
-#endif
}
- else{
-#ifdef _UNICODE
+ else
message = mir_a2u((char*)(dbei->pBlob));
-#else
- message = (char*)(dbei->pBlob);
-#endif
- }
// if message contains right answer...
@@ -153,8 +140,27 @@ MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
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()))))
+ bool answered = false;
+ if(!gbRegexMatch)
+ answered = gbCaseInsensitive?(!Stricmp(message.c_str(), (variables_parse(gbAnswer, hContact).c_str()))):( !_tcscmp(message.c_str(), (variables_parse(gbAnswer, hContact).c_str())));
+ else
+ {
+ if(gbCaseInsensitive)
+ {
+ std::string check(toUTF8(variables_parse(gbAnswer, hContact))), msg(toUTF8(message));
+ boost::algorithm::to_upper(check);
+ boost::algorithm::to_upper(msg);
+ boost::regex expr(check);
+ answered = boost::regex_search(msg.begin(), msg.end(), expr);
+ }
+ else
+ {
+ std::string check(toUTF8(variables_parse(gbAnswer, hContact))), msg(toUTF8(message));
+ boost::regex expr(check);
+ answered = boost::regex_search(msg.begin(), msg.end(), expr);
+ }
+ }
+ if(answered)
{
// unhide contact
DBDeleteContactSetting(hContact, "CList", "Hidden");