]> git.lizzy.rs Git - furrybot.git/commitdiff
Add book command and sort help command output alphabethically
authorElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 13 Sep 2021 15:16:59 +0000 (17:16 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Mon, 13 Sep 2021 15:16:59 +0000 (17:16 +0200)
bot.lua
random.lua

diff --git a/bot.lua b/bot.lua
index 16b872f5a303466180d0f9eb6eb8a37839d01e3a..447ca65d411b5a54ad190bc61de701ed2e4bf837 100644 (file)
--- a/bot.lua
+++ b/bot.lua
@@ -162,11 +162,15 @@ end
 -- General purpose commands
 
 function furrybot.commands.help()
-       local keys = {}
-       for k in pairs(furrybot.commands) do
-               table.insert(keys, k)
+       local commands = {}
+
+       for cmd in pairs(furrybot.commands) do
+               table.insert(commands, cmd)
        end
-       furrybot.send("Available commands: " .. table.concat(keys, ", "), furrybot.colors.system)
+
+       table.sort(commands)
+
+       furrybot.send("Available commands: " .. table.concat(commands, ", "), furrybot.colors.system)
 end
 
 function furrybot.commands.accept(name)
index d828ac31b3f1c2ec01baf683ae6ad063c01e317c..514fec892da382ba5ceef8829e1d51ed072ade6a 100644 (file)
@@ -77,6 +77,33 @@ function furrybot.commands.german(name)
        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
 
+function furrybot.commands.color(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
+
+function furrybot.commands.book(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
+
 return function(_http, _env, _storage)
        http, env, storage = _http, _env, _storage
 end