Skip to content

Commit

Permalink
chan added flag support
Browse files Browse the repository at this point in the history
  • Loading branch information
Supinic committed Sep 19, 2024
1 parent 3454336 commit a7fce9d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions commands/chan/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const { linkRegex } = require("../../utils/regexes.js");

const charToFlagfEmoji = (char) => {
return "\uD83C" + String.fromCharCode(56741 + char.charCodeAt(0));
};
const FOUR_CHAN_REPLACEMENTS = [
{ regex: /desu/ig, string: "tbh" },
{ regex: /baka/ig, string: "smh" },
Expand Down Expand Up @@ -219,7 +222,8 @@ module.exports = {
: null,
file: (typeof i.filename !== "undefined")
? `https://i.4cdn.org/${board.name}/${i.tim}${i.ext}`
: null
: null,
country: i.country ?? null
}));

await this.setCacheData(postKey, postList, {
Expand Down Expand Up @@ -250,18 +254,22 @@ module.exports = {
}
}

const flagEmoji = (post.country)
? charToFlagfEmoji(post.country[0]) + charToFlagfEmoji(post.country[1])
: "";

if (resultType === "file") {
return {
reply: (context.params.textOnly)
? `${post.file} ${post.content}`
: `${post.ID} (posted ${delta}): ${post.file} ${post.content ?? ""}`
: `${post.ID} ${flagEmoji} (posted ${delta}): ${post.file} ${post.content ?? ""}`
};
}
else if (resultType === "content") {
return {
reply: (context.params.textOnly)
? `${post.content}`
: `${post.ID} (posted ${delta}): ${post.content ?? ""}`
: `${post.ID} ${flagEmoji} (posted ${delta}): ${post.content ?? ""}`
};
}
}),
Expand Down

0 comments on commit a7fce9d

Please sign in to comment.