Skip to main content

CleanTalk module for Python

Project description

cleantalk_python_antispam

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

  • Python 2.6 and above
  • Python 3 and above

SPAM test for text comment sample

from cleantalk import CleanTalk


ct = CleanTalk(auth_key='yourkey')
ct_result = ct.request(
	message = 'abc', # Visitor comment
	sender_ip = '196.19.250.114', # Visitor IP address
	sender_email = 'stop_email@example.com', # Visitor email
	sender_nickname = 'spam_bot', # Visitor nickname
	js_on = 1, # Is visitor has JavaScript
	submit_time = 12 # Seconds from start form filling till the form POST
)
#Check
if ct_result['allow']:
	print('Comment allowed. Reason ' + ct_result['comment'])
	
	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:

pip install cleantalk-python-antispam

Then you can use Cleantalk class import:

from cleantalk_python_antispam.cleantalk import CleanTalk

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cleantalk_python_antispam-1.2.0.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file cleantalk_python_antispam-1.2.0.tar.gz.

File metadata

File hashes

Hashes for cleantalk_python_antispam-1.2.0.tar.gz
Algorithm Hash digest
SHA256 aa206c269d4847136124f92725ec24e0a3892613fc7d68e6fb5d18eee816a2f8
MD5 d7b839c4c470cdb9596ec99adf517c99
BLAKE2b-256 ea3aff7269ad6bbf8a5746161c193ad5465c0f648049963d107a0f6a8095f5ce

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page