help: {
params: "[<command>]",
help: "Display help for a commands or show list of available commands",
- func: (msg, [cmd], {commands}) => {
+ func: (msg, [cmd]) => {
if (cmd) {
let def = commands[cmd]
const fs = require("fs")
const google_images = require("free-google-images")
-/*
-const furrybot.list_change_command(cmd, list_name, title, status)
- furrybot.commands[cmd] = {
- operator = true,
- func = function(name, target)
- if target then
- if furrybot[list_name][target] == status then
- furrybot.error_message(name, "Player " .. (status and "already" or "not") .. " " .. title .. ": ", target)
- else
- furrybot[list_name][target] = status
- storage:set_string(list_name, minetest.serialize(furrybot[list_name]))
- furrybot.ping_message(name, "Successfully " .. cmd .. (cmd:sub(#cmd, #cmd) == "e" and "" or "e") .. "d " .. target, furrybot.colors.system)
- end
- else
- furrybot.error_message(name, "You need to specify a player")
- end
- end,
- }
-end
-
-function furrybot.list_command(cmd, list_name, title)
- furrybot.commands[cmd] = {
- func = function()
- local names = {}
-
- for name in pairs(furrybot[list_name]) do
- table.insert(names, name)
- end
-
- furrybot.send("List of " .. title .. ": " .. table.concat(names, ", "), furrybot.colors.system)
- end,
- }
-end
-
-function furrybot.choose(list, color)
- return furrybot.colors.random .. list[math.random(#list)] .. color
-end
-
-function furrybot.random(min, max, color)
- return furrybot.colors.random .. math.random(min, max) .. color
-end
-
-function furrybot.strrandom(str, seed, ...)
- local v = 0
- local pr = PseudoRandom(seed)
- for i = 1, #str do
- v = v + str:byte(i) * pr:next()
- end
- return PseudoRandom(v):next(...)
-end
-
-function furrybot.repeat_string(str, times)
- local msg = ""
- for i = 1, times do
- msg = msg .. str
- end
- return msg
-end
-
-*/
-
const getPing = module.exports.getPing = (msg, ping, allowSelf) => {
if (ping && ping.startsWith("<@!") && ping.endsWith(">")) {
const id = ping.slice("<@!".length, -">".length)
const r = Math.floor(rng.random() * accum)
return arr.find((_, k) => r < edges[k])[0]
}
+
+module.exports.listCommand = (title, list) => new Object({
+ help: "Show list of " + title,
+ func: msg => msg.reply(`List of ${title}: ${Object.keys(list).join(", ")}`)
+})
+
+module.exports.listChangeCommand = (action, list, listName, status) => new Object({
+ operator: true,
+ func: (msg, [targetPing]) => {
+ const target = getPing(msg, targetPing, true)
+
+ if (target) {
+ if (list[target] == status) {
+ msg.reply(`<@!${target}> ${status ? "already" : "not"} ${action}.`)
+ } else {
+ list[target] = status
+ module.exports.storageSave(listName, list)
+ msg.reply(`Successfully ${action} <@!${target}>.`)
+ }
+ }
+ }
+})
google: {
params: "<keyword> [...]",
help: "Google Image Search",
- func: (msg, keywords) => {
- google_images.searchRandom(keywords.join(" "))
+ func: (msg, keywords) =>
+ google_images.searchRandom(keywords.join(" "), true)
.then(result => msg.reply(result.image.url))
- }
},
verse: {
func: msg => fetch("https://labs.bible.org/api/?type=json&passage=random")
.then(data => msg.reply(`${data[0].text} [${data[0].bookname} ${data[0].chapter}, ${data[0].verse}]`))
},
define: {
- func: (msg, [word]) => word ? fetch("https://api.dictionaryapi.dev/api/v1/entries/en_US/" + word)
+ func: (msg, term) => term.length > 0 ? fetch("https://api.dictionaryapi.dev/api/v1/entries/en_US/" + term.join(" "))
.then(res => res.json())
.then(data => {
let def = data[0]
: msg.reply("You need to specify a word")
},
urban: {
- func: (msg, [word]) => word ? fetch("https://api.urbandictionary.com/v0/define?term=" + word)
+ func: (msg, term) => term.length > 0 ? fetch("https://api.urbandictionary.com/v0/define?term=" + term.join(" "))
.then(res => res.json())
.then(data => {
let def = common.choose(data.list)
if (def.operator && !fb.operators[msg.author.id])
msg.reply(`Sorry, you need to be an operator run this command: ${cmd}`)
else
- def.func(msg, args, fb)
+ def.func(msg, args)
} else {
msg.reply(`Invalid command: ${cmd}`)
}
}
})
-//const modules = ["nsfw", "random", "http", "operator"]
+//const modules = ["nsfw", "random", "operator"]
const modules = ["basic", "bullshit", "marriage", "http", "roleplay", "death", "economy", "waifu"]
for (let f of modules) {
if (m)
for (let k in m)
- fb.commands[k] = m[k]
+ if (k != "__init")
+ fb.commands[k] = m[k]
+
+ m?.__init?.(fb)
}
--- /dev/null
+let operators, ignored
+
+furrybot.list_change_command("op", "operators", "an operator", true)
+furrybot.list_change_command("deop", "operators", "an operator", nil)
+furrybot.list_command("oplist", "operators", "operators")
+
+furrybot.list_change_command("ignore", "ignored", "ignored", true)
+furrybot.list_change_command("unignore", "ignored", "ignored", nil)
+furrybot.list_command("ignorelist", "ignored", "ignored players")
+++ /dev/null
-local http, env, storage
-local C = minetest.get_color_escape_sequence
-
-furrybot.commands.reload = {
- operator = true,
- func = function()
- furrybot.reload()
- end,
-}
-
-furrybot.commands.disconnect = {
- operator = true,
- func = function()
- minetest.disconnect()
- end,
-}
-
-furrybot.list_change_command("op", "operators", "an operator", true)
-furrybot.list_change_command("deop", "operators", "an operator", nil)
-furrybot.list_command("oplist", "operators", "operators")
-
-furrybot.list_change_command("ignore", "ignored", "ignored", true)
-furrybot.list_change_command("unignore", "ignored", "ignored", nil)
-furrybot.list_command("ignorelist", "ignored", "ignored players")
-
-return function(_http, _env, _storage)
- http, env, storage = _http, _env, _storage
-end
}
},
"node_modules/free-google-images": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/free-google-images/-/free-google-images-1.1.1.tgz",
- "integrity": "sha512-tvMekRNXz8HZbOYO5YbmuVPWOTl2g7/njk24qziEZbXiH+Biy+WYpb+oEJLb7O+owkYPcIMSdL5i8i2Z0spshg==",
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/free-google-images/-/free-google-images-1.2.0.tgz",
+ "integrity": "sha512-hncHlKgWOgmGNjwSA0QEU25bThPAjfn+7XCBju7vf+PawCGn4k76+FRJ/HBrvPyrys3B06G3+Apli6v/4Cg0kQ==",
"dependencies": {
"cheerio": "^1.0.0-rc.10",
"jsonic": "^1.0.1",
}
},
"free-google-images": {
- "version": "1.1.1",
- "resolved": "https://registry.npmjs.org/free-google-images/-/free-google-images-1.1.1.tgz",
- "integrity": "sha512-tvMekRNXz8HZbOYO5YbmuVPWOTl2g7/njk24qziEZbXiH+Biy+WYpb+oEJLb7O+owkYPcIMSdL5i8i2Z0spshg==",
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/free-google-images/-/free-google-images-1.2.0.tgz",
+ "integrity": "sha512-hncHlKgWOgmGNjwSA0QEU25bThPAjfn+7XCBju7vf+PawCGn4k76+FRJ/HBrvPyrys3B06G3+Apli6v/4Cg0kQ==",
"requires": {
"cheerio": "^1.0.0-rc.10",
"jsonic": "^1.0.1",