diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-03-10 11:33:03 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-03-10 11:33:03 +0100 |
commit | 519555e43dacd8403098877c24afbbae8b8b7736 (patch) | |
tree | d1b042271baaa2488c347e21d496a7c36359eaa6 /bot.lua | |
parent | 12a38b7bc714899f52178becd15f29ced348e44a (diff) | |
download | furrybot-519555e43dacd8403098877c24afbbae8b8b7736.tar.xz |
Add joke command
Diffstat (limited to 'bot.lua')
-rw-r--r-- | bot.lua | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -72,8 +72,9 @@ function furrybot.http_request(url, name, callback) end function furrybot.json_http_request(url, name, callback) - furrybot.http_request(url, name, function(data) - callback(minetest.parse_json(data)[1]) + furrybot.http_request(url, name, function(raw) + local data = minetest.parse_json(raw) + callback(data[1] or data) end) end @@ -209,6 +210,17 @@ end furrybot.commands.dicksize = furrybot.commands.cocksize +function furrybot.commands.joke(name, first, last) + if not first then + first = "Chuck" + last = "Norris" + end + furrybot.json_http_request("http://api.icndb.com/jokes/random?firstName=" .. first .. "&lastName=" .. (last or ""), name, function(data) + local joke = data.value.joke:gsub(""", "\""):gsub(" ", " ") + furrybot.send(joke) + end) +end + if furrybot.loaded then furrybot.send("Reloaded") else |