Public Member Functions | |
eChatSpamTester (ePlayerNetID *p, tString const &say) | |
bool | Block () |
bool | Check () |
Public Attributes | |
bool | tested_ |
bool | shouldBlock_ |
ePlayerNetID * | player_ |
tString | say_ |
Definition at line 2587 of file ePlayer.cpp.
eChatSpamTester::eChatSpamTester | ( | ePlayerNetID * | p, | |
tString const & | say | |||
) | [inline] |
Definition at line 2590 of file ePlayer.cpp.
02590 : 02591 eChatSpamTester( ePlayerNetID * p, tString const & say ) 02592 : tested_( false ), shouldBlock_( false ), player_( p ), say_( say ) 02593 { }
bool eChatSpamTester::Block | ( | ) | [inline] |
Definition at line 2595 of file ePlayer.cpp.
Referenced by se_ChatMe(), se_ChatMsg(), and se_ChatTeam().
02597 { 02598 if ( !tested_ ) 02599 { 02600 shouldBlock_ = Check(); 02601 tested_ = true; 02602 } 02603 02604 return shouldBlock_;
bool eChatSpamTester::Check | ( | ) | [inline] |
Definition at line 2606 of file ePlayer.cpp.
References ePlayerNetID::chatSpam_, nSpamProtection::CheckSpam(), REAL, se_alreadySaidTimeout, se_chatAccessLevel, se_chatRequestTimeout, sn_ConsoleOut(), and tSysTimeFloat().
02608 { 02609 nTimeRolling currentTime = tSysTimeFloat(); 02610 02611 // check if the player already said the same thing not too long ago 02612 for (short c = 0; c < player_->lastSaid.Len(); c++) 02613 { 02614 if( (say_.StripWhitespace() == player_->lastSaid[c].StripWhitespace()) && ( (currentTime - player_->lastSaidTimes[c]) < se_alreadySaidTimeout) ) 02615 { 02616 sn_ConsoleOut( tOutput("$spam_protection_repeat", say_ ), player_->Owner() ); 02617 return true; 02618 } 02619 } 02620 02621 REAL lengthMalus = say_.Len() / 20.0; 02622 if ( lengthMalus > 4.0 ) 02623 { 02624 lengthMalus = 4.0; 02625 } 02626 02627 if ( nSpamProtection::Level_Mild <= player_->chatSpam_.CheckSpam( 1+lengthMalus, player_->Owner(), tOutput("$spam_chat") ) ) 02628 { 02629 return true; 02630 } 02631 02632 #ifdef KRAWALL_SERVER 02633 if ( player_->GetAccessLevel() > se_chatAccessLevel ) 02634 { 02635 // every once in a while, remind the public that someone has something to say 02636 static double nextRequest = 0; 02637 double now = tSysTimeFloat(); 02638 if ( now > nextRequest && se_chatRequestTimeout > 0 ) 02639 { 02640 sn_ConsoleOut( tOutput("$access_level_chat_request", player_->GetColoredName(), player_->GetLogName() ), player_->Owner() ); 02641 nextRequest = now + se_chatRequestTimeout; 02642 } 02643 else 02644 { 02645 sn_ConsoleOut( tOutput("$access_level_chat_denied" ), player_->Owner() ); 02646 } 02647 02648 return true; 02649 } 02650 #endif 02651 02652 // update last said record 02653 { 02654 for( short zz = 12; zz>=1; zz-- ) 02655 { 02656 player_->lastSaid[zz] = player_->lastSaid[zz-1]; 02657 player_->lastSaidTimes[zz] = player_->lastSaidTimes[zz-1]; 02658 } 02659 02660 player_->lastSaid[0] = say_; 02661 player_->lastSaidTimes[0] = currentTime; 02662 } 02663 02664 return false;
Definition at line 2666 of file ePlayer.cpp.
Definition at line 2667 of file ePlayer.cpp.
Definition at line 2668 of file ePlayer.cpp.
Definition at line 2669 of file ePlayer.cpp.