From: Elias Fleckenstein Date: Mon, 13 Sep 2021 15:16:59 +0000 (+0200) Subject: Add book command and sort help command output alphabethically X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=008e302ea3ee1055cd624c9ad645b981b0271822;p=furrybot.git Add book command and sort help command output alphabethically --- diff --git a/bot.lua b/bot.lua index 16b872f..447ca65 100644 --- 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) diff --git a/random.lua b/random.lua index d828ac3..514fec8 100644 --- a/random.lua +++ b/random.lua @@ -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