|
1 | 1 | python-antispam |
2 | | -=============== |
| 2 | +============ |
3 | 3 |
|
4 | | -Web based antispam API for Python applications |
| 4 | +A Python API for antispam service cleantalk.org. Invisible protection from spam, no captches, no puzzles, no animals and no math. |
| 5 | + |
| 6 | +## How API stops spam? |
| 7 | +API uses several simple tests to stop spammers. |
| 8 | + * Spam bots signatures. |
| 9 | + * Blacklists checks by Email, IP, web-sites domain names. |
| 10 | + * JavaScript availability. |
| 11 | + * Comment submit time. |
| 12 | + * Relevance test for the comment. |
| 13 | + |
| 14 | +## How API works? |
| 15 | +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. |
| 16 | + |
| 17 | +## Requirements |
| 18 | + |
| 19 | + * Python 2.6 and above |
| 20 | + |
| 21 | +## SPAM test for text comment sample |
| 22 | + |
| 23 | +```python |
| 24 | +from cleantalk import CleanTalk |
| 25 | + |
| 26 | + |
| 27 | +ct = CleanTalk(auth_key='yourkey') |
| 28 | +ct_result = ct.request( |
| 29 | + message = 'abc', # Visitor comment |
| 30 | + sender_ip = '196.19.250.114', # Visitor IP address |
| 31 | + sender_email = 'stop_email@example.com', # Visitor email |
| 32 | + sender_nickname = 'spam_bot', # Visitor nickname |
| 33 | + js_on = 1, # Is visitor has JavaScript |
| 34 | + submit_time = 12 # Seconds from start form filling till the form POST |
| 35 | + ) |
| 36 | +#Check |
| 37 | +if ct_result['allow']: |
| 38 | + print('Comment allowed. Reason ' + ct_result['comment']) |
| 39 | +else: |
| 40 | + print('Comment blocked. Reason ' + ct_result['comment']) |
| 41 | +``` |
| 42 | + |
| 43 | +## API Response description |
| 44 | +API returns Python dictionary object, where keys: |
| 45 | + * allow (0|1) - allow to publish or not, in other words spam or ham |
| 46 | + * comment (string) - server comment for requests. |
| 47 | + * id (string MD5 HEX hash) - unique request idenifier. |
| 48 | + * errno (int) - error number. errno == 0 if requests successfull. |
| 49 | + * errtstr (string) - comment for error issue, errstr == null if requests successfull. |
| 50 | + |
0 commit comments