]> git.lizzy.rs Git - furrybot.git/blobdiff - bot.lua
Add new command (details censored)
[furrybot.git] / bot.lua
diff --git a/bot.lua b/bot.lua
index 9652cf8745f62df249036bfeb6225800c1d8c16d..2a1943f7034ebddda597f85be4f83d94a62c9cb1 100644 (file)
--- a/bot.lua
+++ b/bot.lua
@@ -1,6 +1,8 @@
 furrybot.commands = {}
 furrybot.requests = {}
+furrybot.unsafe_commands = {}
 
+local http, env, storage
 local C = minetest.get_color_escape_sequence
 
 furrybot.colors = {
@@ -34,22 +36,36 @@ function furrybot.error_message(player, error, detail)
        furrybot.ping_message(player, error .. (detail and furrybot.colors.detail .. " '" .. detail .. "'" .. furrybot.colors.error or "") .. ".", furrybot.colors.error)
 end
 
-function furrybot.recieve(msg)
-       msg = minetest.strip_colors(msg)
-       if msg:find("<") == 1 then
-               local idx = msg:find(">")
-               local player = msg:sub(2, idx - 1)
-               local message = msg:sub(idx + 3, #msg)
-               if message:find("!") == 1 then
-                       local args = message:sub(2, #message):split(" ")
-                       local cmd = table.remove(args, 1)
-                       local func = furrybot.commands[cmd]
-                       if func then
-                               func(player, unpack(args))
+function furrybot.parse_message(player, message, discord)
+       if message:find("!") == 1 then
+               local args = message:sub(2, #message):split(" ")
+               local cmd = table.remove(args, 1)
+               local func = furrybot.commands[cmd]
+               if func then
+                       if furrybot.unsafe_commands[cmd] and discord then
+                               furrybot.error_message(player, "Sorry, you cannot run this command from discord: ", cmd)
                        else
-                               furrybot.error_message(player, "Invalid command", cmd)
+                               func(player, unpack(args))
                        end
+               else
+                       furrybot.error_message(player, "Invalid command", cmd)
+               end
+       end
+end
+
+function furrybot.reload()
+       local func, err = env.loadfile("clientmods/furrybot/bot.lua")
+       if func then
+               local old_fb = table.copy(furrybot)
+               local status, init = pcall(func)
+               if status then
+                       init(http, env, storage)
+               else
+                       furrybot = old_fb
+                       return false, furrybot.colors.error .. "Error: " .. furrybot.colors.detail .. init
                end
+       else
+               return false, furrybot.colors.error .. "Syntax error: " .. furrybot.colors.detail .. err
        end
 end
 
@@ -78,15 +94,15 @@ function furrybot.choose(list, color)
 end
 
 function furrybot.random(min, max, color)
-       return furrybot.colors.random .. math.random(#list) .. color
+       return furrybot.colors.random .. math.random(min, max) .. color
 end
 
 function furrybot.http_request(url, name, callback)
-       furrybot.http.fetch({url = url}, function(res)
+       http.fetch({url = url}, function(res)
                if res.succeeded then
                        callback(res.data)
                else
-                       furrybot.ping_player_error(name, "Request failed with code", res.code)
+                       furrybot.error_message(name, "Request failed with code", res.code)
                end
        end)
 end
@@ -115,7 +131,7 @@ function furrybot.repeat_string(str, times)
        return msg
 end
 
-function furrybot.simple_rpg_command(action)
+function furrybot.interactive_rpg_command(action)
        return function(name, target)
                if furrybot.online_or_error(name, target) then
                        furrybot.send(name .. " " .. action .. " " .. target .. ".", furrybot.colors.rpg)
@@ -123,6 +139,12 @@ function furrybot.simple_rpg_command(action)
        end
 end
 
+function furrybot.solo_rpg_command(action)
+       return function(name)
+               furrybot.send(name .. " " .. action .. ".", furrybot.colors.rpg)
+       end
+end
+
 function furrybot.request_command(on_request, on_accept)
        return function(name, target)
                if furrybot.online_or_error(name, target) and on_request(name, target) ~= false then
@@ -136,15 +158,15 @@ end
 
 function furrybot.get_money(name)
        local key = name .. ".money"
-       if furrybot.storage:contains(key) then
-               return furrybot.storage:get_int(key)
+       if storage:contains(key) then
+               return storage:get_int(key)
        else
                return 100
        end
 end
 
 function furrybot.set_money(name, money)
-       furrybot.storage:set_int(name .. ".money", money)
+       storage:set_int(name .. ".money", money)
 end
 
 function furrybot.add_money(name, add)
@@ -167,6 +189,10 @@ function furrybot.money(money, color)
        return furrybot.colors.money .. "$" .. money .. color
 end
 
+function furrybot.get_ascii_dick(name)
+       return minetest.rainbow(furrybot.repeat_string("=", furrybot.strrandom(name, 31242, 2, 10)) .. "D")
+end
+
 -- Commands
 
 -- system
@@ -187,6 +213,7 @@ function furrybot.commands.accept(name)
                furrybot.error_message(name, "Nothing to accept")
        end
 end
+furrybot.unsafe_commands.accept = true
 
 function furrybot.commands.deny(name)
        local tbl = furrybot.requests[name]
@@ -197,6 +224,7 @@ function furrybot.commands.deny(name)
                furrybot.error_message(name, "Nothing to deny")
        end
 end
+furrybot.unsafe_commands.deny = true
 
 -- don't bug players that are running ClamityBot commands from discord
 function furrybot.commands.status()
@@ -206,13 +234,29 @@ function furrybot.commands.cmd()
 end
 
 -- rpg
-furrybot.commands.hug = furrybot.simple_rpg_command("hugs")
-furrybot.commands.cuddle = furrybot.simple_rpg_command("cuddles")
-furrybot.commands.kiss = furrybot.simple_rpg_command("kisses")
-furrybot.commands.hit = furrybot.simple_rpg_command("hits")
-furrybot.commands.slap = furrybot.simple_rpg_command("slaps")
-furrybot.commands.beat = furrybot.simple_rpg_command("beats")
-furrybot.commands.lick = furrybot.simple_rpg_command("licks")
+furrybot.commands.cry = furrybot.solo_rpg_command("cries")
+furrybot.commands.laugh = furrybot.solo_rpg_command("laughs")
+furrybot.commands.confused = furrybot.solo_rpg_command("is confused")
+furrybot.commands.smile = furrybot.solo_rpg_command("smiles")
+furrybot.commands.hug = furrybot.interactive_rpg_command("hugs")
+furrybot.commands.cuddle = furrybot.interactive_rpg_command("cuddles")
+furrybot.commands.kiss = furrybot.interactive_rpg_command("kisses")
+furrybot.commands.hit = furrybot.interactive_rpg_command("hits")
+furrybot.commands.slap = furrybot.interactive_rpg_command("slaps")
+furrybot.commands.beat = furrybot.interactive_rpg_command("beats")
+furrybot.commands.lick = furrybot.interactive_rpg_command("licks")
+
+furrybot.commands.smellfeet = furrybot.request_command(function(name, target)
+       furrybot.ping_message(target, name .. " wants to smell your feet. Type !accept to accept or !deny to deny.", furrybot.colors.system)
+end, function(name, target)
+       furrybot.ping_message(name, " you are smelling " .. target .. "'s feet. They are kinda stinky!", furrybot.colors.rpg)
+end)
+
+furrybot.commands.blowjob = furrybot.request_command(function(name, target)
+       furrybot.ping_message(target, name .. " wants to suck your dick. Type !accept to accept or !deny to deny.", furrybot.colors.system)
+end, function(name, target)
+       furrybot.send(name .. " is sucking " .. target .. "'s cock. ˣoˣ IT'S SO HUGE", furrybot.colors.rpg)
+end)
 
 furrybot.commands.sex = furrybot.request_command(function(name, target)
        furrybot.ping_message(target, name .. " wants to have sex with you. Type !accept to accept or !deny to deny.", furrybot.colors.system)
@@ -222,44 +266,116 @@ end)
 furrybot.commands.bang = furrybot.commands.sex
 furrybot.commands.fuck = furrybot.commands.sex
 
+furrybot.commands.cum = function(name)
+       furrybot.send(name .. " is cumming: " .. furrybot.get_ascii_dick(name) .. C("#FFFFFF") .. furrybot.repeat_string("~", math.random(1, 10)), furrybot.colors.rpg)
+end
+
 furrybot.commands.marry = furrybot.request_command(function(name, target)
-       if furrybot.storage:contains(name .. ".partner", target) then
-               furrybot.error_message(name, "You are already married to", furrybot.storage:get_string(name .. ".partner"))
+       if storage:contains(name .. ".partner", target) then
+               furrybot.error_message(name, "You are already married to", storage:get_string(name .. ".partner"))
                return false
-       elseif furrybot.storage:contains(target .. ".partner", name) then
-               furrybot.error_message(name, target .. " is already married to", furrybot.storage:get_string(name .. ".partner"))
+       elseif storage:contains(target .. ".partner", name) then
+               furrybot.error_message(name, target .. " is already married to", storage:get_string(target .. ".partner"))
                return false
        else
                furrybot.ping_message(target, name .. " proposes to you. Type !accept to accept or !deny to deny.", furrybot.colors.system)
        end
 end, function(name, target)
-       furrybot.storage:set_string(name .. ".partner", target)
-       furrybot.storage:set_string(target .. ".partner", name)
+       storage:set_string(name .. ".partner", target)
+       storage:set_string(target .. ".partner", name)
        furrybot.send("Congratulations, " .. furrybot.ping(name, furrybot.colors.rpg) .. "&" .. furrybot.ping(target, furrybot.colors.rpg) .. ", you are married. You may now kiss :).", furrybot.colors.rpg)
 end)
 furrybot.commands.propose = furrybot.commands.marry
+furrybot.unsafe_commands.marry = true
+furrybot.unsafe_commands.propose = true
 
 function furrybot.commands.divorce(name)
-       if furrybot.storage:contains(name .. ".partner") then
-               local partner = furrybot.storage:get_string(name .. ".partner")
-               furrybot.storage:set_string(name .. ".partner", "")
-               furrybot.storage:set_string(partner .. ".partner", "")
+       if storage:contains(name .. ".partner") then
+               local partner = storage:get_string(name .. ".partner")
+               storage:set_string(name .. ".partner", "")
+               storage:set_string(partner .. ".partner", "")
                furrybot.ping_message(name, "divorces from " .. partner .. " :(", furrybot.colors.rpg)
        else
                furrybot.error_message(name, "You are not married")
        end
 end
+furrybot.unsafe_commands.divorce = true
 
 function furrybot.commands.partner(name, target)
        target = target or name
-       if furrybot.storage:contains(target .. ".partner") then
-               furrybot.ping_message(name, (target == name and "You are" or target .. " is") .. " married to " .. furrybot.storage:get_string(target .. ".partner"), furrybot.colors.system)
+       if storage:contains(target .. ".partner") then
+               furrybot.ping_message(name, (target == name and "You are" or target .. " is") .. " married to " .. storage:get_string(target .. ".partner"), furrybot.colors.system)
        else
                furrybot.error_message(name, (target == name and "You are" or target .. " is") .. " not married")
        end
 end
 furrybot.commands.married = furrybot.commands.partner
 
+furrybot.kill_deathmessages = {
+       "%s walked into fire whilst fighting %s",
+       "%s was struck by lightning whilst fighting %s",
+       "%s was burnt to a crisp whilst fighting %s",
+       "%s tried to swim in lava to escape %s",
+       "%s walked into danger zone due to %s",
+       "%s suffocated in a wall whilst fighting %s",
+       "%s drowned whilst trying to escape %s",
+       "%s starved to death whilst fighting %s",
+       "%s walked into a cactus whilst trying to escape %s",
+       "%s hit the ground too hard whilst trying to escape %s",
+       "%s experienced kinetic energy whilst trying to escape %s",
+       "%s didn't want to live in the same world as %s",
+       "%s died because of %s",
+       "%s was killed by magic whilst trying to escape %s",
+       "%s was killed by %s using magic",
+       "%s was roasted in dragon breath by %s",
+       "%s withered away whilst fighting %s",
+       "%s was shot by a skull from %s",
+       "%s was squashed by a falling anvil whilst fighting %s",
+       "%s was slain by %s",
+       "%s was shot by %s",
+       "%s was fireballed by %s",
+       "%s was killed trying to hurt %s",
+       "%s was blown up by %s",
+       "%s was squashed by %s",
+}
+
+furrybot.deathmessages = {
+       "%s went up in flames",
+       "%s was struck by lightning",
+       "%s burned to death",
+       "%s tried to swim in lava",
+       "%s discovered the floor was lava",
+       "%s suffocated in a wall",
+       "%s drowned",
+       "%s starved to death",
+       "%s was pricked to death",
+       "%s hit the ground too hard",
+       "%s experienced kinetic energy",
+       "%s fell out of the world",
+       "%s died",
+       "%s was killed by magic",
+       "%s was roasted in dragon breath",
+       "%s withered away",
+       "%s was squashed by a falling anvil",
+       "%s blew up",
+       "%s was squished too much",
+       "%s went off with a bang",
+}
+
+function furrybot.commands.kill(name, target)
+       if furrybot.online_or_error(name, target, true) then
+               if name == target then
+                       furrybot.send(string.format("%s died due to lack of friends", target), furrybot.colors.rpg)
+               else
+                       furrybot.send(string.format(furrybot.kill_deathmessages[math.random(#furrybot.kill_deathmessages)], target, name), furrybot.colors.rpg)
+               end
+       end
+end
+
+function furrybot.commands.die(name)
+       furrybot.send(string.format(furrybot.deathmessages[math.random(#furrybot.deathmessages)], name), furrybot.colors.rpg)
+end
+
 -- misc
 function furrybot.commands.rolldice(name)
        furrybot.ping_message(name, "rolled a dice and got a " .. furrybot.random(1, 6, furrybot.colors.system) .. ".", furrybot.colors.system)
@@ -280,13 +396,15 @@ end
 
 function furrybot.commands.dicksize(name, target)
        target = target or name
-       local size = furrybot.strrandom(target, 31242, 2, 10)
-       local dick = furrybot.repeat_string("=", size) .. "D"
-       furrybot.send(dick .. furrybot.colors.system .. "   <= " .. furrybot.ping(target, furrybot.colors.system) .. "'s Dick", C("#FF4DE1"))
+       furrybot.send(furrybot.get_ascii_dick(target) .. furrybot.colors.system .. "   ← " .. furrybot.ping(target, furrybot.colors.system) .. "'s Dick", C("#FF4DE1"))
 end
 furrybot.commands.cocksize = furrybot.commands.dicksize
 
 -- fun
+function furrybot.commands.amogus(name)
+       furrybot.ping_message(name, "YOU KINDA SUS MAN", furrybot.colors.fun)
+end
+
 function furrybot.commands.verse(name)
        furrybot.json_http_request("https://labs.bible.org/api/?type=json&passage=random", name, function(data)
                furrybot.send(data.text .. furrybot.colors.info .. "[" .. data.bookname .. " " .. data.chapter .. "," .. data.verse .. "]", furrybot.colors.fun)
@@ -295,9 +413,9 @@ end
 
 function furrybot.commands.define(name, word)
        if word then
-               furrybot.json_http_request("https://api.dictionaryapi.dev/api/v1/entries/en_US/" .. word, name, function(data)
+               furrybot.json_http_request("https://api.dictionaryapi.dev/api/v1/entries/en_US/" .. word:gsub("computer", "person"), name, function(data)
                        local meaning = data.meaning
-                       local selected = meaning.exclamation or meaning.noun or meaning.verb or meaning.adjective or meaning["transitive verb"] or meaning.adverb or meaning["relative adverb"]
+                       local selected = meaning.abbreviation or meaning["cardinal number"] or meaning.exclamation or meaning.noun or meaning.verb or meaning.adjective or meaning["transitive verb"] or meaning.adverb or meaning["relative adverb"] or meaning.preposition
                        if not selected then
                                print(dump(meaning))
                                furrybot.error_message(name, "Error in parsing response")
@@ -360,6 +478,7 @@ function furrybot.commands.pay(name, target, number)
                end
        end
 end
+furrybot.unsafe_commands.pay = true
 
 -- send load message
 furrybot.send("FurryBot - " .. C("#170089") .. "https://github.com/EliasFleckenstein03/furrybot", furrybot.colors.system)
@@ -369,3 +488,7 @@ if furrybot.loaded then
 else
        furrybot.loaded = true
 end
+
+return function(_http, _env, _storage)
+       http, env, storage = _http, _env, _storage
+end