]> git.lizzy.rs Git - furrybot-discord.git/commitdiff
Implement all random commands
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 6 Mar 2022 14:43:39 +0000 (15:43 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 6 Mar 2022 14:43:39 +0000 (15:43 +0100)
books.json [new file with mode: 0644]
german.json [new file with mode: 0644]
random.js

diff --git a/books.json b/books.json
new file mode 100644 (file)
index 0000000..8f50952
--- /dev/null
@@ -0,0 +1,16 @@
+[
+       "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"
+]
diff --git a/german.json b/german.json
new file mode 100644 (file)
index 0000000..5ae531d
--- /dev/null
@@ -0,0 +1,14 @@
+[
+       "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."
+]
index b336688b9be258c83af6024a1d2f12dc66c699e6..11664391fa7dc749b033ccb28d1ebff9a335de07 100644 (file)
--- a/random.js
+++ b/random.js
@@ -1,4 +1,9 @@
 const common = require("./common.js")
+const sha1 = require("sha1")
+const pseudoRandom = require("pseudo-random")
+
+const german = require("./german.json")
+const books = require("./books.json")
 
 module.exports = {
        rolldice: {
@@ -22,84 +27,20 @@ module.exports = {
                        .join(" ")
                )
        },
-       /*extinct: {
+       extinct: {
                func: (msg, [rawSpecies]) => {
-                       const species = common.uppercase(rawSpecies + (rawSpecies.slice(-1) == "s" ? "" : "s"))
-                       msg.reply(`${species} are ${"extinct"}`)
-               }
-       }*/
-}
-/*
-
-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",
+                       const species = common.uppercase((rawSpecies + (rawSpecies.slice(-1) == "s" ? "" : "s")).toLowerCase())
+                       msg.reply(`${species} are ${pseudoRandom(parseInt(sha1(species), 16) % 1e9).random() < 0.5 ? "" : "not "}extinct.`)
                }
-
-               furrybot.ping_message(name, books[math.random(#books)], furrybot.colors.system)
-       end,
+       },
+       german: {
+               func: msg => msg.reply(common.choose(german))
+       },
+       book: {
+               func: msg => msg.reply(common.choose(books))
+       },
+       video: {
+               func: msg => msg.reply("https://youtube.com/watch?v=dQw4w9WgXcQ")
+       },
 }
 
-furrybot.commands.video = {
-       func = function(name)
-               furrybot.ping_message(name, "https://youtube.com/watch?v=dQw4w9WgXcQ", furrybot.colors.system)
-       end,
-}
-*/