项目作者: CleanTalk

项目描述 :
Web based antispam API for Python applications
高级语言: Python
项目地址: git://github.com/CleanTalk/python-antispam.git
创建时间: 2013-09-19T07:54:04Z
项目社区:https://github.com/CleanTalk/python-antispam

开源协议:

下载


python-antispam

Prevents spam in your python web apps. Cloud features allow you to use additional anti-spam functionality. Cloud features allow you to use additional anti-spam functionality, such as: Personal IP/Email lists, blocking by country, language, stop words and etc.

Spam attacks log - allows to view all filtered requests in the “Log of spam attacks”.
The log contains a detailed information about each request for a time period. At any time, you can check the request and make sure that the filtering is correct. A Python API for antispam service cleantalk.org. Invisible protection from spam, no captches, no puzzles, no animals and no math.

How API stops spam?

API uses several simple tests to stop spammers.

  • Spam bots signatures.
  • Blacklists checks by Email, IP, web-sites domain names.
  • JavaScript availability.
  • Comment submit time.
  • Relevance test for the comment.

How API works?

API sends a comment’s text and several previous approved comments to the servers. Servers evaluates the relevance of the comment’s text on the topic, tests on spam and finaly provides a solution - to publish or put on manual moderation of comments. If a comment is placed on manual moderation, the plugin adds to the text of a comment explaining the reason for the ban server publishing.

Requirements

SPAM test for text comment sample

  1. from cleantalk import CleanTalk
  2. import json
  3. ct = CleanTalk(auth_key='yourkey')
  4. ct_result = ct.request(
  5. message = 'abc', # Required. Visitor comment
  6. sender_ip = '196.19.250.114', # Required. Visitor IP address
  7. sender_email = 'stop_email@example.com', # Required. Visitor email
  8. sender_nickname = 'spam_bot', # Required. Visitor nickname
  9. post_info= json.dumps({'post_url': 'https://yoursite.com'}) # Optional. Additional post info in JSON format.
  10. # event_token = 'xxx' # fill it with ct_bot_detector_event_token hidden input from your form (auto generate)
  11. )
  12. #Check
  13. if ct_result['allow']:
  14. print('Comment allowed. Reason ' + ct_result['comment'])
  15. else:
  16. print('Comment blocked. Reason ' + ct_result['comment'])

API Response description

API returns Python dictionary object, where keys:

  • allow (0|1) - allow to publish or not, in other words spam or ham
  • comment (string) - server comment for requests.
  • id (string MD5 HEX hash) - unique request idenifier.

Installing via PyPi

Run the next command in the terminal:

  1. pip install cleantalk-python-antispam

Then you can use Cleantalk class import:

  1. from cleantalk_python_antispam.cleantalk import CleanTalk

For improve protection include javascript to your layout before \<\/body> tag:

  1. <script type="text/javascript" src="https://moderate.cleantalk.org/ct-bot-detector-wrapper.js"></script>

Changelog

Version 1.2

  • New. Now page URL could be added to the request.
  • Mod. Tests file updated.
  • Mod. Readme updated.