#include <nSpamProtection.h>
Public Types | |
enum | Level { Level_Ok, Level_Mild, Level_Hard } |
Public Member Functions | |
Level | CheckSpam (REAL spamlevel, int UserToKick, tOutput const &message) |
REAL | BlockTime () |
nSpamProtection (const nSpamProtectionSettings &settings) | |
~nSpamProtection () | |
Private Attributes | |
const nSpamProtectionSettings & | settings_ |
REAL | spamProtect_ |
nTimeRolling | spamProtectTime_ |
Definition at line 48 of file nSpamProtection.h.
Definition at line 51 of file nSpamProtection.h.
00052 { 00053 Level_Ok, // no spam 00054 Level_Mild, // some level of spam 00055 Level_Hard // extremly annoying 00056 };
nSpamProtection::nSpamProtection | ( | const nSpamProtectionSettings & | settings | ) |
Definition at line 54 of file nSpamProtection.cpp.
00055 : settings_( settings ), spamProtect_( 0.0f ), spamProtectTime_( tSysTimeFloat( )) 00056 { 00057 }
nSpamProtection::~nSpamProtection | ( | void | ) |
nSpamProtection::Level nSpamProtection::CheckSpam | ( | REAL | spamlevel, | |
int | UserToKick, | |||
tOutput const & | message | |||
) |
Definition at line 69 of file nSpamProtection.cpp.
References tOutput::Append(), Level_Hard, Level_Mild, Level_Ok, REAL, se_SpamAutoKick, se_SpamPenalty, se_SpamProtection, tOutput::SetTemplateParameter(), settings_, nSpamProtectionSettings::silence_, sn_ConsoleOut(), sn_KickUser(), spamProtect_, spamProtectTime_, nSpamProtectionSettings::timeScale_, and tSysTimeFloat().
Referenced by eChatSpamTester::Check(), eVoter::IsSpamming(), ePlayerNetID::ReceiveControlNet(), and eVoter::Spam().
00070 { 00071 if ( se_SpamProtection < 0.01f ) 00072 { 00073 se_SpamProtection = 0.01f; 00074 } 00075 00076 REAL timeScale = this->settings_.timeScale_ * se_SpamProtection; 00077 00078 spamProtect_ += spamlevel; 00079 spamProtect_ -=( tSysTimeFloat() - spamProtectTime_ ) / timeScale; 00080 00081 spamProtectTime_ = tSysTimeFloat(); 00082 if ( spamProtect_ < 0 ) 00083 spamProtect_ = 0; 00084 00085 if ( spamProtect_ > 6 ){ 00086 tOutput message; 00087 spamProtect_ += se_SpamPenalty; 00088 00089 message.SetTemplateParameter(1, ( spamProtect_ - 6 ) * timeScale ); 00090 message.Append( settings_.silence_ ); 00091 00092 // message << ColorString (1,1,0); 00093 // message << "$spam_protection"; 00094 00095 sn_ConsoleOut(message,userToKick); 00096 00097 if ( spamProtect_ > se_SpamAutoKick ) 00098 { 00099 tOutput message( "$network_kill_spamkick" ); 00100 message.Append( " " ); 00101 message.Append( reason ); 00102 sn_KickUser( userToKick, message ); 00103 00104 return Level_Hard; 00105 } 00106 00107 return Level_Mild; 00108 } 00109 00110 return Level_Ok; 00111 }
REAL nSpamProtection::BlockTime | ( | ) |
Definition at line 63 of file nSpamProtection.cpp.
References REAL, se_SpamProtection, settings_, spamProtect_, spamProtectTime_, nSpamProtectionSettings::timeScale_, and tSysTimeFloat().
00064 { 00065 REAL timeScale = this->settings_.timeScale_ * se_SpamProtection; 00066 return ( spamProtect_ - 6 ) * timeScale + ( tSysTimeFloat() - spamProtectTime_ ); 00067 }
const nSpamProtectionSettings& nSpamProtection::settings_ [private] |
REAL nSpamProtection::spamProtect_ [private] |