Moved from Gradle to bld

This commit is contained in:
Erik C. Thauvin 2023-11-12 15:12:11 -08:00
parent 7ef1c441e6
commit d5e21dd3a1
194 changed files with 2185 additions and 1983 deletions

View file

@ -0,0 +1,66 @@
package com.example
import net.thauvin.erik.akismet.Akismet
import net.thauvin.erik.akismet.AkismetComment
import java.util.Date
import kotlin.system.exitProcess
fun main(args: Array<String>) {
if (args.size == 1 && args[0].isNotEmpty()) {
val akismet = Akismet(apiKey = args[0], blog = "https://yourblogdomainname.com/blog/")
val comment = AkismetComment(userIp = "127.0.0.1", userAgent = "curl/7.29.0")
with(comment) {
isTest = true
referrer = "https://www.google.com"
permalink = "${akismet.blog}post=1"
type = AkismetComment.TYPE_COMMENT
author = "admin"
authorEmail = "test@test.com"
authorUrl = "https://www.CheckOutMyCoolSite.com"
dateGmt = Akismet.dateToGmt(Date())
// userRole = AkismetComment.ADMIN_ROLE
content = "It means a lot that you would take the time to review our software. Thanks again."
}
// with(akismet.logger) {
// addHandler(ConsoleHandler().apply { level = Level.FINE })
// level = Level.FINE
// }
if (akismet.verifyKey()) {
val isSpam = akismet.checkComment(comment)
if (isSpam) {
println("The comment is SPAM according to Akismet.")
val hasBeenSubmitted = akismet.submitSpam(comment)
if (hasBeenSubmitted) {
println("The comment was successfully submitted as SPAM to Akismet.")
} else {
System.err.println(akismet.errorMessage)
}
} else {
println("The comment is not SPAM according to Akismet.")
val hasBeenSubmitted = akismet.submitHam(comment)
if (hasBeenSubmitted) {
println("The comment was successfully submitted as HAM to Akismet.")
} else {
System.err.println(akismet.errorMessage)
}
}
} else {
System.err.println("Invalid API Key.")
exitProcess(1)
}
exitProcess(0)
} else {
System.err.println("Please specify an API key.")
exitProcess(1)
}
}