# Path: comments_spamfighter/models.py
# class Keyword(models.Model):
# 
#     # Default field choices. These are good inital values for the default
#     # Django comments but you can override it using the settings variable
#     # COMMENTS_CHECK_FIELDS_CHOICES
# 
#     FIELD_CHOICES = (
#         ("user_name", _("Username")),
#         ("user_email", _("User Email")),
#         ("user_url", _("User URL")),
#         ("comment", _("Comment text")),
#         ("ip_address", _("IP Address")),
#     )
#     FIELD_CHOICES = getattr(settings, "COMMENTS_CHECK_FIELDS_CHOICES", FIELD_CHOICES)
# 
#     active = models.BooleanField(_("Active"), default=True)
#     keyword = models.TextField(_("Keyword"))
#     is_regex = models.BooleanField(_("Is a regular expression"), default=False)
#     fields = models.TextField(_("Fields to check"), max_length=255)
#     created = models.DateTimeField(_("Created"), auto_now_add=True)
#     modified = models.DateTimeField(_("Modified"), auto_now=True)
# 
#     class Meta:
#         ordering = ("keyword", "created")
#         verbose_name = _("Keyword")
#         verbose_name_plural = _("Keywords")
# 
#     def __str__(self):
#         return self.keyword


import re
from akismet import Akismet
from django.conf import settings
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django_comments.moderation import CommentModerator
from .models import Keyword




class SpamFighterModerator(CommentModerator):
    # Check with Akismet for spam
    akismet_check = False

    # If Akismet marks this message as spam, delete it instantly (False) or
    # add it the comment the moderation queue (True). Default is True.
    akismet_check_moderate = True

    # Do a keyword check
    keyword_check = True

    # If a keyword is found, delete it instantly (False) or add the comment to
    # the moderation queue (True). Default is False.
    keyword_check_moderate = False


# Path: comments_spamfighter/models.py
# class Keyword(models.Model):
# 
#     # Default field choices. These are good inital values for the default
#     # Django comments but you can override it using the settings variable
#     # COMMENTS_CHECK_FIELDS_CHOICES
# 
#     FIELD_CHOICES = (
#         ("user_name", _("Username")),
#         ("user_email", _("User Email")),
#         ("user_url", _("User URL")),
#         ("comment", _("Comment text")),
#         ("ip_address", _("IP Address")),
#     )
#     FIELD_CHOICES = getattr(settings, "COMMENTS_CHECK_FIELDS_CHOICES", FIELD_CHOICES)
# 
#     active = models.BooleanField(_("Active"), default=True)
#     keyword = models.TextField(_("Keyword"))
#     is_regex = models.BooleanField(_("Is a regular expression"), default=False)
#     fields = models.TextField(_("Fields to check"), max_length=255)
#     created = models.DateTimeField(_("Created"), auto_now_add=True)
#     modified = models.DateTimeField(_("Modified"), auto_now=True)
# 
#     class Meta:
#         ordering = ("keyword", "created")
#         verbose_name = _("Keyword")
#         verbose_name_plural = _("Keywords")
# 
#     def __str__(self):
#         return self.keyword


# Path: comments_spamfighter/moderation.py
import re
from akismet import Akismet
from django.conf import settings
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django_comments.moderation import CommentModerator
from .models import Keyword





class SpamFighterModerator(CommentModerator):
    # Check with Akismet for spam
    akismet_check = False

    # If Akismet marks this message as spam, delete it instantly (False) or
    # add it the comment the moderation queue (True). Default is True.
    akismet_check_moderate = True

    # Do a keyword check
    keyword_check = True

    # If a keyword is found, delete it instantly (False) or add the comment to
    # the moderation queue (True). Default is False.
    keyword_check_moderate = False


    def _keyword_check(self, comment, content_object, request):