clean text before haiku

This commit is contained in:
osmarks 2023-06-14 15:02:14 +01:00
parent 04805ca1d5
commit 5849342584
1 changed files with 4 additions and 3 deletions

View File

@ -6,7 +6,7 @@ const pluralize = require("pluralize")
const { DB, SQL } = require("./db")
var client = new irc.Client(process.argv[2] || "207:1473:146:ae77:a3be:d39f:8e59:d256", "testbot", {
var client = new irc.Client(process.argv[2] || "irc.osmarks.net", "testbot", {
channels: ["#a", "#botrobots", "#b"],
userName: "testbot",
encoding: "utf8",
@ -117,8 +117,9 @@ client.addListener("message", (nick, channel, message, ev) => {
}
}
sylhist = R.takeLast(3, R.append(syllables(message), sylhist))
mhist = R.takeLast(50, R.append(message, mhist))
const messageContent = message.replace(/^(\s*[<\[][A-Za-z0-9_-]+[>\]]\s*)+/, "")
sylhist = R.takeLast(3, R.append(syllables(messageContent), sylhist))
mhist = R.takeLast(50, R.append(messageContent, mhist))
if (R.equals(sylhist, [5, 7, 5])) {
client.say(channel, "haiku detected!")
logEv("haiku", R.takeLast(3, mhist).join("\n"))