~ubuntu-branches/ubuntu/trusty/kvirc/trusty-proposed

« back to all changes in this revision

Viewing changes to src/kvirc/sparser/kvi_antispam.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kai Wasserbäch, Kai Wasserbäch, Raúl Sánchez Siles
  • Date: 2011-02-12 10:40:21 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110212104021-5mh4f75jlku20mnt
The combined "Twisted Experiment" and "Nocturnal Raid" release.

[ Kai Wasserbäch ]
* Synced to upstream's SVN revision 5467.
* debian/rules:
  - Added .PHONY line.
  - Resurrect -DMANUAL_REVISION, got lost somewhere and we build SVN
    revisions again.
  - Replace "-DWITH_NO_EMBEDDED_CODE=YES" with "-DWANT_CRYPTOPP=YES".
  - Change the remaining -DWITH/-DWITHOUT to the new -DWANT syntax.
* debian/control:
  - Removed DMUA, I'm a DD now.
  - Changed my e-mail address.
  - Removed unneeded relationships (no upgrades over two releases are
    supported).
  - Fix Suggests for kvirc-dbg.
  - kvirc-data: Make the "Suggests: kvirc" a Recommends, doesn't make much
    sense to install the -data package without the program.
* debian/source/local-options: Added with "unapply-patches".
* debian/kvirc.lintian-overrides: Updated to work for 4.1.1.
* debian/patches/21_make_shared-mime-info_B-D_superfluous.patch: Updated.
* debian/kvirc-data.install: Added .notifyrc.

[ Raúl Sánchez Siles ]
* Stating the right version where kvirc-data break and replace should happen.
* Fixing link to license file.
* Added French and Portuguese man pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//=============================================================================
2
 
//
3
 
//   File : kvi_antispam.cpp
4
 
//   Creation date : Sun Apr 18 1999 05:36:55 CEST by Szymon Stefanek
5
 
//
6
 
//   This file is part of the KVirc irc client distribution
7
 
//   Copyright (C) 1999-2008 Szymon Stefanek (pragma at kvirc dot net)
8
 
//
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.
13
 
//
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.
18
 
//
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.
22
 
//
23
 
//=============================================================================
24
 
 
25
 
#define _KVI_ANTISPAM_CPP_
26
 
 
27
 
#include "kvi_antispam.h"
28
 
#include "kvi_options.h"
29
 
 
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 
32
 
//                                              =- `��`��`��- 
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
48
 
 
49
 
 
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 ?
55
 
// mmmmh
56
 
//
57
 
// kvi_mayBeSpam : try to guess if text may be a spam message.
58
 
// Ideas:
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
62
 
//              window open yet.
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
67
 
//
68
 
// In this way we can get rid of a good 70% of spam msgs.
69
 
 
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 ... ;-)))
73
 
// -- Kristoff
74
 
 
75
 
// Ok...made this completely configurable....
76
 
// The default spam words get "installed" by the default script
77
 
// 09-01-2001: Pragma
78
 
 
79
 
/*
80
 
        @doc: antispam
81
 
        @title:
82
 
                Anti-spam protection
83
 
        @keyterms:
84
 
                spam
85
 
        @body:
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]
95
 
        @examples:
96
 
                [example]
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
103
 
                [/example]
104
 
*/
105
 
 
106
 
bool kvi_mayBeSpam(KviStr * msg,KviStr &spamWord)
107
 
{
108
 
        for(QStringList::Iterator it = KVI_OPTION_STRINGLIST(KviOption_stringlistSpamWords).begin();
109
 
                        it != KVI_OPTION_STRINGLIST(KviOption_stringlistSpamWords).end() ; ++it)
110
 
        {
111
 
                // FIXME : This is SLOOOOOOOOW (QString -> ascii translation!!)
112
 
 
113
 
                const char * aux = (*it).toAscii();
114
 
                if(aux)
115
 
                {
116
 
                        if(msg->findFirstIdx(aux,false) != -1)
117
 
                        {
118
 
                                spamWord = aux;
119
 
                                return true;
120
 
                        }
121
 
                }
122
 
        }
123
 
        return false;
124
 
}