From 407a6f66daebca35fb355ead2c0dc65e7c80fc68 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 6 Mar 2022 14:09:38 +0100 Subject: [PATCH] Fully ping proof --- basic.js | 2 -- common.js | 6 ++---- init.js | 7 +++---- random.lua => random.js | 19 ++++++++++++------- 4 files changed, 17 insertions(+), 17 deletions(-) rename random.lua => random.js (91%) diff --git a/basic.js b/basic.js index 6c45b04..f34f8bb 100644 --- a/basic.js +++ b/basic.js @@ -5,8 +5,6 @@ module.exports = { params: "[]", help: "Display help for a commands or show list of available commands", func: (msg, [cmd], {commands}) => { - cmd = cmd && common.stripPings(cmd) - if (cmd) { let def = commands[cmd] diff --git a/common.js b/common.js index d06566d..5bb4cff 100644 --- a/common.js +++ b/common.js @@ -2,8 +2,8 @@ const fs = require("fs") const google_images = require("free-google-images") const getPing = module.exports.getPing = (msg, ping, allowSelf) => { - if (ping && ping.startsWith("<@!") && ping.endsWith(">")) { - const id = ping.slice("<@!".length, -">".length) + if (ping && ping.startsWith("<\\@!") && ping.endsWith(">")) { + const id = ping.slice("<\\@!".length, -">".length) if (!allowSelf && id == msg.author.id) { msg.reply("Please mention a user other than yourself") @@ -104,5 +104,3 @@ module.exports.listChangeCommand = (action, list, status) => new Object({ } } }) - -module.exports.stripPings = str => str.replace(/@/g, "\@") diff --git a/init.js b/init.js index b9fc2e6..da34ff0 100644 --- a/init.js +++ b/init.js @@ -16,8 +16,8 @@ let fb = { client.on("messageCreate", msg => { if (msg.author.id != client.user.id && msg.content.startsWith("!") && !fb.ignored[msg.author.id]) { - let args = msg.content.slice(1).split(" ") - let cmd = common.stripPings(args.shift()) + let args = msg.content.replace(/@/g, "\\@").slice(1).split(" ") + let cmd = args.shift() let def = fb.commands[cmd] if (def) { @@ -31,8 +31,7 @@ client.on("messageCreate", msg => { } }) -//const modules = ["random"] -const modules = ["basic", "bullshit", "marriage", "http", "roleplay", "death", "economy", "waifu", "operator", "nsfw"] +const modules = ["basic", "bullshit", "marriage", "http", "roleplay", "death", "economy", "waifu", "operator", "nsfw", "random"] for (let f of modules) { let m = require(`./${f}.js`) diff --git a/random.lua b/random.js similarity index 91% rename from random.lua rename to random.js index aad94eb..11c387e 100644 --- a/random.lua +++ b/random.js @@ -1,6 +1,14 @@ -local http, env, storage -local C = minetest.get_color_escape_sequence - +const common = require("./common.js") + +module.exports = { + rolldice: { + func: msg => msg.channel.send(`<@!${msg.author.id}> rolled a dice and got a ${1 + Math.floor(Math.random() * 6)}.`) + }, + coinflip: { + func: msg => msg.channel.send(`<@!${msg.author.id}> flipped a coin and got ${common.choose(["Heads", "Tails"])}.`) + } +} +/* furrybot.commands.rolldice = { func = function(name) furrybot.ping_message(name, "rolled a dice and got a " .. furrybot.random(1, 6, furrybot.colors.system) .. ".", furrybot.colors.system) @@ -126,7 +134,4 @@ furrybot.commands.video = { furrybot.ping_message(name, "https://youtube.com/watch?v=dQw4w9WgXcQ", furrybot.colors.system) end, } - -return function(_http, _env, _storage) - http, env, storage = _http, _env, _storage -end +*/ -- 2.44.0