3 furrybot.unsafe_commands = {}
5 local C = minetest.get_color_escape_sequence
11 detail = C("#FF6683"),
13 braces = C("#FFFAC0"),
16 random = C("#A300BE"),
22 function furrybot.send(msg, color)
23 minetest.send_chat_message("/me " .. furrybot.colors.braces .. "[" .. color .. msg .. furrybot.colors.braces .. "]")
26 function furrybot.ping(player, color)
27 return furrybot.colors.ping .. "@" .. player .. color
30 function furrybot.ping_message(player, message, color)
31 furrybot.send(furrybot.ping(player, color) .. ": " .. message, "")
34 function furrybot.error_message(player, error, detail)
35 furrybot.ping_message(player, error .. (detail and furrybot.colors.detail .. " '" .. detail .. "'" .. furrybot.colors.error or "") .. ".", furrybot.colors.error)
38 function furrybot.recieve(rawmsg)
39 local msg = minetest.strip_colors(rawmsg)
40 local nameidx = msg:find("<")
41 local first_byte = rawmsg:byte(1)
42 if nameidx and (first_byte == 60 or first_byte == 27) then
43 local idx = msg:find(">")
44 local player = msg:sub(nameidx + 1, idx - 1)
45 local message = msg:sub(idx + 3, #msg)
46 if message:find("!") == 1 then
47 local args = message:sub(2, #message):split(" ")
48 local cmd = table.remove(args, 1)
49 local func = furrybot.commands[cmd]
51 if furrybot.unsafe_commands[cmd] and first_byte == 27 and rawmsg:sub(2, 12) == "(c@#63d269)" and nameidx == 1 then
52 furrybot.error_message(player, "Sorry, you cannot run this command from discord", cmd)
54 func(player, unpack(args))
57 furrybot.error_message(player, "Invalid command", cmd)
63 function furrybot.player_online(name)
64 for _, n in ipairs(minetest.get_player_names()) do
71 function furrybot.online_or_error(name, other, allow_self)
73 furrybot.error_message(name, "You need to specify a player")
74 elseif name == other and not allow_self then
75 furrybot.error_message(name, "You need to specify a different player than yourself")
76 elseif furrybot.player_online(other) then
79 furrybot.error_message(name, "Player not online", other)
83 function furrybot.choose(list, color)
84 return furrybot.colors.random .. list[math.random(#list)] .. color
87 function furrybot.random(min, max, color)
88 return furrybot.colors.random .. math.random(min, max) .. color
91 function furrybot.http_request(url, name, callback)
92 furrybot.http.fetch({url = url}, function(res)
96 furrybot.error_message(name, "Request failed with code", res.code)
101 function furrybot.json_http_request(url, name, callback)
102 furrybot.http_request(url, name, function(raw)
103 local data = minetest.parse_json(raw)
104 callback(data[1] or data)
108 function furrybot.strrandom(str, seed, ...)
110 local pr = PseudoRandom(seed)
112 v = v + str:byte(i) * pr:next()
114 return PseudoRandom(v):next(...)
117 function furrybot.repeat_string(str, times)
125 function furrybot.interactive_rpg_command(action)
126 return function(name, target)
127 if furrybot.online_or_error(name, target) then
128 furrybot.send(name .. " " .. action .. " " .. target .. ".", furrybot.colors.rpg)
133 function furrybot.solo_rpg_command(action)
134 return function(name)
135 furrybot.send(name .. " " .. action .. ".", furrybot.colors.rpg)
139 function furrybot.request_command(on_request, on_accept)
140 return function(name, target)
141 if furrybot.online_or_error(name, target) and on_request(name, target) ~= false then
142 furrybot.requests[target] = {
150 function furrybot.get_money(name)
151 local key = name .. ".money"
152 if furrybot.storage:contains(key) then
153 return furrybot.storage:get_int(key)
159 function furrybot.set_money(name, money)
160 furrybot.storage:set_int(name .. ".money", money)
163 function furrybot.add_money(name, add)
164 local money = furrybot.get_money(name)
165 furrybot.set_money(name, money + add)
168 function furrybot.take_money(name, remove)
169 local money = furrybot.get_money(name)
170 local new = money - remove
174 furrybot.set_money(name, new)
179 function furrybot.money(money, color)
180 return furrybot.colors.money .. "$" .. money .. color
186 function furrybot.commands.help()
188 for k in pairs(furrybot.commands) do
189 table.insert(keys, k)
191 furrybot.send("Available commands: " .. table.concat(keys, ", "), furrybot.colors.system)
194 function furrybot.commands.accept(name)
195 local tbl = furrybot.requests[name]
197 furrybot.requests[name] = nil
198 tbl.func(tbl.origin, name)
200 furrybot.error_message(name, "Nothing to accept")
203 furrybot.unsafe_commands.accept = true
205 function furrybot.commands.deny(name)
206 local tbl = furrybot.requests[name]
208 furrybot.requests[name] = nil
209 furrybot.ping_message(name, "Denied request", furrybot.colors.system)
211 furrybot.error_message(name, "Nothing to deny")
214 furrybot.unsafe_commands.deny = true
216 -- don't bug players that are running ClamityBot commands from discord
217 function furrybot.commands.status()
220 function furrybot.commands.cmd()
224 furrybot.commands.cry = furrybot.solo_rpg_command("cries")
225 furrybot.commands.laugh = furrybot.solo_rpg_command("laughs")
226 furrybot.commands.confused = furrybot.solo_rpg_command("is confused")
227 furrybot.commands.hug = furrybot.interactive_rpg_command("hugs")
228 furrybot.commands.cuddle = furrybot.interactive_rpg_command("cuddles")
229 furrybot.commands.kiss = furrybot.interactive_rpg_command("kisses")
230 furrybot.commands.hit = furrybot.interactive_rpg_command("hits")
231 furrybot.commands.slap = furrybot.interactive_rpg_command("slaps")
232 furrybot.commands.beat = furrybot.interactive_rpg_command("beats")
233 furrybot.commands.lick = furrybot.interactive_rpg_command("licks")
235 furrybot.commands.sex = furrybot.request_command(function(name, target)
236 furrybot.ping_message(target, name .. " wants to have sex with you. Type !accept to accept or !deny to deny.", furrybot.colors.system)
237 end, function(name, target)
238 furrybot.send(name .. " and " .. target .. " are having sex! OwO", furrybot.colors.rpg)
240 furrybot.commands.bang = furrybot.commands.sex
241 furrybot.commands.fuck = furrybot.commands.sex
243 furrybot.commands.marry = furrybot.request_command(function(name, target)
244 if furrybot.storage:contains(name .. ".partner", target) then
245 furrybot.error_message(name, "You are already married to", furrybot.storage:get_string(name .. ".partner"))
247 elseif furrybot.storage:contains(target .. ".partner", name) then
248 furrybot.error_message(name, target .. " is already married to", furrybot.storage:get_string(name .. ".partner"))
251 furrybot.ping_message(target, name .. " proposes to you. Type !accept to accept or !deny to deny.", furrybot.colors.system)
253 end, function(name, target)
254 furrybot.storage:set_string(name .. ".partner", target)
255 furrybot.storage:set_string(target .. ".partner", name)
256 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)
258 furrybot.commands.propose = furrybot.commands.marry
259 furrybot.unsafe_commands.marry = true
260 furrybot.unsafe_commands.propose = true
262 function furrybot.commands.divorce(name)
263 if furrybot.storage:contains(name .. ".partner") then
264 local partner = furrybot.storage:get_string(name .. ".partner")
265 furrybot.storage:set_string(name .. ".partner", "")
266 furrybot.storage:set_string(partner .. ".partner", "")
267 furrybot.ping_message(name, "divorces from " .. partner .. " :(", furrybot.colors.rpg)
269 furrybot.error_message(name, "You are not married")
272 furrybot.unsafe_commands.divorce = true
274 function furrybot.commands.partner(name, target)
275 target = target or name
276 if furrybot.storage:contains(target .. ".partner") then
277 furrybot.ping_message(name, (target == name and "You are" or target .. " is") .. " married to " .. furrybot.storage:get_string(target .. ".partner"), furrybot.colors.system)
279 furrybot.error_message(name, (target == name and "You are" or target .. " is") .. " not married")
282 furrybot.commands.married = furrybot.commands.partner
285 function furrybot.commands.rolldice(name)
286 furrybot.ping_message(name, "rolled a dice and got a " .. furrybot.random(1, 6, furrybot.colors.system) .. ".", furrybot.colors.system)
289 function furrybot.commands.coinflip(name)
290 furrybot.ping_message(name, "flipped a coin and got " .. furrybot.choose({"Heads", "Tails"}, furrybot.colors.system) .. ".", furrybot.colors.system)
293 function furrybot.commands.choose(name, ...)
294 local options = {...}
296 furrybot.ping_message(name, "I choose " .. furrybot.choose(options, "", furrybot.colors.system) .. ".", furrybot.colors.system)
298 furrybot.error_message(name, "Not enough options")
302 function furrybot.commands.dicksize(name, target)
303 target = target or name
304 local size = furrybot.strrandom(target, 31242, 2, 10)
305 local dick = furrybot.repeat_string("=", size) .. "D"
306 furrybot.send(dick .. furrybot.colors.system .. " <= " .. furrybot.ping(target, furrybot.colors.system) .. "'s Dick", C("#FF4DE1"))
308 furrybot.commands.cocksize = furrybot.commands.dicksize
311 function furrybot.commands.verse(name)
312 furrybot.json_http_request("https://labs.bible.org/api/?type=json&passage=random", name, function(data)
313 furrybot.send(data.text .. furrybot.colors.info .. "[" .. data.bookname .. " " .. data.chapter .. "," .. data.verse .. "]", furrybot.colors.fun)
317 function furrybot.commands.define(name, word)
319 furrybot.json_http_request("https://api.dictionaryapi.dev/api/v1/entries/en_US/" .. word, name, function(data)
320 local meaning = data.meaning
321 local selected = meaning.exclamation or meaning.noun or meaning.verb or meaning.adjective or meaning["transitive verb"] or meaning.adverb or meaning["relative adverb"]
324 furrybot.error_message(name, "Error in parsing response")
326 furrybot.send(word:sub(1, 1):upper() .. word:sub(2, #word):lower() .. ": " .. furrybot.colors.fun .. selected[1].definition, furrybot.colors.info)
330 furrybot.error_message(name, "You need to specify a word")
334 function furrybot.commands.insult(name, target)
335 if furrybot.online_or_error(name, target, true) then
336 furrybot.http_request("https://insult.mattbas.org/api/insult", name, function(data)
337 furrybot.ping_message(target, data, furrybot.colors.fun)
342 function furrybot.commands.joke(name, first, last)
349 furrybot.json_http_request("http://api.icndb.com/jokes/random?firstName=" .. first .. "&lastName=" .. last, name, function(data)
350 local joke = data.value.joke:gsub(""", "\""):gsub(" ", " ")
351 furrybot.send(joke, furrybot.colors.fun)
355 function furrybot.commands.question(name)
356 furrybot.json_http_request("https://8ball.delegator.com/magic/JSON/anything", name, function(data)
357 furrybot.ping_message(name, data.magic.answer, furrybot.colors.fun)
360 furrybot.commands["8ball"] = furrybot.commands.question
363 function furrybot.commands.money(name, target)
364 target = target or name
365 furrybot.ping_message(name, (target == name and "You have " or target .. " has ") .. furrybot.money(furrybot.get_money(target), furrybot.colors.system) .. ".", furrybot.colors.system)
367 furrybot.commands.balance = furrybot.commands.money
369 function furrybot.commands.pay(name, target, number)
370 if furrybot.online_or_error(name, target) then
371 local money = tonumber(number or "")
372 if not money or money <= 0 or math.floor(money) ~= money then
373 furrybot.error_message(name, "Invalid amount of money")
375 if furrybot.take_money(name, money) then
376 furrybot.add_money(target, money)
377 furrybot.ping_message(target, name .. " has payed you " .. furrybot.money(money, furrybot.colors.system) .. ".", furrybot.colors.system)
379 furrybot.error_message(name, "You don't have enough money")
384 furrybot.unsafe_commands.pay = true
387 furrybot.send("FurryBot - " .. C("#170089") .. "https://github.com/EliasFleckenstein03/furrybot", furrybot.colors.system)
389 if furrybot.loaded then
390 furrybot.send("Reloaded", furrybot.colors.system)
392 furrybot.loaded = true