Akismet for Kotlin/Java/Android, a client library for accessing the Automattic Kismet (Akismet) spam comments filtering service. https://github.com/ethauvin/akismet-kotlin
Find a file
2022-10-03 23:52:55 -07:00
.circleci Upgraded to Kotlin 1.7.20 2022-09-30 22:40:48 -07:00
.github/workflows Upgraded to Kotlin 1.7.20 2022-09-30 22:40:48 -07:00
.idea Upgraded to Kotlin 1.7.20 2022-09-30 22:40:48 -07:00
config Upgraded to Kotlin 1.7.20 2022-09-30 22:40:48 -07:00
docs Upgraded to Kotlin 1.7.20 2022-09-30 22:40:48 -07:00
examples Upgraded to Kotlin 1.7.20 2022-09-30 22:40:48 -07:00
gradle/wrapper Upgraded to Kotlin 1.7.20 2022-09-30 22:40:48 -07:00
src Cleaned up tests with assertk 2022-10-03 23:52:55 -07:00
.editorconfig Initial commit. 2019-09-18 05:16:01 -07:00
.gitattributes Initial commit. 2019-09-18 05:16:01 -07:00
.gitignore Upgrade to JDK 16, Kotlin 1.3.21 and Gradle 7.1.1 2021-07-27 14:41:16 -07:00
.gitlab-ci.yml Trying a different way to increase the metaspace. 2021-05-21 00:21:06 -07:00
bitbucket-pipelines.yml Upgraded to Kotlin 1.7.20 2022-09-30 22:40:48 -07:00
build.gradle.kts Cleaned up tests with assertk 2022-10-03 23:52:55 -07:00
gradlew Dependencies updates. Kotlin 1.5.30. 2021-08-25 09:04:47 -07:00
gradlew.bat Upgraded to Gradle 6.6 and Kotlin 1.4.0. 2020-08-18 00:31:13 -07:00
LICENSE.txt Updated dependencies and copyright. 2022-01-03 12:49:29 -08:00
pom.xml Upgraded to Kotlin 1.7.20 2022-09-30 22:40:48 -07:00
README.md Upgraded to Kotlin 1.7.20 2022-09-30 22:40:48 -07:00
settings.gradle.kts Upgrade to JDK 16, Kotlin 1.3.21 and Gradle 7.1.1 2021-07-27 14:41:16 -07:00
version.mustache Added version template. 2019-09-19 18:07:38 -07:00
version.properties Added support for snapshot. 2021-05-02 22:21:44 -07:00

License (3-Clause BSD) Release Maven Central

Quality Gate Status GitHub CI CircleCI

Akismet for Kotlin/Java

Akismet for Kotlin/Java/Android is a pretty complete and straightforward implementation of the Automattic's Akismet API, a free service which can be used to actively stop comments spam.

Examples (TL;DR)

Kotlin

val akismet = Akismet(apiKey = "YOUR_API_KEY", blog = "YOUR_BLOG_URL")
val comment = AkismetComment(userIp = "127.0.0.1", userAgent = "curl/7.29.0")

with(comment) {
    referrer = "https://www.google.com"
    type = AkismetComment.TYPE_COMMENT
    author = "admin"
    authorEmail = "test@test.com"
    authorUrl = "https://www.CheckOutMyCoolSite.com"
    dateGmt = Akismet.dateToGmt(Date())
    content = "It means a lot that you would take the time to review our software."
}
// ...

val isSpam = akismet.checkComment(comment)
if (isSpam) {
    // ...
}

View Full Example

Java

final Akismet akismet = new Akismet("YOUR_API_KEY", "YOUR_BLOG_URL");
final AkismetComment comment = new AkismetComment("127.0.0.1", "curl/7.29.0");

comment.setReferrer("https://www.google.com");
comment.setType(AkismetComment.TYPE_COMMENT);
comment.setAuthor("admin");
comment.setAuthorEmail("test@test.com");
comment.setAuthorUrl("https://www.CheckOutMyCoolSite.com");
comment.setDateGmt(Akismet.dateToGmt(new Date()));
comment.setContent("It means a lot that you would take the time to review our software.");
//...

final boolean isSpam = akismet.checkComment(comment);
if (isSpam) {
    // ...
}

View Full Example

Gradle

To use with Gradle, include the following dependency in your build file:

repositories {
    mavenCentral()
}

dependencies {
    implementation("net.thauvin.erik:akismet-kotlin:0.9.3")
}

Instructions for using with Maven, Ivy, etc. can be found on Maven Central.

HttpServletRequest

The more information is sent to Akismet, the more accurate the response is. An HttpServletRequest can be used as a parameter so that all the relevant information is automatically included.

AkismetComment(request = context.getRequest())

This will ensure that the user's IP, agent, referrer and various environment variables are automatically extracted from the request.

View Full Example

JSON

Since comments mis-identified as spam or ham can be submitted to Askimet to improve the service. A comment can be saved as a JSON object to be stored in a database, etc.

var json = comment.toJson()

At a latter time, the comment can then be submitted:

akismet.submitSpam(Akismet.jsonComment(json))

More...

If all else fails, there's always more Documentation.