1
//=============================================================================
3
// File : kvi_antispam.cpp
4
// Creation date : Sun Apr 18 1999 05:36:55 CEST by Szymon Stefanek
6
// This file is part of the KVirc irc client distribution
7
// Copyright (C) 1999-2008 Szymon Stefanek (pragma at kvirc dot net)
9
// This program is FREE software. You can redistribute it and/or
10
// modify it under the terms of the GNU General Public License
11
// as published by the Free Software Foundation; either version 2
12
// of the License, or (at your opinion) any later version.
14
// This program is distributed in the HOPE that it will be USEFUL,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
// See the GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program. If not, write to the Free Software Foundation,
21
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
//=============================================================================
25
#define _KVI_ANTISPAM_CPP_
27
#include "kvi_antispam.h"
28
#include "kvi_options.h"
30
//[05:10:48] <Nataly19> :2http://www.extrababes.com5Go ahead punk, make my day !
31
//[05:11:04] <treeman> :-��`��`�� -= for mp3's go to http://members.xoom.com/treemansmp3/start.htm
33
//[05:10:51] <Suzi48498>:P*** **** squirms like CRAZY when **** licks between her ...
34
//[05:12:11] <dea_> :Hi my name is **** and I just posted pics of myself and
35
// other hot girls on my website at http://133.16.114.32/~guest/
36
// tell me what you think!
37
//[15:18:37] <JuL|aN^bZ> Join #Teens4eva...Have Fun PPl!!!
38
//[15:19:37] <jkhnbn> Ciao, vai sul sito www.sitromba.3000.it ci sono un casino di
39
// immagini e video porno gratisssssssssssssssss!!!!!
40
//[15:19:46] <emjot``> zapraszam na kanal #poke super zabawa i opa za free !!!!!
41
//[15:23:20] <AlExXxX> IMPORTANTE: Se cerchi foto e video HARD andate qu�:
42
// http://216.221.175.58/cgi-bin/affiliate/ad.cgi?id=m4rines [automsg]
43
//[15:23:36] <Jane> hi..join #hard sex channel --Venom ScRipT�-- SToRM iN THe DaRK!!
44
//[15:23:47] <lovghgh> VISIT>> http://go.to/mp3andwarez/ << VISIT[15:23:47] <lovghgh> VISIT>> http://go.to/mp3andwarez/ << VISIT
45
//[15:23:56] <PIMPOLO> HO le prove certe che si puo' far soldi dovendo solo ricevere sms pubblicitari sul cellulare.
46
// Mi sono arrivati sms pubblicitari!!! Ti interessa ? ISCRIVITI CLICCANDO DIRETTAMENTE SU QUESTO SITO:
47
// http://www.smscash.it/index.php3?pagid=reg&p_form=P&p_pres=0&cpre=95620&p_desc=1 (Messaggio Automatico) IR�Simpson
50
// Yes...it is really annoying when I join a channel and
51
// i am flooded with all that messages.
52
// On large-newbie-high-traffic channels I get lagged
53
// with the Query windows popping up with all that stuff.
54
// What I can do ? Ignore queries ?
57
// kvi_mayBeSpam : try to guess if text may be a spam message.
59
// - A spam message is generally a single PRIVMSG <mynick> :<text>
60
// so this function should be (and is) called when
61
// a PRIVMSG is received from a person that has no QUERY
63
// - 95% of spam messages contain an URL inside (http,ftp,www) or a channel name.
64
// - The other 5% contain words like auto-msg , msg me or query <nickname>
65
// - There are some really common words:
66
// free , mp3 , sex , teen , porn , pics , girls , babe , pass , user... , hard , join
68
// In this way we can get rid of a good 70% of spam msgs.
70
// Just a minor change. This allows to easily add more "banned" words.
71
// Maybe there should be a config dialog for that ? Some people like to get
72
// porno pics, but don't like mp3's for example ... ;-)))
75
// Ok...made this completely configurable....
76
// The default spam words get "installed" by the default script
86
KVIrc contains a small spam detector, and can help you in avoiding that annoying flood
87
of queries popping up when you join large channels full of lamers.[br]
88
The spam detector works in a rather simple way: when someone sends you a private message
89
containing one or more "special words", and that user has no open query window,
90
so the message is treated as spam and is redirected to the console window or is ignored completely
91
(if you enable that option).[br]
92
The spam words to check for, can be set by the means of [cmd]option[/cmd] stringlistSpamWords.[br]
93
The anti-spam engine can be enabled by setting [cmd]option[/cmd] boolUseAntiSpamOnPrivmsg and
94
[cmd]option[/cmd] boolUseAntiSpamOnNotice to 1.[br]
97
[comment]# This will cause "new-query private messages" containing[/comment]
98
[comment]# words "http:","#" (channel name),"ftp:".... to be redirected to the console[/comment]
99
[cmd]option[/cmd] stringlistSpamWords http:,#,ftp:,sex,free,chat,join
100
[cmd]option[/cmd] boolUseAntiSpamOnPrivmsg 1
101
[comment]# This will cause these messages to be completely ignored[/comment]
102
[cmd]option[/cmd] boolSilentAntiSpam 1
106
bool kvi_mayBeSpam(KviStr * msg,KviStr &spamWord)
108
for(QStringList::Iterator it = KVI_OPTION_STRINGLIST(KviOption_stringlistSpamWords).begin();
109
it != KVI_OPTION_STRINGLIST(KviOption_stringlistSpamWords).end() ; ++it)
111
// FIXME : This is SLOOOOOOOOW (QString -> ascii translation!!)
113
const char * aux = (*it).toAscii();
116
if(msg->findFirstIdx(aux,false) != -1)