summaryrefslogtreecommitdiff
path: root/messages.cpp
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-09-26 21:46:33 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-09-26 21:46:33 +0300
commitdcf36bc803916561f01febeedb76501d3fe3f729 (patch)
tree904d682ba3d6077ce0c585514827b14294ff67a9 /messages.cpp
parentfa9565edd129e41bc45e5e7012a15de1456448eb (diff)
modified: messages.cpp
modified: options.cpp modified: replacer.suo
Diffstat (limited to 'messages.cpp')
-rw-r--r--messages.cpp67
1 files changed, 67 insertions, 0 deletions
diff --git a/messages.cpp b/messages.cpp
index 16cac57..7b2424e 100644
--- a/messages.cpp
+++ b/messages.cpp
@@ -43,6 +43,8 @@ int RecvMsgSvc(WPARAM w, LPARAM l)
return CallService(MS_PROTO_CHAINRECV, w, l);
}
+char *send_msg = NULL;
+
int SendMsgSvc(WPARAM w, LPARAM l)
{
CCSDATA *ccs = (CCSDATA*)l;
@@ -55,6 +57,71 @@ int SendMsgSvc(WPARAM w, LPARAM l)
HANDLE hContact = ccs->hContact;
if(isProtoMetaContacts(hContact))
hContact = metaGetMostOnline(hContact);
+
+ TCHAR *tmp = mir_a2t(msg);
+ wstring str = tmp;
+ mir_free(tmp);
+
+ int i = 0;
+ char setting[32];
+ mir_snprintf(setting, 31, "szSourceWord%d", i);
+ TCHAR *buf = UniGetContactSettingUtf(NULL, szReplacerModuleName, setting, _T(""));
+ wstring::size_type p1 = 0;
+ while(_tcslen(buf) > 0)
+ {
+ mir_snprintf(setting, 31, "szTargetWords%d", i);
+ TCHAR *buf2 = UniGetContactSettingUtf(NULL, szReplacerModuleName, setting, _T(""));
+ wstring tmp = buf2;
+ mir_free(buf2);
+ wstring::size_type p1 = 0, p2 = 0, end = 0;
+ p1 = tmp.find(_T("†")); //nice delimiter
+ int c = 0;
+ TCHAR *words[1024]; //fucked msvc does not support variable massive size (
+ for(;;)
+ {
+ if(p1 == wstring::npos)
+ break;
+ if(!c)
+ {
+ words[c] = mir_wstrdup(tmp.substr(0, p1).c_str());
+ p2 = end = p1;
+ }
+ else
+ {
+ p2 = tmp.find(_T("†"), p1+1);
+ if(p2 < end || p2 == p1)
+ break;
+ else if(p2 == wstring::npos)
+ break;
+ p1++;
+ words[c] = mir_wstrdup(tmp.substr(p1, p2-p1).c_str());
+ end = p2;
+ }
+ p1 = p2;
+ c++;
+ }
+ if(c)
+ {
+ p1 = 0;
+ wstring::size_type end = 0;
+ while((p1 = str.find(buf), p1) != wstring::npos)
+ {
+ if(p1 < end)
+ break;
+ int p = (c>1)?(rand()%(c-1)):0;
+ str.replace(p1, (wstring::size_type)_tcslen(buf), words[p]);
+ p1+=_tcslen(words[p]);
+ end = p1;
+ }
+ }
+ mir_free(buf);
+ for(int cc = 0; cc < c; cc++)
+ mir_free(words[cc]);
+ i++;
+ mir_snprintf(setting, 31, "szSourceWord%d", i);
+ buf = UniGetContactSettingUtf(NULL, szReplacerModuleName, setting, _T(""));
+ }
+ ccs->lParam = (LPARAM)mir_utf8encodeW(str.c_str());
return CallService(MS_PROTO_CHAINSEND, w, l);
}