1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
#include "headers.h"
extern TCHAR const * defQuestion;
MIRANDA_HOOK_EVENT(ME_DB_CONTACT_ADDED, w, l)
{
DBWriteContactSettingByte((HANDLE)w, "CList", "NotOnList", 1);
return 0;
}
MIRANDA_HOOK_EVENT(ME_DB_EVENT_ADDED, wParam, lParam)
{
HANDLE hContact = (HANDLE)wParam;
HANDLE hDbEvent = (HANDLE)lParam;
DBEVENTINFO dbei = {0};
dbei.cbSize = sizeof(dbei);
dbei.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hDbEvent, 0);
if(-1 == dbei.cbBlob)
return 0;
dbei.pBlob = new BYTE[dbei.cbBlob];
CallService(MS_DB_EVENT_GET, lParam, (LPARAM)&dbei);
// if event is in protocol that is not despammed
if(!ProtoInList(dbei.szModule)) {
delete dbei.pBlob;
return 0;
}
// event is an auth request
if(gbHandleAuthReq)
{
if(!(dbei.flags & DBEF_SENT) && !(dbei.flags & DBEF_READ) && dbei.eventType == EVENTTYPE_AUTHREQUEST)
{
HANDLE hcntct;
hcntct=*((PHANDLE)(dbei.pBlob+sizeof(DWORD)));
/*char text[100];
sprintf(text, "%d, %d, \r\n%d, %d",
(int)hcntct,
(int)hDbEvent,
DBGetContactSettingByte(hContact, pluginName, answeredSetting, 0),
DBGetContactSettingByte(hContact, "CList", "NotOnList", 0));
int a = MessageBox( 0, text, "Àâòîðèçàöèÿ",MB_OK|MB_ICONQUESTION );*/
// if request is from unknown or not marked Answered contact
int a = DBGetContactSettingByte(hcntct, "CList", "NotOnList", 0);
int b = !DBGetContactSettingByte(hcntct, pluginName, "Answered", 0);
if(a && b)//
{
// ...send message
/*MessageBox( 0, "...send message", "yappp...",MB_OK|MB_ICONQUESTION );*/
std::string allowService = dbei.szModule;
allowService += PS_AUTHDENY;
if(gbHideContacts)
DBWriteContactSettingByte(hcntct, "CList", "Hidden", 1);
if(gbSpecialGroup)
DBWriteContactSettingTString(hcntct, "CList", "Group", gbSpammersGroup.c_str());
int a = CallService(allowService.c_str(), (WPARAM)hDbEvent, (LPARAM)gbAuthRepl.c_str());
//CallProtoService(dbei.szModule,PS_AUTHDENY,(WPARAM)hDbEvent,(LPARAM)GetAuthRepl().c_str());
delete dbei.pBlob;
return 1;
}
}
}
delete dbei.pBlob;
return 0;
}
MIRANDA_HOOK_EVENT(ME_DB_EVENT_FILTER_ADD, w, l)
{
HANDLE hContact = (HANDLE)w;
DBEVENTINFO * dbei = (DBEVENTINFO*)l;
// if event is in protocol that is not despammed
if(!ProtoInList(dbei->szModule))
// ...let the event go its way
return 0;
//do not check excluded contact
else if(DBGetContactSettingByte(hContact, pluginName, "Answered", 0))
return 0;
else if(DBGetContactSettingByte(hContact, pluginName, "Excluded", 0))
{
if(!DBGetContactSettingByte(hContact, "CList", "NotOnList", 0))
DBDeleteContactSetting(hContact, pluginName, "Excluded");
return 0;
}
// if event is not a message, or if the message has been read or sent...
/* else if(dbei->flags & DBEF_READ || dbei->eventType != EVENTTYPE_MESSAGE)
// ...let the event go its way
return 0; */
//we want block not only messages, i seen many types other eventtype flood
else if(dbei->flags & DBEF_READ)
// ...let the event go its way
return 0;
//mark contact which we trying to contact for exclude from chack
else if((dbei->flags & DBEF_SENT) && DBGetContactSettingByte(hContact, "CList", "NotOnList", 0)
&& (!gbMaxQuestCount || DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0) < gbMaxQuestCount) && gbExclude)
{
DBWriteContactSettingByte(hContact, pluginName, "Excluded", 1);
return 0;
}
// if message is from known or marked Answered contact
else if(!DBGetContactSettingByte(hContact, "CList", "NotOnList", 0) ||
DBGetContactSettingWord(hContact, dbei->szModule, "ServerId", 0)) //fix for icq
// ...let the event go its way
return 0;
// if message is corrupted or empty it cannot be an answer.
else if(!dbei->cbBlob || !dbei->pBlob)
// reject processing of the event
return 1;
tstring message;
if(dbei->flags & DBEF_UTF){
WCHAR* 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
message = mir_a2u((char*)(dbei->pBlob));
#else
message = (char*)(dbei->pBlob);
#endif
}
// if message contains right answer...
// if( tstring::npos!=message.find(gbAnswer) )
if(!wcscmp(message.c_str(), gbAnswer.c_str()))
{
// unhide contact
DBDeleteContactSetting(hContact, "CList", "Hidden");
// mark contact as Answered
DBWriteContactSettingByte(hContact, pluginName, "Answered", 1);
//add contact permanently
if(gbAddPermanent) //do not use this )
DBDeleteContactSetting(hContact, "CList", "NotOnList");
// send congratulation
#ifdef _UNICODE
char * buf=mir_utf8encodeW(gbCongratulation.c_str());
CallContactService(hContact, PSS_MESSAGE, PREF_UTF, (LPARAM)buf);
mir_free(buf);
#else
CallContactService(hContact, PSS_MESSAGE, 0, (LPARAM)GetCongratulation().c_str());
#endif
// process the event
return 0;
}
// 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) )
{
// send question
tstring q = _T("StopSpam automatic message:\r\n") + gbQuestion;
#ifdef _UNICODE
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());
#endif
// increment question count
DWORD questCount = DBGetContactSettingDword(hContact, pluginName, "QuestionCount", 0);
DBWriteContactSettingDword(hContact, pluginName, "QuestionCount", questCount + 1);
}
else
{
if (gbDosServiceIntegration && gbDosServiceExist)
{
int i;
i = rand()%255*13;
CallService(MS_DOS_SERVICE, (WPARAM)hContact, (LPARAM)i);
}
if(gbIgnoreContacts)
{
DBWriteContactSettingDword(hContact, "Ignore", "Mask1", 0x0000007F);
return 1;
}
}
if(gbHideContacts)
DBWriteContactSettingByte(hContact, "CList", "Hidden", 1);
if(gbSpecialGroup)
DBWriteContactSettingTString(hContact, "CList", "Group", gbSpammersGroup.c_str());
DBWriteContactSettingByte(hContact, "CList", "NotOnList", 1);
// save message from contact
dbei->flags |= DBEF_READ;
CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)dbei);
// reject processing of the event
return 1;
}
MIRANDA_HOOK_EVENT(ME_DB_CONTACT_SETTINGCHANGED, w, l)
{
HANDLE hContact = (HANDLE)w;
DBCONTACTWRITESETTING * cws = (DBCONTACTWRITESETTING*)l;
// if CList/NotOnList is being deleted then remove answeredSetting
if(strcmp(cws->szModule, "CList"))
return 0;
if(strcmp(cws->szSetting, "NotOnList"))
return 0;
if(!cws->value.type)
{
DBDeleteContactSetting(hContact, pluginName, "Answered");
DBDeleteContactSetting(hContact, pluginName, "QuestionCount");
}
return 0;
}
|