1 furrybot = rawget(_G, "furrybot") or {}
4 local C = minetest.get_color_escape_sequence
5 local http = minetest.get_http_api()
7 function furrybot.send(msg, color)
8 minetest.send_chat_message("/me " .. C("#00FF3C") .. "[" .. C(color or "#FFFA00") .. msg .. C("#00FF3C") .. "]")
11 function furrybot.ping(player)
12 return C("#00DCFF") .. "@" .. player .. C("#FFFA00")
15 function furrybot.ping_player(player, message)
16 furrybot.send(furrybot.ping(player) .. ": " .. message)
19 function furrybot.ping_player_error(player, err, detail)
20 furrybot.ping_player(player, C("#D70029") .. " " .. err .. " " .. (detail and C("#FF6683") .. "'" .. detail .. "'" .. C("#D70029") or "") .. ".")
23 function furrybot.player_online(name)
24 for _, n in ipairs(minetest.get_player_names()) do
31 function furrybot.check_online(name, target)
32 if name == target then
33 ping_player_error(name, "You need to specify another player")
34 elseif player_online(target) then
37 ping_player_error(name, "Player not online", target)
41 function furrybot.recieve(msg)
42 msg = minetest.strip_colors(msg)
43 if msg:find("<") == 1 then
44 local idx = msg:find(">")
45 local player = msg:sub(2, idx - 1)
46 local message = msg:sub(idx + 3, #msg)
47 if message:find("!") == 1 then
48 local args = message:sub(2, #message):split(" ")
49 local cmd = table.remove(args, 1)
50 local func = furrybot.commands[cmd]
52 func(player, unpack(args))
54 furrybot.ping_player_error(player, "Invalid command", cmd)
60 function furrybot.commands.furhug(name, target)
61 if furrybot.check_online(name, target) then
62 furrybot.send(name .. " hugs " .. target .. ".")
66 furrybot.commands.furcuddle = furrybot.commands.furhug
68 function furrybot.commands.furkiss(name, target)
69 if furrybot.check_online(name, target) then
70 furrybot.send(name .. " kisses " .. target .. ".")
74 furrybot.target_list = {}
76 function furrybot.commands.furbang(name, target)
77 if furrybot.check_online(name, target) then
78 furrybot.target_list[target] = function()
79 furrybot.send(ping(name) .. " and " .. ping(target) .. " are having sex! OwO")
81 furrybot.ping_player(target, name .. " wants to have sex with you. Type !accept to accept or !deny to deny.")
85 furrybot.commands.fursex = furrybot.commands.furbang
86 furrybot.commands.furfuck = furrybot.commands.furbang
88 function furrybot.commands.accept(name)
89 local func = furrybot.target_list[name]
93 furrybot.ping_player_error(name, "Nothing to accept")
97 function furrybot.commands.deny(name)
98 if furrybot.target_list[name] then
99 furrybot.target_list[name] = nil
100 furrybot.ping_player(name, "Denied request")
102 furrybot.ping_player_error(name, "Nothing to deny")
106 function furrybot.commands.furhit(name, target)
107 if furrybot.check_online(name, target) then
108 furrybot.send(name .. " hits " .. target)
112 furrybot.commands.furslap = furrybot.commands.furhit
114 function furrybot.commands.help()
116 for k in pairs(furrybot.commands) do
117 table.insert(keys, k)
119 furrybot.send("Available commands: " .. table.concat(keys, ", "))
122 function furrybot.commands.verse(name)
124 --url = "https://labs.bible.org/api/?type=json&passage=random",
127 local res = http.fetch_sync(req)
128 if res.succeeded then
129 --local data = minetest.parse_json(res.data)[1]
130 --furrybot.send(data.text .. C("#00FFC3") .. "[" .. data.bookname .. " " .. data.chapter .. "," .. data.verse .. "]")
131 furrybot.send(res.data)
133 furrybot.ping_player_error(name, "Request failed with code", res.code)
137 function furrybot.reload()
138 local f = loadfile(minetest.get_modpath("furrybot") .. "/init.lua")
143 if not furrybot.loaded then
144 minetest.register_on_receiving_chat_message(function(msg)
145 furrybot.recieve(msg)
148 minetest.register_chatcommand("furrybot-reload", {
154 furrybot.send("Reloaded")
157 furrybot.loaded = true