GithubHelp home page GithubHelp logo

mollom_python's Introduction

mollom_python

A python client library for the Mollom REST API.

Requirements

  • requests_oauthlib
  • requests

These requirements can be installed by doing

pip install -r requirements.txt

Example Usage

from mollom_python import Mollom
public_key = {public_key}
private_key = {private_key}
mollom_client = Mollom(public_key, private_key)

try:
  post_title = {post_title}
  post_body = {post_body}
  author_id = {author_id}
  author_ip = {author_ip}
  content_id, spam_classification = mollom_client.check_content(post_title=post_title, post_body=post_body, author_id=author_id, author_ip=author_ip)
  
  if spam_classification == "ham":
    # Accept the content
  elif spam_classification == "spam":
    # Reject the content
  else: # unsure
    captcha_id, captcha_url = mollom_client.create_captcha(content_id=content_id)
    
    # Present captcha_url to the end-user for a solution
    solution = {solution}
    
    solved = mollom_client.check_captcha(captcha_id=captcha_id, solution=solution, author_id=author_id, author_ip=author_ip)
    if solved:
      # If the content hasn't changed, accept the content
      # otherwise, resubmit for checking: mollom_client.check_content(content_id=content_id, ...)
    else:
      # User failed to solve the CAPTCHA correctly
      # Either give the user more attempts or simply reject the content
    
except (MollomConnectionError):
  # Mollom is down, accept the content for manual moderation

Sending feedback

Sometimes, Mollom makes mistakes. When this happens, send feedback so that Mollom can learn from its mistakes.

from mollom_python import Mollom
public_key = {public_key}
private_key = {private_key}
mollom_client = Mollom(public_key, private_key)

# Content ID of the content to submit feedback about
content_id = {content_id}

mollom_client.send_feedback(content_id=content_id, reason="spam")

mollom_python's People

Contributors

elyk avatar

Watchers

James Cloos avatar

Forkers

disqus

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.