ChatBlade SDK Documentation

Class   CBChatFilter
Header   CBChatFilter.h

Data    Member Summary    Member Details


CBChatFilter is a class designed to support Chat Filtering.  When the Chat Filter is enabled, offensive words shall be replaced with non-offensive #$%! styled text.  
Players can typically enable and disable the Chat Filter by using the /filter Slash Command toggle.   
Players can add or remove words from their local Chat Filter by using the /filterword and /unfilterword commands.  
ChatBlade ships with a sample XML file containing an extensive list of American English bad words, Filter.XML.  
ChatBlade uses CB_FILTER_REPLACEMENT_STRING found in CBStringLiterals.h to replace any bad words found.  
Filtering is Non Case-Sensitive.  Only whole words are Filtered out, not portions of words.  
ChatBlade shall endeavor to ignore any punctuation found in words.  
Only single words should be loaded into the Chat Filter, no spaces should be present.  
An instance of CBChatFilter is created by ChatBlade and stored in CBChatHandler as CBChatHandler::m_ChatFilter.  

Game Developer Implementation:  

CBChatFilter should be loaded up with Offensive words via the AddString() function (CBData::pChatHandler->m_ChatFilter.AddString()).  
CBClientImplementation::LoadChatFilter() is the location where the Chat Filter should be filled via AddString().  
CBSampleImplementation::LoadChatFilter() displays how to do this using the sample Filter.XML file.  
See How To Load the Chat Filter.  
CBChatFilter 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 be filtered out of messages if the chat filter is enabled
// Any words passing through the chat system which match words in the chat filter shall be replaced with non-offensive text
// On startup of the chat system this class should be loaded up with words to be filtered
// Only whole words are checked, but the check is not Case Sensitive
//     So if the word ASS is in the chat filter, Bass shall get through, but not AsS, or aSS
// Bad words are stored in the chat filter in all UPPERCASE


int m_nFilterEnabledFlag
        Flag to tell if we should filter or not - TRUE = filter text    FALSE = don't filter
CBSTRING m_sFilterReplacementString
        A string containing the text we should replace bad words with, usually CB_FILTER_REPLACEMENT_STRING
std::set<CBSTRING> m_FilterStringSet
        A list of all the bad words to filter out

Member Function Summary:  

int  ClearFilter()
        Function which removes all words from the chat filter.
int  EnableFilter(int bEnableFlag = CB_TRUE)
        Function which turns on the chat filter.
int  DisableFilter()
        Function which disables the filter.
int  AddString(CBSTRING sString)
        Function which adds a string to the chat filter.
int  RemoveString(CBSTRING sString)
        Function which removes a string from the chat filter.
int  FilterLine(CBSTRING & sString /*IN OUT*/)
        Function which checks an incoming string and replaces its bad words

Member Function Detail:  

Sets the initial state of the Chat Filter and initializes m_sFilterReplacementString.  
int  CBChatFilter::ClearFilter()
Removes all entries from the Chat Filter.  
int  CBChatFilter::EnableFilter( int bEnableFlag = CB_TRUE)
Enables or Disables the Chat Filter depending on if TRUE or FALSE is passed in.  
No Parameters means to Enable the filter.  
When the Chat Filter is enabled, offensive text should be replaced with @!#%$ type characters when displayed.  
    TRUE or FALSE flag to specify if the Filter should be Enabled or Disabled.  Defaults to CB_TRUE.   
CB_SUCCESS regardless of if the Filter is Enabled or Disabled.  
int  CBChatFilter::DisableFilter()
Turns off the Chat Filter.  
With the Chat Filter disabled, offensive text may be shown.  
int  CBChatFilter::AddString( CBSTRING sString)
Adds a string to the Chat Filter.  
Any strings contained in the Chat Filter that are found in a chat message are replaced with #@%$! type text if the Chat Filter is currently enabled.  
Only single words should be added.  sString should not contain a space.  
Strings are converted to UPPERCASE before storage.  Filtering is not Case Sensitive so bad words are filtered out regardless of Case.  
    A String representing a bad word to add to the Chat Filter.  
CB_ERROR_EMPTY_STRING if sString is empty.
CB_SUCCESS if the word was added to the Chat Filter
int  CBChatFilter::RemoveString( CBSTRING sString)
Removes a string from the Chat Filter.
All strings are stored in the Chat Filter in UPPERCASE.  sString is converted to UPPERCASE before searching for it for removal.  
    The String to remove from the Chat Filter
CB_SUCCESS regardless of if the string was already in the Chat Filter or not.  
int  CBChatFilter::FilterLine( CBSTRING & sString /*IN OUT*/)
Applies the Chat Filter to the incoming line of Text (sString).  If the Chat Filter is enabled, then any words found in sString that have also been added as bad words to the Chat Filter shall be replaced with non-offensive text upon function return.  
Does an in-place replacement of any offensive text in sString and changes the bad words to #@%^! style Text.  
Any punctuation in the bad words is ignored and they are still filtered out.  Filtering is not Case Sensitive.  
An attempt is made to maintain the same length of the string, but this is not guaranteed.  
Only whole words are filtered, not portions of words.  
  For Example:  "Cockatrice" typically would not have any filtering applied.  
sString typically represents an entire line of text and does not need to be a single word.  
Called by CBChatMessage::GetChatString() which formats Chat messages and applies the Chat Filter to them.  
    A reference to a line of text that should be potentially filtered.  
    Upon entry this string contains unfiltered text.  
    Upon exit this string should be altered and any offensive words replaced with #$@%! type text if the Chat Filter is enabled.  
sString is potentially altered if the Filter is on and it contained bad words.  
CB_SUCCESS regardless of if any words were replaced or not.  




ChatBlade Copyright Flex Dolphynn