-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
84 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {Author, Blog, CheckResult, Client, Comment, CommentType} from "@cedx/akismet" | ||
import console from "node:console" | ||
|
||
# Checks a comment against the Akismet service. | ||
try | ||
author = new Author | ||
email: "[email protected]" | ||
ipAddress: "192.168.123.456" | ||
name: "John Doe" | ||
role: "guest" | ||
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36" | ||
|
||
comment = new Comment | ||
author: author | ||
date: new Date | ||
content: "A user comment." | ||
referrer: "https://github.com/cedx/akismet.js" | ||
type: CommentType.contactForm | ||
|
||
blog = new Blog | ||
charset: "UTF-8" | ||
languages: ["fr"] | ||
url: "https://www.yourblog.com" | ||
|
||
result = await new Client("123YourAPIKey", blog).checkComment comment | ||
console.log(if result is CheckResult.ham then "The comment is ham." else "The comment is spam.") | ||
|
||
catch error | ||
console.error if error instanceof Error then error.message else error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {Author, Blog, Client, Comment} from "@cedx/akismet" | ||
import console from "node:console" | ||
|
||
# Submits ham to the Akismet service. | ||
try | ||
blog = new Blog url: "https://www.yourblog.com" | ||
client = new Client "123YourAPIKey", blog | ||
|
||
comment = new Comment | ||
content: "I'm testing out the Service API." | ||
author: new Author | ||
ipAddress: "192.168.123.456" | ||
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36" | ||
|
||
await client.submitHam comment | ||
console.log "The comment was successfully submitted as ham." | ||
|
||
catch error | ||
console.error if error instanceof Error then error.message else error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {Author, Blog, Client, Comment} from "@cedx/akismet" | ||
import console from "node:console" | ||
|
||
# Submits spam to the Akismet service. | ||
try | ||
blog = new Blog url: "https://www.yourblog.com" | ||
client = new Client "123YourAPIKey", blog | ||
|
||
comment = new Comment | ||
content: "Spam!" | ||
author: new Author | ||
ipAddress: "192.168.123.456" | ||
userAgent: "Spam Bot/6.6.6" | ||
|
||
await client.submitSpam comment | ||
console.log "The comment was successfully submitted as spam." | ||
|
||
catch error | ||
console.error if error instanceof Error then error.message else error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {Blog, Client} from "@cedx/akismet" | ||
import console from "node:console" | ||
|
||
# Verifies an Akismet API key. | ||
try | ||
blog = new Blog url: "https://www.yourblog.com" | ||
client = new Client "123YourAPIKey", blog | ||
|
||
isValid = await client.verifyKey() | ||
console.log(if isValid then "The API key is valid." else "The API key is invalid.") | ||
|
||
catch error | ||
console.error if error instanceof Error then error.message else error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters