From e6de98c9ad48642f3ac673fc3730d20216db69f0 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Tue, 29 Mar 2022 11:38:02 -0600 Subject: [PATCH] utility: add charinfo --- src/modules/utility.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/modules/utility.js b/src/modules/utility.js index 4655256..7740192 100644 --- a/src/modules/utility.js +++ b/src/modules/utility.js @@ -60,7 +60,7 @@ const CUSTOM_EMOTE_REGEX = /<(?:\u200b|&)?(a)?:(\w+):(\d+)>/; const fetch = require("node-fetch"); const sharp = require("sharp"); -const {lookupUser} = require("../lib/utils.js"); +const {hastebin, lookupUser} = require("../lib/utils.js"); const {getNamesFromString} = require("../lib/unicode.js"); const avatar = new Command("avatar"); @@ -576,3 +576,28 @@ jumbo.callback = async function (msg, line) { } }; hf.registerCommand(jumbo); + +const charinfo = new Command("charinfo"); +charinfo.category = CATEGORY; +charinfo.description = "Get information about a set of characters."; +charinfo.usage = "[characters]"; +charinfo.addAlias("char"); +charinfo.callback = async function (msg, line) { + const names = getNamesFromString(line); + const chars = [...line]; + const lines = names + .map( + ([code, name], index) => + `\`\\u${code}\`: ${name} - ${chars[index]} - ` + ) + .join("\n"); + + if (lines.length > 2000) { + return `Output too long: ${hf.config.haste_provider}/${await hastebin( + lines + )}`; + } else { + return lines; + } +}; +hf.registerCommand(charinfo);