]> git.lizzy.rs Git - furrybot-discord.git/commitdiff
Fully ping proof
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 6 Mar 2022 13:09:38 +0000 (14:09 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 6 Mar 2022 13:09:38 +0000 (14:09 +0100)
basic.js
common.js
init.js
random.js [new file with mode: 0644]
random.lua [deleted file]

index 6c45b041bd65a901716715c7d857a76305426bfc..f34f8bb5990fa215c9f4f249240db4c535027557 100644 (file)
--- a/basic.js
+++ b/basic.js
@@ -5,8 +5,6 @@ module.exports = {
                params: "[<command>]",
                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]
 
index d06566d212406b3b34097f73eb33b9ac5b201b1d..5bb4cff5badbfe47f3bb2a39ad2c7278c0d722de 100644 (file)
--- 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 b9fc2e67be53b778ae2a071e3f9c8ca61f91d29a..da34ff0b41f86136201b6a6f29e9d2ba75386921 100644 (file)
--- 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.js b/random.js
new file mode 100644 (file)
index 0000000..11c387e
--- /dev/null
+++ b/random.js
@@ -0,0 +1,137 @@
+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)
+       end,
+}
+
+furrybot.commands.coinflip = {
+       func = function(name)
+               furrybot.ping_message(name, "flipped a coin and got " .. furrybot.choose({"Heads", "Tails"}, furrybot.colors.system) .. ".", furrybot.colors.system)
+       end,
+}
+
+furrybot.commands.choose = {
+       func = function(name, ...)
+               local options = {...}
+               if #options > 1 then
+                       furrybot.ping_message(name, "I choose " .. furrybot.choose(options, "", furrybot.colors.system) .. ".", furrybot.colors.system)
+               else
+                       furrybot.error_message(name, "Not enough options")
+               end
+       end,
+}
+
+furrybot.commands.uwu = {
+       func = function()
+               local msg = ""
+
+               local m = math.random(10)
+
+               for i = 1, m do
+                       local u_list = {"u", "ü", "o", "ö"}
+
+                       local u = u_list[math.random(#u_list)]
+                       local w = "w"
+
+                       if math.random() < 0.5 then
+                               u = u:upper()
+                       end
+
+                       if math.random() < 0.5 then
+                               w = w:upper()
+                       end
+
+                       msg = msg .. u .. w .. u
+
+                       if i ~= m then
+                               msg = msg .. " "
+                       end
+               end
+
+               furrybot.send(msg, furrybot.colors.system)
+       end,
+}
+
+furrybot.commands.extinct = {
+       func = function(name, species)
+               if species then
+                       species = furrybot.uppercase(species .. (species:sub(#species, #species):lower() == "s" and "" or "s"))
+                       furrybot.ping_message(name, species  .. " are " .. (furrybot.strrandom(species, 420, 0, 1) == 0 and "not " or "") .. "extinct." , furrybot.colors.system)
+               else
+                       furrybot.error_message(name, "You need to specify a species")
+               end
+       end,
+}
+
+furrybot.commands.german = {
+       func = function(name)
+               local messages = {
+                       "Schnauze!",
+                       "Sprich Deutsch, du Hurensohn!",
+                       "NEIN NEIN NEIN NEIN NEIN NEIN",
+                       "Deine Mutter",
+                       "Das war ein BEFEHL!",
+                       "Das bleibt hier alles so wie das hier ist!",
+                       "Scheißße",
+                       "Digga was falsch bei dir",
+                       "Lass mich deine Arschfalten sehen",
+                       "Krieg mal deinen Ödipuskomplex unter Kontrolle",
+                       "Meine Nudel ist 30cm lang und al dente",
+                       "Wie die Nase eines Mannes, so auch sein Johannes.",
+               }
+
+               local msg = messages[math.random(#messages)]
+               local stripe = math.floor(#msg / 3)
+
+               furrybot.ping_message(name, msg:sub(1, stripe) .. C("red") .. msg:sub(stripe + 1, stripe * 2) .. C("yellow") .. msg:sub(stripe * 2 + 1, #msg), C("black"))
+       end,
+}
+
+furrybot.commands.color = {
+       func = function(name)
+               local color = string.format("#%06x", math.random(16777216) - 1):upper()
+
+               furrybot.ping_message(name, "Here's your color: " .. C(color) .. color, furrybot.colors.system)
+       end,
+}
+
+furrybot.commands.book = {
+       func = function(name)
+               local books = {
+                       "Johann Wolfgang von Goethe - Faust, Der Tragödie Erster Teil",
+                       "Johann Wolfgang von Goethe - Faust, Der Tragödie Zweiter Teil",
+                       "Karl Marx & Friedrich Engels - The Communist Manifesto",
+                       "Brian Kernhigan & Dennis Ritchie - The C Programming Language",
+                       "Heinrich Heine - Die Harzreise",
+                       "Johann Wolfgang von Goethe - Die Leiden des jungen Werther",
+                       "Friedrich Schiller - Die Jungfrau von Orleans",
+                       "Theodor Fontane - Irrungen, Wirrungen",
+                       "Friedrich Schiller - Die Räuber",
+                       "Theodor Storm - Der Schimmelreiter",
+                       "Josef von Eichendorff - Aus dem Leben eines Taugenichts",
+                       "Richard Esplin - Advanced Linux Programming",
+                       "Joey de Vries - Learn OpenGL",
+                       "Gerard Beekmans - Linux From Scratch",
+               }
+
+               furrybot.ping_message(name, books[math.random(#books)], furrybot.colors.system)
+       end,
+}
+
+furrybot.commands.video = {
+       func = function(name)
+               furrybot.ping_message(name, "https://youtube.com/watch?v=dQw4w9WgXcQ", furrybot.colors.system)
+       end,
+}
+*/
diff --git a/random.lua b/random.lua
deleted file mode 100644 (file)
index aad94eb..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-local http, env, storage
-local C = minetest.get_color_escape_sequence
-
-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)
-       end,
-}
-
-furrybot.commands.coinflip = {
-       func = function(name)
-               furrybot.ping_message(name, "flipped a coin and got " .. furrybot.choose({"Heads", "Tails"}, furrybot.colors.system) .. ".", furrybot.colors.system)
-       end,
-}
-
-furrybot.commands.choose = {
-       func = function(name, ...)
-               local options = {...}
-               if #options > 1 then
-                       furrybot.ping_message(name, "I choose " .. furrybot.choose(options, "", furrybot.colors.system) .. ".", furrybot.colors.system)
-               else
-                       furrybot.error_message(name, "Not enough options")
-               end
-       end,
-}
-
-furrybot.commands.uwu = {
-       func = function()
-               local msg = ""
-
-               local m = math.random(10)
-
-               for i = 1, m do
-                       local u_list = {"u", "ü", "o", "ö"}
-
-                       local u = u_list[math.random(#u_list)]
-                       local w = "w"
-
-                       if math.random() < 0.5 then
-                               u = u:upper()
-                       end
-
-                       if math.random() < 0.5 then
-                               w = w:upper()
-                       end
-
-                       msg = msg .. u .. w .. u
-
-                       if i ~= m then
-                               msg = msg .. " "
-                       end
-               end
-
-               furrybot.send(msg, furrybot.colors.system)
-       end,
-}
-
-furrybot.commands.extinct = {
-       func = function(name, species)
-               if species then
-                       species = furrybot.uppercase(species .. (species:sub(#species, #species):lower() == "s" and "" or "s"))
-                       furrybot.ping_message(name, species  .. " are " .. (furrybot.strrandom(species, 420, 0, 1) == 0 and "not " or "") .. "extinct." , furrybot.colors.system)
-               else
-                       furrybot.error_message(name, "You need to specify a species")
-               end
-       end,
-}
-
-furrybot.commands.german = {
-       func = function(name)
-               local messages = {
-                       "Schnauze!",
-                       "Sprich Deutsch, du Hurensohn!",
-                       "NEIN NEIN NEIN NEIN NEIN NEIN",
-                       "Deine Mutter",
-                       "Das war ein BEFEHL!",
-                       "Das bleibt hier alles so wie das hier ist!",
-                       "Scheißße",
-                       "Digga was falsch bei dir",
-                       "Lass mich deine Arschfalten sehen",
-                       "Krieg mal deinen Ödipuskomplex unter Kontrolle",
-                       "Meine Nudel ist 30cm lang und al dente",
-                       "Wie die Nase eines Mannes, so auch sein Johannes.",
-               }
-
-               local msg = messages[math.random(#messages)]
-               local stripe = math.floor(#msg / 3)
-
-               furrybot.ping_message(name, msg:sub(1, stripe) .. C("red") .. msg:sub(stripe + 1, stripe * 2) .. C("yellow") .. msg:sub(stripe * 2 + 1, #msg), C("black"))
-       end,
-}
-
-furrybot.commands.color = {
-       func = function(name)
-               local color = string.format("#%06x", math.random(16777216) - 1):upper()
-
-               furrybot.ping_message(name, "Here's your color: " .. C(color) .. color, furrybot.colors.system)
-       end,
-}
-
-furrybot.commands.book = {
-       func = function(name)
-               local books = {
-                       "Johann Wolfgang von Goethe - Faust, Der Tragödie Erster Teil",
-                       "Johann Wolfgang von Goethe - Faust, Der Tragödie Zweiter Teil",
-                       "Karl Marx & Friedrich Engels - The Communist Manifesto",
-                       "Brian Kernhigan & Dennis Ritchie - The C Programming Language",
-                       "Heinrich Heine - Die Harzreise",
-                       "Johann Wolfgang von Goethe - Die Leiden des jungen Werther",
-                       "Friedrich Schiller - Die Jungfrau von Orleans",
-                       "Theodor Fontane - Irrungen, Wirrungen",
-                       "Friedrich Schiller - Die Räuber",
-                       "Theodor Storm - Der Schimmelreiter",
-                       "Josef von Eichendorff - Aus dem Leben eines Taugenichts",
-                       "Richard Esplin - Advanced Linux Programming",
-                       "Joey de Vries - Learn OpenGL",
-                       "Gerard Beekmans - Linux From Scratch",
-               }
-
-               furrybot.ping_message(name, books[math.random(#books)], furrybot.colors.system)
-       end,
-}
-
-furrybot.commands.video = {
-       func = function(name)
-               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