1 /*
2 
3 *************************************************************************
4 
5 ArmageTron -- Just another Tron Lightcycle Game in 3D.
6 Copyright (C) 2000  Manuel Moos (manuel@moosnet.de)
7 
8 **************************************************************************
9 
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License
12 as published by the Free Software Foundation; either version 2
13 of the License, or (at your option) any later version.
14 
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23 
24 ***************************************************************************
25 
26 */
27 
28 #ifndef ArmageTron_SPAM_PROTECTION_H
29 #define ArmageTron_SPAM_PROTECTION_H
30 
31 #include "defs.h"
32 #include "tLocale.h"
33 #include "nNetwork.h"
34 #include "tConfiguration.h"
35 
36 // spam protection settings
37 class nSpamProtectionSettings
38 {
39 public:
40     REAL timeScale_;	//!< timescale of the protection
41     tOutput silence_;	//!< message to send when someone is silenced
42     tSettingItem<REAL> timeScaleSetting_; //!< setting item for timeScale_
43 
44     nSpamProtectionSettings( REAL timeScale, char const * timeScaleConfig , const tOutput& silence );
45 };
46 
47 // spam protection
48 class nSpamProtection
49 {
50 public:
51     enum Level					// enum describing the spam level
52     {
53         Level_Ok,				// no spam
54         Level_Mild,				// some level of spam
55         Level_Hard				// extremly annoying
56     };
57 
58     Level	CheckSpam( REAL spamlevel, int UserToKick, tOutput const & message );	// check if someone is spamming
59     REAL	BlockTime();									                        // time left in silenced mode
60 
61     nSpamProtection( const nSpamProtectionSettings& settings );
62     ~nSpamProtection();
63 
64 private:
65     const nSpamProtectionSettings&	settings_;
66     REAL                            spamProtect_;
67     nTimeRolling                    spamProtectTime_;
68     int                             numWarnings_;
69 };
70 
71 #endif // !defined(ArmageTron_SPAM_PROTECTION_H)
72