Coder Social home page Coder Social logo

ubernostrum / akismet Goto Github PK

View Code? Open in Web Editor NEW
11.0 3.0 4.0 162 KB

A Python interface to the Akismet spam-filtering service.

Home Page: http://akismet.readthedocs.io/

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%
python akismet akismet-client spam-filtering spam-prevention spam-detection spam

akismet's Introduction

CI status image

A Python interface to the Akismet spam-filtering service.

Two API clients are available from this library:

  • akismet.SyncClient is an Akismet API client which performs synchronous (blocking) HTTP requests to the Akismet web service.
  • akismet.AsyncClient is an Akismet API client which performs asynchronous (async/await/non-blocking) HTTP requests to the Akismet web service.

Aside from one being sync and the other async, the two clients expose identical APIs, and implement all methods of the Akismet web API, including the v1.2 key and API usage metrics.

To use this library, you will need to obtain an Akismet API key and register a site for use with the Akismet web service; you can do this at <https://akismet.com>. Once you have a key and corresponding registered site URL to use with it, place them in the environment variables PYTHON_AKISMET_API_KEY and PYTHON_AKISMET_BLOG_URL, and they will be automatically detected and used.

You can then construct a client instance and call its methods. For example, to check a submitted forum post for spam:

import akismet

akismet_client = akismet.SyncClient.validated_client()

if akismet_client.comment_check(
    user_ip=submitter_ip,
    comment_content=submitted_content,
    comment_type="forum-post",
    comment_author=submitter_name
):
    # This piece of content was classified as spam; handle it appropriately.

Or using the asynchronous client:

import akismet

akismet_client = await akismet.AsyncClient.validated_client()

if await akismet_client.comment_check(
    user_ip=submitter_ip,
    comment_content=submitted_content,
    comment_type="forum-post",
    comment_author=submitter_name
):
    # This piece of content was classified as spam; handle it appropriately.

Note that in both cases the client instance is created via the alternate constructor validated_client(). This is recommended instead of using the default constructor (i.e., directly calling akismet.SyncClient() or akismet.AsyncClient()); the validated_client() constructor will perform automatic discovery of the environment-variable configuration and validate the configuration with the Akismet web service before returning the client, while directly constructing an instance will not (so if you do directly construct an instance, you must manually provide and validate its configuration).

See the documentation for full details.

The original version of this library was written by Michael Foord.

akismet's People

Contributors

grantisu avatar ubernostrum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

akismet's Issues

Expose X-akismet-pro-tip

From the docs:

If the X-akismet-pro-tip header is set to discard, then Akismet has determined that the comment is blatant spam, and you can safely discard it without saving it in any spam queue. Read more about this feature in this Akismet blog post.

It would be useful to have access to this flag.

new pypi release

Hey,

I saw that you are the one who uploaded akismet on pypi, could you merge python 3 branch and release a new version?

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.