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.ping_player_error(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) then
129 furrybot.requests[target] = {
133 on_request(name, target)
138 function furrybot.money_key(name)
139 return name .. ".money"
142 function furrybot.get_money(name)
143 local key = furrybot.money_key(name)
144 if furrybot.storage:contains(key) then
145 return furrybot.storage:get_int(key)
151 function furrybot.set_money(name, money)
152 furrybot.storage:set_int(furrybot.money_key(name), money)
155 function furrybot.add_money(name, add)
156 local money = furrybot.get_money(name)
157 furrybot.set_money(name, money + add)
160 function furrybot.take_money(name, remove)
161 local money = furrybot.get_money(name)
162 local new = money - remove
166 furrybot.set_money(name, new)
171 function furrybot.money(money, color)
172 return furrybot.colors.money .. "$" .. money .. color
178 function furrybot.commands.help()
180 for k in pairs(furrybot.commands) do
181 table.insert(keys, k)
183 furrybot.send("Available commands: " .. table.concat(keys, ", "), furrybot.colors.system)
186 function furrybot.commands.accept(name)
187 local tbl = furrybot.requests[name]
189 furrybot.requests[name] = nil
190 tbl.func(tbl.origin, name)
192 furrybot.error_message(name, "Nothing to accept")
196 function furrybot.commands.deny(name)
197 local tbl = furrybot.requests[name]
199 furrybot.requests[name] = nil
200 furrybot.ping_message(name, "Denied request")
202 furrybot.error_message(name, "Nothing to deny")
206 -- don't bug players that are running ClamityBot commands from discord
207 function furrybot.commands.status()
210 function furrybot.commands.cmd()
214 furrybot.commands.hug = furrybot.simple_rpg_command("hugs")
215 furrybot.commands.cuddle = furrybot.simple_rpg_command("cuddles")
216 furrybot.commands.kiss = furrybot.simple_rpg_command("kisses")
217 furrybot.commands.hit = furrybot.simple_rpg_command("hits")
218 furrybot.commands.slap = furrybot.simple_rpg_command("slaps")
219 furrybot.commands.beat = furrybot.simple_rpg_command("beats")
221 furrybot.commands.sex = furrybot.request_command(function(name, target)
222 furrybot.ping_message(target, name .. " wants to have sex with you. Type !accept to accept or !deny to deny.", furrybot.colors.system)
223 end, function(name, target)
224 furrybot.send(name .. " and " .. target .. " are having sex! OwO", furrybot.colors.rpg)
226 furrybot.commands.bang = furrybot.commands.sex
227 furrybot.commands.fuck = furrybot.commands.sex
230 function furrybot.commands.rolldice(name)
231 furrybot.ping_message(name, "rolled a dice and got a " .. furrybot.random(1, 6, furrybot.colors.system) .. ".", furrybot.colors.system)
234 function furrybot.commands.coinflip(name)
235 furrybot.ping_message(name, "flipped a coin and got " .. furrybot.choose({"Heads", "Tails"}, furrybot.colors.system) .. ".", furrybot.colors.system)
238 function furrybot.commands.choose(name, ...)
239 local options = {...}
241 furrybot.ping_message(name, "I choose " .. furrybot.choose(options, "", furrybot.colors.system) .. ".", furrybot.colors.system)
243 furrybot.error_message(name, "Not enough options")
247 function furrybot.commands.dicksize(name, target)
248 target = target or name
249 local size = furrybot.strrandom(target, 31242, 2, 10)
250 local dick = furrybot.repeat_string("=", size) .. "D"
251 furrybot.send(dick .. furrybot.colors.system .. " <= " .. furrybot.ping(target, furrybot.colors.system) .. "'s Dick", C("#FF4DE1"))
253 furrybot.commands.cocksize = furrybot.commands.dicksize
256 function furrybot.commands.verse(name)
257 furrybot.json_http_request("https://labs.bible.org/api/?type=json&passage=random", name, function(data)
258 furrybot.send(data.text .. furrybot.colors.info .. "[" .. data.bookname .. " " .. data.chapter .. "," .. data.verse .. "]", furrybot.colors.fun)
262 function furrybot.commands.define(name, word)
264 furrybot.json_http_request("https://api.dictionaryapi.dev/api/v1/entries/en_US/" .. word, name, function(data)
265 local meaning = data.meaning
266 local selected = meaning.exclamation or meaning.noun or meaning.verb or meaning.adjective or meaning["transitive verb"] or meaning.adverb or meaning["relative adverb"]
269 furrybot.error_message(name, "Error in parsing response")
271 furrybot.send(word:sub(1, 1):upper() .. word:sub(2, #word):lower() .. ": " .. furrybot.colors.fun .. selected[1].definition, furrybot.colors.info)
275 furrybot.error_message(name, "You need to specify a word")
279 function furrybot.commands.insult(name, target)
280 if furrybot.online_or_error(name, target, true) then
281 furrybot.http_request("https://insult.mattbas.org/api/insult", name, function(data)
282 furrybot.ping_message(target, data, furrybot.colors.fun)
287 function furrybot.commands.joke(name, first, last)
294 furrybot.json_http_request("http://api.icndb.com/jokes/random?firstName=" .. first .. "&lastName=" .. last, name, function(data)
295 local joke = data.value.joke:gsub(""", "\""):gsub(" ", " ")
296 furrybot.send(joke, furrybot.colors.fun)
300 function furrybot.commands.question(name)
301 furrybot.json_http_request("https://8ball.delegator.com/magic/JSON/anything", name, function(data)
302 furrybot.ping_message(name, data.magic.answer, furrybot.colors.fun)
305 furrybot.commands["8ball"] = furrybot.commands.question
308 function furrybot.commands.money(name, target)
309 target = target or name
310 furrybot.ping_message(name, (target == name and "You have " or target .. " has ") .. furrybot.money(furrybot.get_money(target), furrybot.colors.system) .. ".", furrybot.colors.system)
312 furrybot.commands.balance = furrybot.commands.money
314 function furrybot.commands.pay(name, target, number)
315 if furrybot.online_or_error(name, target) then
316 local money = tonumber(number or "")
317 if not money or money <= 0 or math.floor(money) ~= money then
318 furrybot.error_message(name, "Invalid amount of money")
320 if furrybot.take_money(name, money) then
321 furrybot.add_money(target, money)
322 furrybot.ping_message(target, name .. " has payed you " .. furrybot.money(money, furrybot.colors.system) .. ".", furrybot.colors.system)
324 furrybot.error_message(name, "You don't have enough money")
331 furrybot.send("FurryBot - " .. C("#170089") .. "https://github.com/EliasFleckenstein03/furrybot", furrybot.colors.system)
333 if furrybot.loaded then
334 furrybot.send("Reloaded", furrybot.colors.system)
336 furrybot.loaded = true