4 local C = minetest.get_color_escape_sequence
10 detail = C("#FF6683"),
12 braces = C("#FFFAC0"),
15 random = C("#A300BE"),
21 function furrybot.send(msg, color)
22 minetest.send_chat_message("/me " .. furrybot.colors.braces .. "[" .. color .. msg .. furrybot.colors.braces .. "]")
25 function furrybot.ping(player, color)
26 return furrybot.colors.ping .. "@" .. player .. color
29 function furrybot.ping_message(player, message, color)
30 furrybot.send(furrybot.ping(player, color) .. ": " .. message, "")
33 function furrybot.error_message(player, error, detail)
34 furrybot.ping_message(player, error .. (detail and furrybot.colors.detail .. " '" .. detail .. "'" .. furrybot.colors.error or "") .. ".", furrybot.colors.error)
37 function furrybot.recieve(msg)
38 msg = minetest.strip_colors(msg)
39 if msg:find("<") == 1 then
40 local idx = msg:find(">")
41 local player = msg:sub(2, idx - 1)
42 local message = msg:sub(idx + 3, #msg)
43 if message:find("!") == 1 then
44 local args = message:sub(2, #message):split(" ")
45 local cmd = table.remove(args, 1)
46 local func = furrybot.commands[cmd]
48 func(player, unpack(args))
50 furrybot.error_message(player, "Invalid command", cmd)
56 function furrybot.player_online(name)
57 for _, n in ipairs(minetest.get_player_names()) do
64 function furrybot.online_or_error(name, other, allow_self)
66 furrybot.error_message(name, "You need to specify a player")
67 elseif name == other and not allow_self then
68 furrybot.error_message(name, "You need to specify a different player than yourself")
69 elseif furrybot.player_online(other) then
72 furrybot.error_message(name, "Player not online", other)
76 function furrybot.choose(list, color)
77 return furrybot.colors.random .. list[math.random(#list)] .. color
80 function furrybot.random(min, max, color)
81 return furrybot.colors.random .. math.random(#list) .. color
84 function furrybot.http_request(url, name, callback)
85 furrybot.http.fetch({url = url}, function(res)
89 furrybot.error_message(name, "Request failed with code", res.code)
94 function furrybot.json_http_request(url, name, callback)
95 furrybot.http_request(url, name, function(raw)
96 local data = minetest.parse_json(raw)
97 callback(data[1] or data)
101 function furrybot.strrandom(str, seed, ...)
103 local pr = PseudoRandom(seed)
105 v = v + str:byte(i) * pr:next()
107 return PseudoRandom(v):next(...)
110 function furrybot.repeat_string(str, times)
118 function furrybot.simple_rpg_command(action)
119 return function(name, target)
120 if furrybot.online_or_error(name, target) then
121 furrybot.send(name .. " " .. action .. " " .. target .. ".", furrybot.colors.rpg)
126 function furrybot.request_command(on_request, on_accept)
127 return function(name, target)
128 if furrybot.online_or_error(name, target) and on_request(name, target) ~= false then
129 furrybot.requests[target] = {
137 function furrybot.get_money(name)
138 local key = name .. ".money"
139 if furrybot.storage:contains(key) then
140 return furrybot.storage:get_int(key)
146 function furrybot.set_money(name, money)
147 furrybot.storage:set_int(name .. ".money", money)
150 function furrybot.add_money(name, add)
151 local money = furrybot.get_money(name)
152 furrybot.set_money(name, money + add)
155 function furrybot.take_money(name, remove)
156 local money = furrybot.get_money(name)
157 local new = money - remove
161 furrybot.set_money(name, new)
166 function furrybot.money(money, color)
167 return furrybot.colors.money .. "$" .. money .. color
173 function furrybot.commands.help()
175 for k in pairs(furrybot.commands) do
176 table.insert(keys, k)
178 furrybot.send("Available commands: " .. table.concat(keys, ", "), furrybot.colors.system)
181 function furrybot.commands.accept(name)
182 local tbl = furrybot.requests[name]
184 furrybot.requests[name] = nil
185 tbl.func(tbl.origin, name)
187 furrybot.error_message(name, "Nothing to accept")
191 function furrybot.commands.deny(name)
192 local tbl = furrybot.requests[name]
194 furrybot.requests[name] = nil
195 furrybot.ping_message(name, "Denied request", furrybot.colors.system)
197 furrybot.error_message(name, "Nothing to deny")
201 -- don't bug players that are running ClamityBot commands from discord
202 function furrybot.commands.status()
205 function furrybot.commands.cmd()
209 furrybot.commands.hug = furrybot.simple_rpg_command("hugs")
210 furrybot.commands.cuddle = furrybot.simple_rpg_command("cuddles")
211 furrybot.commands.kiss = furrybot.simple_rpg_command("kisses")
212 furrybot.commands.hit = furrybot.simple_rpg_command("hits")
213 furrybot.commands.slap = furrybot.simple_rpg_command("slaps")
214 furrybot.commands.beat = furrybot.simple_rpg_command("beats")
215 furrybot.commands.lick = furrybot.simple_rpg_command("licks")
217 furrybot.commands.sex = furrybot.request_command(function(name, target)
218 furrybot.ping_message(target, name .. " wants to have sex with you. Type !accept to accept or !deny to deny.", furrybot.colors.system)
219 end, function(name, target)
220 furrybot.send(name .. " and " .. target .. " are having sex! OwO", furrybot.colors.rpg)
222 furrybot.commands.bang = furrybot.commands.sex
223 furrybot.commands.fuck = furrybot.commands.sex
225 furrybot.commands.marry = furrybot.request_command(function(name, target)
226 if furrybot.storage:contains(name .. ".partner", target) then
227 furrybot.error_message(name, "You are already married to", furrybot.storage:get_string(name .. ".partner"))
229 elseif furrybot.storage:contains(target .. ".partner", name) then
230 furrybot.error_message(name, target .. " is already married to", furrybot.storage:get_string(name .. ".partner"))
233 furrybot.ping_message(target, name .. " proposes to you. Type !accept to accept or !deny to deny.", furrybot.colors.system)
235 end, function(name, target)
236 furrybot.storage:set_string(name .. ".partner", target)
237 furrybot.storage:set_string(target .. ".partner", name)
238 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)
240 furrybot.commands.propose = furrybot.commands.marry
242 function furrybot.commands.divorce(name)
243 if furrybot.storage:contains(name .. ".partner") then
244 local partner = furrybot.storage:get_string(name .. ".partner")
245 furrybot.storage:set_string(name .. ".partner", "")
246 furrybot.storage:set_string(partner .. ".partner", "")
247 furrybot.ping_message(name, "divorces from " .. partner .. " :(", furrybot.colors.rpg)
249 furrybot.error_message(name, "You are not married")
253 function furrybot.commands.partner(name, target)
254 target = target or name
255 if furrybot.storage:contains(target .. ".partner") then
256 furrybot.ping_message(name, (target == name and "You are" or target .. " is") .. " married to " .. furrybot.storage:get_string(target .. ".partner"), furrybot.colors.system)
258 furrybot.error_message(name, (target == name and "You are" or target .. " is") .. " not married")
261 furrybot.commands.married = furrybot.commands.partner
264 function furrybot.commands.rolldice(name)
265 furrybot.ping_message(name, "rolled a dice and got a " .. furrybot.random(1, 6, furrybot.colors.system) .. ".", furrybot.colors.system)
268 function furrybot.commands.coinflip(name)
269 furrybot.ping_message(name, "flipped a coin and got " .. furrybot.choose({"Heads", "Tails"}, furrybot.colors.system) .. ".", furrybot.colors.system)
272 function furrybot.commands.choose(name, ...)
273 local options = {...}
275 furrybot.ping_message(name, "I choose " .. furrybot.choose(options, "", furrybot.colors.system) .. ".", furrybot.colors.system)
277 furrybot.error_message(name, "Not enough options")
281 function furrybot.commands.dicksize(name, target)
282 target = target or name
283 local size = furrybot.strrandom(target, 31242, 2, 10)
284 local dick = furrybot.repeat_string("=", size) .. "D"
285 furrybot.send(dick .. furrybot.colors.system .. " <= " .. furrybot.ping(target, furrybot.colors.system) .. "'s Dick", C("#FF4DE1"))
287 furrybot.commands.cocksize = furrybot.commands.dicksize
290 function furrybot.commands.verse(name)
291 furrybot.json_http_request("https://labs.bible.org/api/?type=json&passage=random", name, function(data)
292 furrybot.send(data.text .. furrybot.colors.info .. "[" .. data.bookname .. " " .. data.chapter .. "," .. data.verse .. "]", furrybot.colors.fun)
296 function furrybot.commands.define(name, word)
298 furrybot.json_http_request("https://api.dictionaryapi.dev/api/v1/entries/en_US/" .. word, name, function(data)
299 local meaning = data.meaning
300 local selected = meaning.exclamation or meaning.noun or meaning.verb or meaning.adjective or meaning["transitive verb"] or meaning.adverb or meaning["relative adverb"]
303 furrybot.error_message(name, "Error in parsing response")
305 furrybot.send(word:sub(1, 1):upper() .. word:sub(2, #word):lower() .. ": " .. furrybot.colors.fun .. selected[1].definition, furrybot.colors.info)
309 furrybot.error_message(name, "You need to specify a word")
313 function furrybot.commands.insult(name, target)
314 if furrybot.online_or_error(name, target, true) then
315 furrybot.http_request("https://insult.mattbas.org/api/insult", name, function(data)
316 furrybot.ping_message(target, data, furrybot.colors.fun)
321 function furrybot.commands.joke(name, first, last)
328 furrybot.json_http_request("http://api.icndb.com/jokes/random?firstName=" .. first .. "&lastName=" .. last, name, function(data)
329 local joke = data.value.joke:gsub(""", "\""):gsub(" ", " ")
330 furrybot.send(joke, furrybot.colors.fun)
334 function furrybot.commands.question(name)
335 furrybot.json_http_request("https://8ball.delegator.com/magic/JSON/anything", name, function(data)
336 furrybot.ping_message(name, data.magic.answer, furrybot.colors.fun)
339 furrybot.commands["8ball"] = furrybot.commands.question
342 function furrybot.commands.money(name, target)
343 target = target or name
344 furrybot.ping_message(name, (target == name and "You have " or target .. " has ") .. furrybot.money(furrybot.get_money(target), furrybot.colors.system) .. ".", furrybot.colors.system)
346 furrybot.commands.balance = furrybot.commands.money
348 function furrybot.commands.pay(name, target, number)
349 if furrybot.online_or_error(name, target) then
350 local money = tonumber(number or "")
351 if not money or money <= 0 or math.floor(money) ~= money then
352 furrybot.error_message(name, "Invalid amount of money")
354 if furrybot.take_money(name, money) then
355 furrybot.add_money(target, money)
356 furrybot.ping_message(target, name .. " has payed you " .. furrybot.money(money, furrybot.colors.system) .. ".", furrybot.colors.system)
358 furrybot.error_message(name, "You don't have enough money")
365 furrybot.send("FurryBot - " .. C("#170089") .. "https://github.com/EliasFleckenstein03/furrybot", furrybot.colors.system)
367 if furrybot.loaded then
368 furrybot.send("Reloaded", furrybot.colors.system)
370 furrybot.loaded = true