3 furrybot.unsafe_commands = {}
5 local http, env, storage
6 local C = minetest.get_color_escape_sequence
10 system = C("#FFFA00"),
12 detail = C("#FF6683"),
14 braces = C("#FFFAC0"),
17 random = C("#A300BE"),
23 function furrybot.send(msg, color)
24 minetest.send_chat_message("/me " .. furrybot.colors.braces .. "[" .. color .. msg .. furrybot.colors.braces .. "]")
27 function furrybot.ping(player, color)
28 return furrybot.colors.ping .. "@" .. player .. color
31 function furrybot.ping_message(player, message, color)
32 furrybot.send(furrybot.ping(player, color) .. ": " .. message, "")
35 function furrybot.error_message(player, error, detail)
36 furrybot.ping_message(player, error .. (detail and furrybot.colors.detail .. " '" .. detail .. "'" .. furrybot.colors.error or "") .. ".", furrybot.colors.error)
39 function furrybot.recieve(rawmsg)
40 local message_info = libclamity.parse_chat_message(rawmsg)
42 if not message_info then
46 local player, message, discord = message_info.player, message_info.message, message_info.discord
48 if message:find("!") == 1 then
49 local args = message:sub(2, #message):split(" ")
50 local cmd = table.remove(args, 1)
51 local func = furrybot.commands[cmd]
53 if furrybot.unsafe_commands[cmd] and discord then
54 furrybot.error_message(player, "Sorry, you cannot run this command from discord", cmd)
56 func(player, unpack(args))
59 furrybot.error_message(player, "Invalid command", cmd)
64 function furrybot.reload()
65 local func, err = env.loadfile("clientmods/furrybot/bot.lua")
67 local old_fb = table.copy(furrybot)
68 local status, init = pcall(func)
70 init(http, env, storage)
73 return false, furrybot.colors.error .. "Error: " .. furrybot.colors.detail .. init
76 return false, furrybot.colors.error .. "Syntax error: " .. furrybot.colors.detail .. err
80 function furrybot.player_online(name)
81 for _, n in ipairs(minetest.get_player_names()) do
88 function furrybot.online_or_error(name, other, allow_self)
90 furrybot.error_message(name, "You need to specify a player")
91 elseif name == other and not allow_self then
92 furrybot.error_message(name, "You need to specify a different player than yourself")
93 elseif furrybot.player_online(other) then
96 furrybot.error_message(name, "Player not online", other)
100 function furrybot.choose(list, color)
101 return furrybot.colors.random .. list[math.random(#list)] .. color
104 function furrybot.random(min, max, color)
105 return furrybot.colors.random .. math.random(min, max) .. color
108 function furrybot.http_request(url, name, callback)
109 http.fetch({url = url}, function(res)
110 if res.succeeded then
113 furrybot.error_message(name, "Request failed with code", res.code)
118 function furrybot.json_http_request(url, name, callback)
119 furrybot.http_request(url, name, function(raw)
120 local data = minetest.parse_json(raw)
121 callback(data[1] or data)
125 function furrybot.strrandom(str, seed, ...)
127 local pr = PseudoRandom(seed)
129 v = v + str:byte(i) * pr:next()
131 return PseudoRandom(v):next(...)
134 function furrybot.repeat_string(str, times)
142 function furrybot.interactive_rpg_command(action)
143 return function(name, target)
144 if furrybot.online_or_error(name, target) then
145 furrybot.send(name .. " " .. action .. " " .. target .. ".", furrybot.colors.rpg)
150 function furrybot.solo_rpg_command(action)
151 return function(name)
152 furrybot.send(name .. " " .. action .. ".", furrybot.colors.rpg)
156 function furrybot.request_command(on_request, on_accept)
157 return function(name, target)
158 if furrybot.online_or_error(name, target) and on_request(name, target) ~= false then
159 furrybot.requests[target] = {
167 function furrybot.get_money(name)
168 local key = name .. ".money"
169 if storage:contains(key) then
170 return storage:get_int(key)
176 function furrybot.set_money(name, money)
177 storage:set_int(name .. ".money", money)
180 function furrybot.add_money(name, add)
181 local money = furrybot.get_money(name)
182 furrybot.set_money(name, money + add)
185 function furrybot.take_money(name, remove)
186 local money = furrybot.get_money(name)
187 local new = money - remove
191 furrybot.set_money(name, new)
196 function furrybot.money(money, color)
197 return furrybot.colors.money .. "$" .. money .. color
203 function furrybot.commands.help()
205 for k in pairs(furrybot.commands) do
206 table.insert(keys, k)
208 furrybot.send("Available commands: " .. table.concat(keys, ", "), furrybot.colors.system)
211 function furrybot.commands.accept(name)
212 local tbl = furrybot.requests[name]
214 furrybot.requests[name] = nil
215 tbl.func(tbl.origin, name)
217 furrybot.error_message(name, "Nothing to accept")
220 furrybot.unsafe_commands.accept = true
222 function furrybot.commands.deny(name)
223 local tbl = furrybot.requests[name]
225 furrybot.requests[name] = nil
226 furrybot.ping_message(name, "Denied request", furrybot.colors.system)
228 furrybot.error_message(name, "Nothing to deny")
231 furrybot.unsafe_commands.deny = true
233 -- don't bug players that are running ClamityBot commands from discord
234 function furrybot.commands.status()
237 function furrybot.commands.cmd()
241 furrybot.commands.cry = furrybot.solo_rpg_command("cries")
242 furrybot.commands.laugh = furrybot.solo_rpg_command("laughs")
243 furrybot.commands.confused = furrybot.solo_rpg_command("is confused")
244 furrybot.commands.smile = furrybot.solo_rpg_command("smiles")
245 furrybot.commands.hug = furrybot.interactive_rpg_command("hugs")
246 furrybot.commands.cuddle = furrybot.interactive_rpg_command("cuddles")
247 furrybot.commands.kiss = furrybot.interactive_rpg_command("kisses")
248 furrybot.commands.hit = furrybot.interactive_rpg_command("hits")
249 furrybot.commands.slap = furrybot.interactive_rpg_command("slaps")
250 furrybot.commands.beat = furrybot.interactive_rpg_command("beats")
251 furrybot.commands.lick = furrybot.interactive_rpg_command("licks")
253 furrybot.commands.sex = furrybot.request_command(function(name, target)
254 furrybot.ping_message(target, name .. " wants to have sex with you. Type !accept to accept or !deny to deny.", furrybot.colors.system)
255 end, function(name, target)
256 furrybot.send(name .. " and " .. target .. " are having sex! OwO", furrybot.colors.rpg)
258 furrybot.commands.bang = furrybot.commands.sex
259 furrybot.commands.fuck = furrybot.commands.sex
261 furrybot.commands.marry = furrybot.request_command(function(name, target)
262 if storage:contains(name .. ".partner", target) then
263 furrybot.error_message(name, "You are already married to", storage:get_string(name .. ".partner"))
265 elseif storage:contains(target .. ".partner", name) then
266 furrybot.error_message(name, target .. " is already married to", storage:get_string(name .. ".partner"))
269 furrybot.ping_message(target, name .. " proposes to you. Type !accept to accept or !deny to deny.", furrybot.colors.system)
271 end, function(name, target)
272 storage:set_string(name .. ".partner", target)
273 storage:set_string(target .. ".partner", name)
274 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)
276 furrybot.commands.propose = furrybot.commands.marry
277 furrybot.unsafe_commands.marry = true
278 furrybot.unsafe_commands.propose = true
280 function furrybot.commands.divorce(name)
281 if storage:contains(name .. ".partner") then
282 local partner = storage:get_string(name .. ".partner")
283 storage:set_string(name .. ".partner", "")
284 storage:set_string(partner .. ".partner", "")
285 furrybot.ping_message(name, "divorces from " .. partner .. " :(", furrybot.colors.rpg)
287 furrybot.error_message(name, "You are not married")
290 furrybot.unsafe_commands.divorce = true
292 function furrybot.commands.partner(name, target)
293 target = target or name
294 if storage:contains(target .. ".partner") then
295 furrybot.ping_message(name, (target == name and "You are" or target .. " is") .. " married to " .. storage:get_string(target .. ".partner"), furrybot.colors.system)
297 furrybot.error_message(name, (target == name and "You are" or target .. " is") .. " not married")
300 furrybot.commands.married = furrybot.commands.partner
303 function furrybot.commands.rolldice(name)
304 furrybot.ping_message(name, "rolled a dice and got a " .. furrybot.random(1, 6, furrybot.colors.system) .. ".", furrybot.colors.system)
307 function furrybot.commands.coinflip(name)
308 furrybot.ping_message(name, "flipped a coin and got " .. furrybot.choose({"Heads", "Tails"}, furrybot.colors.system) .. ".", furrybot.colors.system)
311 function furrybot.commands.choose(name, ...)
312 local options = {...}
314 furrybot.ping_message(name, "I choose " .. furrybot.choose(options, "", furrybot.colors.system) .. ".", furrybot.colors.system)
316 furrybot.error_message(name, "Not enough options")
320 function furrybot.commands.dicksize(name, target)
321 target = target or name
322 local size = furrybot.strrandom(target, 31242, 2, 10)
323 local dick = furrybot.repeat_string("=", size) .. "D"
324 furrybot.send(dick .. furrybot.colors.system .. " <= " .. furrybot.ping(target, furrybot.colors.system) .. "'s Dick", C("#FF4DE1"))
326 furrybot.commands.cocksize = furrybot.commands.dicksize
329 function furrybot.commands.verse(name)
330 furrybot.json_http_request("https://labs.bible.org/api/?type=json&passage=random", name, function(data)
331 furrybot.send(data.text .. furrybot.colors.info .. "[" .. data.bookname .. " " .. data.chapter .. "," .. data.verse .. "]", furrybot.colors.fun)
335 function furrybot.commands.define(name, word)
337 furrybot.json_http_request("https://api.dictionaryapi.dev/api/v1/entries/en_US/" .. word:gsub("computer", "person"), name, function(data)
338 local meaning = data.meaning
339 local selected = meaning.exclamation or meaning.noun or meaning.verb or meaning.adjective or meaning["transitive verb"] or meaning.adverb or meaning["relative adverb"]
342 furrybot.error_message(name, "Error in parsing response")
344 furrybot.send(word:sub(1, 1):upper() .. word:sub(2, #word):lower() .. ": " .. furrybot.colors.fun .. selected[1].definition, furrybot.colors.info)
348 furrybot.error_message(name, "You need to specify a word")
352 function furrybot.commands.insult(name, target)
353 if furrybot.online_or_error(name, target, true) then
354 furrybot.http_request("https://insult.mattbas.org/api/insult", name, function(data)
355 furrybot.ping_message(target, data, furrybot.colors.fun)
360 function furrybot.commands.joke(name, first, last)
367 furrybot.json_http_request("http://api.icndb.com/jokes/random?firstName=" .. first .. "&lastName=" .. last, name, function(data)
368 local joke = data.value.joke:gsub(""", "\""):gsub(" ", " ")
369 furrybot.send(joke, furrybot.colors.fun)
373 function furrybot.commands.question(name)
374 furrybot.json_http_request("https://8ball.delegator.com/magic/JSON/anything", name, function(data)
375 furrybot.ping_message(name, data.magic.answer, furrybot.colors.fun)
378 furrybot.commands["8ball"] = furrybot.commands.question
381 function furrybot.commands.money(name, target)
382 target = target or name
383 furrybot.ping_message(name, (target == name and "You have " or target .. " has ") .. furrybot.money(furrybot.get_money(target), furrybot.colors.system) .. ".", furrybot.colors.system)
385 furrybot.commands.balance = furrybot.commands.money
387 function furrybot.commands.pay(name, target, number)
388 if furrybot.online_or_error(name, target) then
389 local money = tonumber(number or "")
390 if not money or money <= 0 or math.floor(money) ~= money then
391 furrybot.error_message(name, "Invalid amount of money")
393 if furrybot.take_money(name, money) then
394 furrybot.add_money(target, money)
395 furrybot.ping_message(target, name .. " has payed you " .. furrybot.money(money, furrybot.colors.system) .. ".", furrybot.colors.system)
397 furrybot.error_message(name, "You don't have enough money")
402 furrybot.unsafe_commands.pay = true
405 furrybot.send("FurryBot - " .. C("#170089") .. "https://github.com/EliasFleckenstein03/furrybot", furrybot.colors.system)
407 if furrybot.loaded then
408 furrybot.send("Reloaded", furrybot.colors.system)
410 furrybot.loaded = true
413 return function(_http, _env, _storage)
414 http, env, storage = _http, _env, _storage