| Crates.io | snooker |
| lib.rs | snooker |
| version | 0.1.0 |
| created_at | 2017-08-15 13:54:57.846718+00 |
| updated_at | 2017-08-15 13:54:57.846718+00 |
| description | Snooker is a pure-Rust implementation of Jonathan Snook's spam detection algorithm for blog comments |
| homepage | https://github.com/elliotekj/snooker |
| repository | https://github.com/elliotekj/snooker |
| max_upload_size | |
| id | 27603 |
| size | 24,884 |
This crate provides a pure-Rust implementation of Jonathan Snook's spam detection algorithm for blog comments.
As described in the afore-linked post, it works on a points system. Points are awarded and deducted based on a variety of rules. If a comments final score is greater than or equal to 1, the comment is considered valid. If the comments final score is 0 then it's considered to be worth of moderating. If the comments final score is below 0 then it's considered to be spam. Each comment starts with a score of 0.
If you're using Cargo, just add Snooker to your Cargo.toml:
[dependencies]
snooker = "0.1.0"
Snooker gives the example comment below a score of -10 based off of the following patterns:
body has less that 2 links in it: +2 pointsbody is more that 20 characters long but contains 1 link: +1 pointbody contains one keyword considered spammy ("free"): -1
pointbody contains one phrase considered spammy ("limited time only"): -1
pointbody starts with a word considered spammy when it's the first word of
the comment ("nice"): -10 pointsauthor field doesn't contain http:// or https://: +0 points
(unchanged)url field contains a keyword considered spammy ("free"): -1 pointuse snooker::{Comment, Snooker, Status};
let comment = Comment {
author: Some("Johnny B. Goode".to_string()),
url: Some("http://my-free-ebook.com".to_string()),
body: String::from("
<p>Nice post! Check out our free (for a limited time only) eBook
<a href=\"http://my-free-ebook.com\">here</a> that's totally relevant</p>
"),
previously_accepted_for_email: None,
previously_rejected_for_email: None,
previous_comment_bodies: None,
};
let snooker_result = Snooker::new(comment);
assert_eq!(snooker_result.score, -10);
assert_eq!(snooker_result.status, Status::Spam);
Snooker is released under the MIT LICENSE.
This crate was written by Elliot Jackson.