ChatBlade SDK Documentation

Class   CBSpamFilter
Header   CBSpamFilter.h

Data    Member Summary    Member Details


Information 

CBSpamFilter is a class designed to support Spam Filtering.  When the Spam Filter is enabled, any Chat Messages containing strings found in the Spam Filter are discarded and are not displayed.  
 
Players can typically enable and disable the Spam Filter by using the /blockspam and /unblockspam Slash Commands.  
Players can add or remove words from their local Spam Filter by using the /blockword and /unblockword commands.  
 
Filtering is Non Case-Sensitive.  Filtering is performed if the Spam string is found anywhere in the Chat Message, including being a substring of a longer word.   
Any string can be loaded into the Spam Filter, spaces are allowed.   
 
An instance of CBSpamFilter is created by ChatBlade and stored in CBChatHandler as CBChatHandler::m_SpamFilter.  
 
Certain Chat Channels (such as Customer Service Channels) are exempt from Spam Filtering.  

Game Developer Implementation:  

CBSpamFilter should be loaded up with Spam Strings via the AddString() function (CBData::pChatHandler->m_SpamFilter.AddString()).  
CBClientImplementation::LoadSpamFilter() is the location where the Spam Filter should be filled via AddString().  
CBSampleImplementation::LoadSpamFilter() displays how to do this.
A Players Spam words should be persisted and reloaded upon logon.  
CBSpamFilter does not need to be instantiated.  CBChatHandler contains an internal instance of this class that is used by ChatBlade.  

Source File Comments:  

// Represents a set of words that should cause the Chat Messages they appear in to be blocked and not displayed
// Any Chat Messages passing through the chat system which contain words found in the Spam Filter shall be discarded and not displayed
// The Spam Filter is used to prevent unwanted Spam from being displayed as well as blocking other Chat Messages, as the User desires
 
// Some companies try to advertise with spam bots via an MMORPGs Chat system
// CBSpamFilter allows Players to block out any unwanted spam or other messages
// Unlike the Chat Filter the entire message is blocked and not displayed, rather than having just the offensive text Filtered with $#@%^!
// Unlike the Ignore List the Spam Filter parses the text of a Chat Message rather than the source to determine whether to Discard it or not
 
// Players can add words to the Spam Filter by using the /blockword and /unblockword Slash Commands (by default)
 
// The check for blocked words is not case sensitive
 
// Blocked words are stored in the Spam Filter in all UPPERCASE

Data:  

int m_nSpamFilterEnabledFlag
        Flag to tell if we should filter or not - CB_TRUE = filter text    CB_FALSE = don't filter
std::set<CBSTRING> m_SpamStringSet
        A list of all the Spam strings to filter out

Member Function Summary:  

     CBSpamFilter()
        Constructor.
int  ClearFilter()
        Function which removes all words from the Spam filter.
int  EnableSpamFilter(int bEnableFlag = CB_TRUE)
        Function which turns on the Spam filter.
int  DisableSpamFilter()
        Function which disables the filter.
int  AddString(CBSTRING sString)
        Function which adds a string to the Spam filter.
int  RemoveString(CBSTRING sString)
        Function which removes a string from the Spam filter.
int  IsSpam(CBChatMessage cbcmChatMessage)
        Function which determines if a Chat Message contains any strings found in the Spam Filter.  

Member Function Detail:  

       CBSpamFilter::CBSpamFilter()
Comments:
Constructor.  
Sets the initial state of the Spam Filter.   
Parameters:
None
Returns:
None
 
int  CBSpamFilter::ClearFilter()
Comments:
Removes all entries from the Spam Filter.  
Parameters:
None
Returns:
CB_SUCCESS
 
int  CBSpamFilter::EnableSpamFilter( int bEnableFlag = CB_TRUE)
Comments:
Enables or Disables the Spam Filter depending on if TRUE or FALSE is passed in.  
No Parameters means to Enable the filter.  
When the Spam Filter is enabled, Chat Messages containing strings found in the Spam Filter are discarded and are not displayed.    
Parameters:
bEnableFlag 
    TRUE or FALSE flag to specify if the Filter should be Enabled or Disabled.  Defaults to CB_TRUE.   
Returns:
CB_SUCCESS regardless of if the Filter is Enabled or Disabled.  
 
int  CBSpamFilter::DisableSpamFilter()
Comments:
Turns off the Spam Filter.  
With the Spam Filter disabled, Spam messages may be shown.  
Parameters:
None
Returns:
CB_SUCCESS
 
int  CBSpamFilter::AddString( CBSTRING sString)
Comments:
Adds a string to the Spam Filter.  
Any Chat Messages containing strings found in the Spam Filter are blocked and discarded and are not displayed (provided the Spam Filter is enabled).   
Phrases (strings containing spaces) may be added.   
Strings are converted to UPPERCASE before storage.  Filtering is not Case Sensitive so Spam words are filtered out regardless of Case.  
Parameters:
sString
    A String representing a spam string to add to the Spam Filter.  
Returns:
CB_ERROR_EMPTY_STRING if sString is empty.
CB_SUCCESS if the word was added to the Spam Filter
 
int  CBSpamFilter::RemoveString( CBSTRING sString)
Comments:
Removes a string from the Spam Filter.
All strings are stored in the Spam Filter in UPPERCASE.  sString is converted to UPPERCASE before searching for it for removal.  
Parameters:
sString
    The String to remove from the Spam Filter
Returns:
CB_SUCCESS regardless of if the string was already in the Spam Filter or not.  
 
int  CBSpamFilter::IsSpam( CBChatMessage cbcmChatMessage)
Comments:
Applies the Spam Filter to the Chat Message.  If the Spam Filter is enabled and cbcmChatMessage contains any strings found in the Spam Filter (m_SpamStringSet), then this function shall return CB_TRUE.  
If the Spam Filter is disabled and/or cbcmChatMessage does not contain any strings found in the Spam Filter, then this function returns CB_FALSE.  
Filtering is not Case Sensitive.  
The filtering is string based, and not word based, meaning that if a substring is found which matches any string in the Spam Filter (even if it is a portion of a larger word) then this function shall return CB_TRUE if the Spam Filter is enabled.  
cbcmChatMessage typically represents a Chat Message for which one wishes to determine if it contains Spam or not.  
This function calls CBChatMessage::GetRawChatString() to get the Chat Text out of the Chat Message.  
Called by CBChatHandler::IsDisplayableChatMessage().  
Parameters:
cbcmChatMessage
    A CBChatMessage instance which may or may not contain Spam 
 
Returns:
CB_TRUE if the Spam Filter is enabled and cbcmChatMessage contains a string found in m_SpamStringSet.  
CB_FALSE if the Spam Filter is disabled or cbcmChatMessage does not contain any Spam.  
 
 

 

 

 

ChatBlade Copyright Flex Dolphynn