Powered by MediaWiki
Personal tools

CreatingAntispamPlugin

From B2evolution

Jump to: navigation, search

An Antispam Plugin is a plugin that implements methods to prevent/fight back at spam.

Creating an Antispam Plugin is the same as creating a "normal" plugin. This page only handles topics and introduces methods that are common to Antispam plugins.

[edit] Feedback spam

Your plugin should implement the method GetSpamKarmaForComment(). This gets passed the following values in the $params function parameter array:

  • "Comment": the comment object

The following values are interesting if you want to skip your test:

  • 'cur_karma': current karma value (cur_karma_abs/cur_karma_divider)
  • 'cur_karma_abs': current karma absolute value
  • 'cur_karma_divider': current divider (sum of weights)
  • 'cur_count_plugins': number of Plugins that have already been asked

Your plugin should return an integer value between -100 and 100, where -100 means "it's absolutely not spam" and 100 means "I'm damn sure this is spam.". If you don't want to return a spam probability value (e.g. because cur_karma is already above a certain value), just return NULL.


For example:

Step1:
- if domain ends with '.info'   =>  return 20
- if domain ends with '.biz'    =>  return 30
- no match                      =>  return 0
Step2
- if domain contains 'search'   =>  return 20
- no match                      =>  return 0
Step3
- if full url contains '-anal-' =>  return 80
- if full url contains 'anal'   =>  return 20
- no match                      =>  return 0
Step4
- ..

The core then decides upon the results of

$karma_abs / $karma_divider

what to do with the comment. Your plugin provides a part of $karma_abs and $karma_divider is the total weight of the antispam plugins, which can be setup in Antispam Settings tab.