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)
30 if name == target then
31 furrybot.ping_player_error(name, "You need to specify another player")
32 elseif furrybot.player_online(target) then
35 furrybot.ping_player_error(name, "Player not online", target)
39 function furrybot.choose(list)
40 return list[math.random(#list)]
43 function furrybot.http_request(url, name, callback)
44 furrybot.http.fetch({url = url}, function(res)
46 local data = minetest.parse_json(res.data)[1]
49 furrybot.ping_player_error(name, "Request failed with code", res.code)
54 function furrybot.recieve(msg)
55 msg = minetest.strip_colors(msg)
56 if msg:find("<") == 1 then
57 local idx = msg:find(">")
58 local player = msg:sub(2, idx - 1)
59 local message = msg:sub(idx + 3, #msg)
60 if message:find("!") == 1 then
61 local args = message:sub(2, #message):split(" ")
62 local cmd = table.remove(args, 1)
63 local func = furrybot.commands[cmd]
65 func(player, unpack(args))
67 furrybot.ping_player_error(player, "Invalid command", cmd)
73 function furrybot.commands.hug(name, target)
74 if furrybot.check_online(name, target) then
75 furrybot.send(name .. " hugs " .. target .. ".")
79 furrybot.commands.cuddle = furrybot.commands.hug
81 function furrybot.commands.kiss(name, target)
82 if furrybot.check_online(name, target) then
83 furrybot.send(name .. " kisses " .. target .. ".")
87 furrybot.target_list = {}
89 function furrybot.commands.bang(name, target)
90 if furrybot.check_online(name, target) then
91 furrybot.target_list[target] = function()
92 furrybot.send(ping(name) .. " and " .. ping(target) .. " are having sex! OwO")
94 furrybot.ping_player(target, name .. " wants to have sex with you. Type !accept to accept or !deny to deny.")
98 furrybot.commands.sex = furrybot.commands.bang
99 furrybot.commands.fuck = furrybot.commands.bang
101 function furrybot.commands.accept(name)
102 local func = furrybot.target_list[name]
106 furrybot.ping_player_error(name, "Nothing to accept")
110 function furrybot.commands.deny(name)
111 if furrybot.target_list[name] then
112 furrybot.target_list[name] = nil
113 furrybot.ping_player(name, "Denied request")
115 furrybot.ping_player_error(name, "Nothing to deny")
119 function furrybot.commands.hit(name, target)
120 if furrybot.check_online(name, target) then
121 furrybot.send(name .. " hits " .. target)
125 furrybot.commands.slap = furrybot.commands.hit
126 furrybot.commands.beat = furrybot.commands.hit
128 function furrybot.commands.help()
130 for k in pairs(furrybot.commands) do
131 table.insert(keys, k)
133 furrybot.send("Available commands: " .. table.concat(keys, ", "))
136 function furrybot.commands.verse(name)
137 furrybot.http_request("https://labs.bible.org/api/?type=json&passage=random", name, function(data)
138 furrybot.send(data.text .. C("#00FFC3") .. "[" .. data.bookname .. " " .. data.chapter .. "," .. data.verse .. "]")
142 function furrybot.commands.define(name, word)
144 furrybot.http_request("https://api.dictionaryapi.dev/api/v1/entries/en_US/" .. word, name, function(data)
145 local meaning = data.meaning
146 local selected = meaning.exclamation or meaning.noun or meaning.verb or meaning["transitive verb"] or meaning.adverb or meaning["relative adverb"]
149 furrybot.ping_player_error(name, "Error in parsing response")
151 furrybot.send(C("#00FFC3") .. word:sub(1, 1):upper() .. word:sub(2, #word):lower() .. ": " .. C("#FFFA00") .. selected[1].definition)
155 furrybot.ping_player_error(name, "You need to specify a word")
159 function furrybot.commands.rolldice(name)
160 furrybot.ping_player(name, "rolled a dice and got a " .. C("#AAFF43") .. math.random(6))
163 function furrybot.commands.coinflip(name)
164 furrybot.ping_player(name, "flipped a coin and got " .. C("#AAFF43") .. furrybot.choose({"Heads", "Tails"}))
167 function furrybot.commands.status()
170 function furrybot.commands.cmd()
173 if furrybot.loaded then
174 furrybot.send("Reloaded")
176 furrybot.loaded = true