3 local C = minetest.get_color_escape_sequence
5 function furrybot.send(msg, color)
6 minetest.send_chat_message("/me " .. C("#00FF3C") .. "[" .. C(color or "#FFFA00") .. msg .. C("#00FF3C") .. "]")
9 function furrybot.ping(player)
10 return C("#00DCFF") .. "@" .. player .. C("#FFFA00")
13 function furrybot.ping_player(player, message)
14 furrybot.send(furrybot.ping(player) .. ": " .. message)
17 function furrybot.ping_player_error(player, err, detail)
18 furrybot.ping_player(player, C("#D70029") .. " " .. err .. (detail and C("#FF6683") .. " '" .. detail .. "'" .. C("#D70029") or "") .. ".")
21 function furrybot.player_online(name)
22 for _, n in ipairs(minetest.get_player_names()) do
29 function furrybot.check_online(name, target)
31 furrybot.ping_player_error(name, "You need to specify a player")
32 elseif name == target then
33 furrybot.ping_player_error(name, "You need to specify a different player than yourself")
34 elseif furrybot.player_online(target) then
37 furrybot.ping_player_error(name, "Player not online", target)
41 function furrybot.choose(list)
42 return list[math.random(#list)]
45 function furrybot.http_request(url, name, callback)
46 furrybot.http.fetch({url = url}, function(res)
50 furrybot.ping_player_error(name, "Request failed with code", res.code)
55 function furrybot.json_http_request(url, name, callback)
56 furrybot.http_request(url, name, function(data)
57 callback(minetest.parse_json(data)[1])
61 function furrybot.recieve(msg)
62 msg = minetest.strip_colors(msg)
63 if msg:find("<") == 1 then
64 local idx = msg:find(">")
65 local player = msg:sub(2, idx - 1)
66 local message = msg:sub(idx + 3, #msg)
67 if message:find("!") == 1 then
68 local args = message:sub(2, #message):split(" ")
69 local cmd = table.remove(args, 1)
70 local func = furrybot.commands[cmd]
72 func(player, unpack(args))
74 furrybot.ping_player_error(player, "Invalid command", cmd)
80 function furrybot.commands.hug(name, target)
81 if furrybot.check_online(name, target) then
82 furrybot.send(name .. " hugs " .. target .. ".")
86 furrybot.commands.cuddle = furrybot.commands.hug
88 function furrybot.commands.kiss(name, target)
89 if furrybot.check_online(name, target) then
90 furrybot.send(name .. " kisses " .. target .. ".")
94 furrybot.target_list = {}
96 function furrybot.commands.bang(name, target)
97 if furrybot.check_online(name, target) then
98 furrybot.target_list[target] = function()
99 furrybot.send(ping(name) .. " and " .. ping(target) .. " are having sex! OwO")
101 furrybot.ping_player(target, name .. " wants to have sex with you. Type !accept to accept or !deny to deny.")
105 furrybot.commands.sex = furrybot.commands.bang
106 furrybot.commands.fuck = furrybot.commands.bang
108 function furrybot.commands.accept(name)
109 local func = furrybot.target_list[name]
113 furrybot.ping_player_error(name, "Nothing to accept")
117 function furrybot.commands.deny(name)
118 if furrybot.target_list[name] then
119 furrybot.target_list[name] = nil
120 furrybot.ping_player(name, "Denied request")
122 furrybot.ping_player_error(name, "Nothing to deny")
126 function furrybot.commands.hit(name, target)
127 if furrybot.check_online(name, target) then
128 furrybot.send(name .. " hits " .. target)
132 furrybot.commands.slap = furrybot.commands.hit
133 furrybot.commands.beat = furrybot.commands.hit
135 function furrybot.commands.help()
137 for k in pairs(furrybot.commands) do
138 table.insert(keys, k)
140 furrybot.send("Available commands: " .. table.concat(keys, ", "))
143 function furrybot.commands.verse(name)
144 furrybot.json_http_request("https://labs.bible.org/api/?type=json&passage=random", name, function(data)
145 furrybot.send(data.text .. C("#00FFC3") .. "[" .. data.bookname .. " " .. data.chapter .. "," .. data.verse .. "]")
149 function furrybot.commands.define(name, word)
151 furrybot.json_http_request("https://api.dictionaryapi.dev/api/v1/entries/en_US/" .. word, name, function(data)
152 local meaning = data.meaning
153 local selected = meaning.exclamation or meaning.noun or meaning.verb or meaning.adjective or meaning["transitive verb"] or meaning.adverb or meaning["relative adverb"]
156 furrybot.ping_player_error(name, "Error in parsing response")
158 furrybot.send(C("#00FFC3") .. word:sub(1, 1):upper() .. word:sub(2, #word):lower() .. ": " .. C("#FFFA00") .. selected[1].definition)
162 furrybot.ping_player_error(name, "You need to specify a word")
166 function furrybot.commands.insult(name, target)
167 if furrybot.check_online(name, target) then
168 furrybot.http_request("https://insult.mattbas.org/api/insult", name, function(data)
169 furrybot.ping_player(target, data)
174 function furrybot.commands.rolldice(name)
175 furrybot.ping_player(name, "rolled a dice and got a " .. C("#AAFF43") .. math.random(6))
178 function furrybot.commands.coinflip(name)
179 furrybot.ping_player(name, "flipped a coin and got " .. C("#AAFF43") .. furrybot.choose({"Heads", "Tails"}))
182 function furrybot.commands.status()
185 function furrybot.commands.cmd()
188 if furrybot.loaded then
189 furrybot.send("Reloaded")
191 furrybot.loaded = true