In order for the Telligent Community to determine whether content is spam, the content is processed through a series of content scorers. If the resulting score is higher than the configured threshold, the content is flagged as spam.
You can create custom scorers to help detect certain types of spam. To do this, you will need to create an object that implements IContentScorer. When you create an object, you must place it in the objects assembly in the bin folder. It will then be added to the list of available spam modules in the Control Panel. You can also configure the new content scorer, if it supports configuration, in the spam management page through the Control Panel.
Here is a list of the required properties an IContentScorer should implement:
- Guid ContentScorerId
- string ScorerName
- string ScorerDescription
- bool Enabled
This list of properties is used to help identify each scorer and determine whether it should be run. The scorer must also have a method that returns a Boolean and outputs the resultant score: TryGetScore(ScoreableContent, out int score).
ConfigurableContentScorerBase
If you are interested in making your content scorer configurable, then you should inherit from ConfigurableContentScorerBase. It allows you to create PropertyGroups like you would for a content fragment. Because a PropertyGroup and its containing properties are explained in the dynamic configuration (which requires a login to obtain) and content fragment documentation, it will not be explained here. Note: If you make your content scorer configurable, you do not need to implement the Enabled property; it is configured in the ConfigurableContentScorerBase class.
Example - Simple Content Scorer
In the following example, the content scorer counts how many 's' characters appear in the content and returns a score based on this. For each 's' that exists in the content, a point is added to the content's score.
public class SContentScorer : ConfigurableContentScorerBase
{
public override Guid ContentScorerId
{
get { return new Guid("583CDCE6-61EA-4500-83FC-E2D5C598B8DE"); }
}
public override string ScorerName
{
get { return "S Content Scorer"; }
}
public override string ScorerDescription
{
get { return "A score based on the number of 's' characters"; }
}
public override bool TryGetScore(ScoreableContent scoreableContent, out int score)
{
score = 0;
int pointsPerS = GetIntValue("pointsPerS", 1);
string[] sSplit = scoreableContent.Content.Split('s');
if (sSplit != null && sSplit.Length > 0)
score += pointsPerS * sSplit.Length;
return true;
}
public override PropertyGroup[] GetPropertyGroups()
{
PropertyGroup[] propertyGroups = new[] { new PropertyGroup("spamOptions", "Spam Settings", 1) };
propertyGroups[0].Properties.Add(new Property("pointsPerS", "Points to assign for each S", PropertyType.Int, 0, "1"));
return propertyGroups;
}
}