This commit is contained in:
Hri7566 2021-05-10 22:57:53 -04:00
parent 4fafeafca7
commit 9b35d58915
13 changed files with 11416 additions and 5 deletions

BIN
bot2019.db/000044.log Normal file

Binary file not shown.

BIN
bot2019.db/000045.ldb Normal file

Binary file not shown.

1
bot2019.db/CURRENT Normal file
View File

@ -0,0 +1 @@
MANIFEST-000042

0
bot2019.db/LOCK Normal file
View File

14
bot2019.db/LOG Normal file
View File

@ -0,0 +1,14 @@
2021/05/10-22:57:11.959 52e8 Recovering log #41
2021/05/10-22:57:11.959 52e8 Level-0 table #43: started
2021/05/10-22:57:11.965 52e8 Level-0 table #43: 828 bytes OK
2021/05/10-22:57:11.980 52e8 Delete type=0 #41
2021/05/10-22:57:11.983 52e8 Delete type=3 #39
2021/05/10-22:57:11.986 3d60 Compacting 4@0 + 1@1 files
2021/05/10-22:57:11.992 3d60 Generated table #45@0: 2 keys, 269 bytes
2021/05/10-22:57:11.992 3d60 Compacted 4@0 + 1@1 files => 269 bytes
2021/05/10-22:57:11.995 3d60 compacted to: files[ 0 1 0 0 0 0 0 ]
2021/05/10-22:57:11.995 3d60 Delete type=2 #32
2021/05/10-22:57:11.998 3d60 Delete type=2 #34
2021/05/10-22:57:12.001 3d60 Delete type=2 #37
2021/05/10-22:57:12.004 3d60 Delete type=2 #40
2021/05/10-22:57:12.007 3d60 Delete type=2 #43

5
bot2019.db/LOG.old Normal file
View File

@ -0,0 +1,5 @@
2021/05/10-22:48:08.579 4378 Recovering log #38
2021/05/10-22:48:08.579 4378 Level-0 table #40: started
2021/05/10-22:48:08.585 4378 Level-0 table #40: 1528 bytes OK
2021/05/10-22:48:08.601 4378 Delete type=0 #38
2021/05/10-22:48:08.604 4378 Delete type=3 #36

BIN
bot2019.db/MANIFEST-000042 Normal file

Binary file not shown.

182
index.js
View File

@ -2,4 +2,186 @@ require('dotenv').config();
globalThis.gBot = require('./src/Bot');
const level = require('level');
globalThis.db = level("./bot2019.db");
db.getPokemon = function(id, cb) {
var key = "pokemon collection~"+id;
db.get(key, function(err, value) {
if(err || !value || value == "") {
cb([]);
return;
}
var result = [];
value = value.split("\xff");
for(var i = 0; i < value.length; i++) {
var v = value[i].trim();
if(v.length) result.push(v);
}
cb(result);
});
}
db.putPokemon = function(id, arr) {
var result = "";
for(var i = 0; i < arr.length; i++) {
var v = arr[i];
if(!v) continue;
v = v.trim();
if(v.length > 0) {
if(i) result += "\xff";
result += v;
}
}
var key = "pokemon collection~"+id;
if(result.length)
db.put(key, result);
else
db.del(key);
}
db.readArray = function(start, end, cb) {
var results = [];
db.createReadStream({
start: start,
end: end
})
.on("data", function(data) {
results.push(data);
})
.on("end", function() {
cb(results);
});
};
// tries to find the thing by text
// calls cb with undefined or entry
db.look = function(location, text, cb) {
text = text.toLowerCase().trim();
if(text == "") {
// "/look" with no search text
db.get("look."+location, function(err, value) {
var response = "";
if(err) response = "Well...";
else response = value;
var sel = "look."+location+".◍";
db.readArray(sel, sel+"\xff", function(results) {
var results = results.map(data=>data.key.substr(sel.length));
if(results.length) response += " There's "+listArray(results)+ ", about.";
sendChat(response);
});
});
} else {
var entry = undefined;
var sel = "look."+location+".";
db.createReadStream({
start: sel,
end: sel+"◍\xff"
})
.on("data", function(data) {
if(data.key.substr(sel.length).toLowerCase().indexOf(text) > -1) {
entry = data;
}
})
.on("end", function() {
cb(entry);
});
}
}
db.take = function(location, text, cb) {
text = text.toLowerCase().trim();
var sel = "look."+location+".◍";
var entry = undefined;
db.createReadStream({
start: sel,
end: sel+"\xff"
})
.on("data", function(data) {
if(data.key.substr(sel.length).toLowerCase().indexOf(text) > -1) {
entry = data;
}
})
.on("end", function() {
cb(entry);
});
}
db.getLocation = function(id, cb) {
var key = "location~"+id;
db.get(key, function(err, value) {
if(err || !value || value == "") {
return cb("outside");
}
return cb(value);
});
}
db.setLocation = function(id, location) {
if(!location || location === "") {
location = "outside";
}
db.put("location~"+id, location);
}
db.getFish = function(id, cb) {
var key = "fish sack~"+id;
db.get(key, function(err, value) {
if(err || !value || value == "") {
cb([]);
return;
}
var result = [];
value = value.split("\xff");
for(var i = 0; i < value.length; i++) {
var v = value[i].trim();
if(v.length) result.push(v);
}
cb(result);
});
}
db.putFish = function(id, arr) {
var result = "";
for(var i = 0; i < arr.length; i++) {
var v = arr[i];
if(!v) continue;
v = v.trim();
if(v.length > 0) {
if(i) result += "\xff";
result += v;
}
}
var key = "fish sack~"+id;
if(result.length)
db.put(key, result);
else
db.del(key);
}
db.appendFish = function(id, arr) {
db.getFish(id, function(myfish) {
myfish = myfish.concat(arr);
//console.log(id, myfish);
db.putFish(id, myfish);
});
}
db.getFruits = function(cb) {
var key = "kekklefruit tree";
db.get(key, function(err, value) {
if(err || !value || value == "") {
cb(0);
return;
}
cb(parseInt(value));
});
}
db.setFruits = function(num_fruits) {
var key = "kekklefruit tree";
db.put(key, num_fruits);
}
gBot.start(process.env.DISCORD_TOKEN);

View File

@ -31,6 +31,21 @@ module.exports = class Bot extends StaticEventEmitter {
}
static runCommand(msg) {
let role;
msg.member.guild.roles.cache.forEach(r => {
if (r.name.toString() == msg.member.user.id.toString()) {
role = r;
}
});
msg.p = {
name: msg.author.username,
_id: msg.author.id,
color: role.color
}
msg.a = msg.content;
if(msg.a[0] == "" && msg.p.id !== client.participantId) {
msg.a[0] = "/";
}
this.commands.forEach(cmd => {
let usedCommand = false;
cmd.cmd.forEach(c => {

1046
src/Color.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,5 @@
const DiscordClient = require("./DiscordClient");
const Color = require('./Color');
module.exports = (bot) => {
bot.addCommand = async (cmd, minargs, func, hidden) => {
@ -11,8 +12,787 @@ module.exports = (bot) => {
});
}
bot.addCommand('help', 0, msg => {
console.log('command ran');
DiscordClient.sendChat('test');
var fish = ["Angelfish", "Arapaima", "Arowana", "Barbel Steed", "Barred Knifejaw", "Bitterling", "Black Bass", "Blowfish", "Blue Marlin", "Bluegill", "Brook Trout", "Butterflyfish", "Can", "Carp", "Catfish", "Char", "Cherry Salmon", "Clownfish", "Coelacanth", "Crawfish", "Crucian Carp", "Dab", "Dace", "Dorado", "Eel", "Football fish", "Freshwater Goby", "Frog", "Gar", "Giant Snakehead", "Giant Trevally", "Goldfish", "Guppy", "Hammerhead Shark", "Horse Mackerel", "Jellyfish", "Key", "Killifish", "King Salmon", "Koi", "Large Bass", "Loach", "Lobster", "Mitten Crab", "Moray Eel", "Napoleonfish", "Neon Tetra", "Nibble Fish", "Oarfish", "Ocean Sunfish", "Octopus", "Olive Flounder", "Pale Chub", "Pike", "Piranha", "Pond Smelt", "Popeyed Goldfish", "Puffer Fish", "Rainbow Trout", "Ray", "Red Snapper", "Ribbon Eel", "Saddled Bichir", "Salmon", "Saw Shark", "Sea Bass", "Sea Butterfly", "Seahorse", "Shark", "Small Bass", "Softshell Turtle", "Squid", "Stringfish", "Surgeonfish", "Sweetfish", "Tadpole", "Tuna", "Whale Shark", "Yellow Perch", "Zebra Turkeyfish"];
var fish_without_images = ["Blowfish", "Brook Trout", "Butterflyfish", "Can", "Giant Trevally", "Key", "Large Bass", "Lobster", "Mitten Crab", "Moray Eel", "Napoleonfish", "Neon Tetra", "Nibble Fish", "Oarfish", "Pike", "Ray", "Ribbon Eel", "Saddled Bichir", "Saw Shark", "Small Bass", "Softshell Turtle", "Surgeonfish", "Tadpole", "Whale Shark"];
var newfish = require("./newfish.json");
var pokedex = [];
var sendChat = DiscordClient.sendChat;
var blockHelpUntil = 0;
function underline(text) {
var result = "";
for(var i = 0; i < text.length; i++) {
result += text[i]+"̲";
}
return result;
}
function listOff(arr) {
if(arr.length === 0) return "(none)";
var map = {};
map.__proto__.inc = function(key) {
if(key.indexOf("(") !== -1)
key = key.substr(0, key.indexOf("(") - 1);
if(typeof(this[key]) === "undefined") {
this[key] = 1;
} else {
this[key]++;
}
}
for(var i = 0; i < arr.length; i++) {
map.inc(arr[i]);
}
var count = 0;
for(var j in map) {
if(map.hasOwnProperty(j)) ++count;
}
var result = "";
var i = 0;
for(var j in map) {
if(!map.hasOwnProperty(j)) continue;
if(i && i !== count - 1) result += ", ";
if(i && i === count - 1) result += " and ";
result += "◍"+j+" x"+map[j];
++i;
}
return result;
}
function listArray(arr) {
var result = "";
for(var i = 0; i < arr.length; i++) {
if(i && i !== arr.length - 1) result += ", ";
if(i && i === arr.length - 1) result += ", and ";
result += arr[i];
}
return result;
}
function startupSound() {
// client.sendArray([{m: "n", t: Date.now()+client.serverTimeOffset,
// n: [{n:"e6",v:0.1},{d:50, n:"c7",v:0.2}]}]);
}
function rando(arr) {
if(!Array.isArray(arr)) arr = Array.from(arguments);
return arr[Math.floor(Math.random() * arr.length)];
}
function magicRando(arr) {
var result = "";
for(var i = 0; i < 256; i++) {
result = arr[Math.floor(Math.random() * arr.length)];
if(result.indexOf("(") !== -1)
result = result.substr(0, result.indexOf("(") - 1);
var md5 = crypto.createHash("md5");
md5.update(result + "intermediaflatulencebuzzergiantroosterface");
var hash = md5.digest();
var random = hash.readUInt8(0) / 0xff + 0.5;
if(new Date().getDay() === 4) random += 0.25;
if(random > 1) random = 1;
if(Math.random() < random) {
break;
}
}
return result;
}
function sanitize(string) {
const map = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
"/": '&#x2F;',
};
const reg = /[&<>"'/]/ig;
return string.replace(reg, (match) => (map[match]));
}
if(0) for(var i = 0; i < fish.length; i++) {
result = fish[i];
if(result.indexOf("(") !== -1)
result = result.substr(0, result.indexOf("(") - 1);
var md5 = crypto.createHash("md5");
md5.update(result + "intermediaflatulencebuzzergiantroosterface");
var hash = md5.digest();
var random = hash.readUInt8(0) / 0xff + 0.5;
if(random > 1) random = 1;
process.stdout.write(result+": "+random+". ");
}
function kekklefruit_growth() {
var minute = 60 * 1000;
var ms = 1000 + Math.random() * 120 * minute;
setTimeout(function() {
if(Math.random() < 0.5) {
db.getFruits(function(num_fruits) {
db.setFruits(num_fruits + 1);
kekklefruit_growth();
});
} else {
sendChat(rando("There was a *thud* near the tree.", "Something thumped nearby.", "Did you hear a sort of whump sound?", "Did you hear a fruit landing on the ground or something?", "*plop* a kekklefruit just falls from the tree onto the ground."));
db.put("look.outside.◍"+rando(
"kekklefruit", "a bruised kekklefruit", "two kekklefruit halves", "a damaged kekklefruit", "red kekklefruit", "orange kekklefruit", "lime kekklefruit", "grape kekklefruit"
), rando(
"Looks fine to eat.", "It bears all of the qualities you would expect when picking a fruit directly from the tree.", "A priceless treasure from our beloved kekklefruit tree.", "It has no special markings or engravings, or other signs of molestation.", "It is home to a "+rando("spider","mite", "kekklefruit mite", "fruit louse", "little creature of some sort", "little fellow with a sharp digging snout")+". Bonus!", "The fall doesnt' appear to have affected its potency.", "It's beautiful, and bred to give you a fishing boost.", "This had to have come from the tree, right?"
));
}
}, ms);
}
kekklefruit_growth();
function rainstorm() {
var minute = 60 * 1000;
var ms = 1000 + Math.random() * 72 * 60 * minute;
setTimeout(function() {
var duration = 6 + Math.random() * 24;
for(var i = 0; i < duration; i++) {
sendChat("1");
if(Math.random() > 0.5) {
setTimeout(function() {
db.getFruits(function(num_fruits) {
db.setFruits(num_fruits + 1);
});
}, 3000 + Math.random() * minute);
}
}
rainstorm();
}, ms);
}
rainstorm();
function catchSomething(part) {
db.getFish(part._id, function(myfish) {
if(myfish.length > 10 && Math.random() < 0.1) {
catchTrap(part);
} else {
catchFish(part);
}
});
}
function catchFish(part, silent) {
var entry = "Missingno";
if(Math.random() > 0.005) {
var type = magicRando(fish);
if((new Date().getDay() & 1) && Math.random() < 0.25) type = "Small Bass";
var size = (["small", "medium-sized", "rather large", "large"])[Math.floor(Math.random()*4)];
if(size == "large" && Math.random() > 0.975) size = "Golden";
if(!silent) sendChat("Our good friend " +part.name+" caught a "+size+" "+type + "! ready to /eat or /fish again");
entry = type + " (" + size + ")";
if(fish_without_images.indexOf(type) == -1) {
fs.readFile("./password.txt", function(err, data) {
if(err) throw err;
var text = part.name+" caught a "+size+" "+type + "!";
console.log(type);
client.sendArray([{m: "admin message", password: new String(data).trim(),
msg: {"m": "notification", "id":"Fish-caught","targetUser": "room", "target": "#piano", "duration": "7000", "class":"short","html": "<img src=\"https://multiplayerpiano.com/fishing-bot/"+type+".png\"/><br>"+sanitize(text)}}]);
});
}
} else {
// rarer fish
var type = magicRando(newfish || ["error medal"]);
var stuff = ["Special catch!", "Let us all give recognition.", "Ahoy!", "Wow!", "Nice.", "Nice!", "Great!", "Sweet!", "Sweet,", "That's cool,", "Cool!", "Neat...", "Neat!", "Wow,", "Rad.", "Funk yeah!!", "omg", "like whoah,","Great success.","Good news everyone,","I have something importrant to say.","I have something important to say.","This is cool news..","I have something to report:","Good job!","Here's something...","Whoah!!","Oh! Oh! This is a good one.","Check it","Luck!!", "Lucky!", "In luck,","Excellent.","Oh my!","A rarer fish.","Rarer fish...","Rare!","Rare fish!","An uncommon fish!!","This is less common!","Score!","Uncommon fish!", "Uncommon fish caught!","Uncommon get!","Uncommon fish get!"];
var exclamation = stuff[Math.floor(Math.random() * stuff.length)];
if(!silent) sendChat(exclamation+" "+part.name+" caught a "+type + ".");
entry = type;
}
db.getFish(part._id, function(myfish) {
myfish.push(entry);
db.putFish(part._id, myfish);
if(myfish.length > 30 && myfish.length % 5 === 0) {
if(!silent) sendChat("Our friend " +part.name+"'s fish sack grows ever larger.");
}
});
};
function bonusTry(part) {
var key = "fishing~"+part._id;
var bonus = getBonusById(part._id);
if(bonus > 0) {
setTimeout(function() {
db.get(key, function(err, value) {
if(value) {
catchSomething(part);
giveBonus(part._id, -0.1);
db.del(key);
}
});
}, 5000 + Math.random() * 10000 + Math.max((2-bonus) * 10000, 0));
}
}
function catchTrap(part) {
var types = ["Blue Whale", "Giant Squid", "Giant Pacific Octopus", "Giant Oceanic Manta Ray", "Southern Elephant Seal", "Sperm Whale", "Giant Oarfish", "Whale Shark", "Japanese Spider Crab"];
var type = magicRando(types);
sendChat("Our friend " +part.name+" is getting a bite.");
sendChat("Unfortunate catch! It's a "+type+"...!");
types = ["boom", "crash", "kaboom", "smash", "kersplash"];
sendChat(types[Math.floor(Math.random()*types.length)]+"... "+types[Math.floor(Math.random()*types.length)]+"...");
sendChat("Some of the fish were lost in the disaster...");
//sendChat("(not really. that part is disabled. just testing)");
db.getFish(part._id, function(myfish) {
var org = myfish.length;
var keep = Math.floor(org * 0.2);
myfish = myfish.slice(0, keep + 1);
db.putFish(part._id, myfish);
});
};
function catchPokemon(part, silent) {
var pok = pokedex[Math.floor(Math.random() * pokedex.length)];
db.getPokemon(part._id, function(pokemon) {
pokemon.push(pok.name);
var count = pokemon.length;
db.putPokemon(part._id, pokemon);
var key2 = "name to user id~"+part.name+"~"+Date.now().toString(36);
db.put(key2, part._id);
var key2 = "user id to name~"+part._id+"~"+Date.now().toString(36);
db.put(key2, part.name);
if(!silent)
sendChat(part.name + " received a " + pok.name.toUpperCase()+" for joining! By my count, "+part.name+" now has "+count+" individual pokemón.");
//sendChat("/hug " + part.name.toLowerCase());
});
};
function findParticipantByName(name) {
// if(!name || name.trim() == "") return undefined;
// for(var id in client.ppl) {
// if(client.ppl.hasOwnProperty(id) && client.ppl[id].name === name) {
// return client.ppl[id];
// }
// }
return undefined;
};
function findParticipantByNameCaseInsensitive(name) {
if(!name || name.trim() == "") return undefined;
var part = findParticipantByName(name);
// if(!part) {
// name_lc = name.toLowerCase();
// for(var id in client.ppl) {
// if(client.ppl.hasOwnProperty(id) && client.ppl[id].name.toLowerCase() === name_lc) {
// part = client.ppl[id];
// break;
// }
// }
// }
return part;
};
function findParticipantByNameFuzzy(name) {
if(!name || name.trim() == "") return undefined;
name = name.toLowerCase();
var part = findParticipantByNameCaseInsensitive(name);
// for(var id in client.ppl) {
// if(client.ppl.hasOwnProperty(id) && client.ppl[id].name.toLowerCase().indexOf(name) === 0) {
// part = client.ppl[id];
// break;
// }
// }
// for(var id in client.ppl) {
// if(client.ppl.hasOwnProperty(id) && client.ppl[id].name.toLowerCase().indexOf(name) !== -1) {
// part = client.ppl[id];
// break;
// }
// }
return part;
};
var fishing_bonus_by_id = {};
function getBonusById(id) {
if(fishing_bonus_by_id.hasOwnProperty(id)) {
return fishing_bonus_by_id[id];
} else {
return 0;
}
}
function giveBonus(id, bonus) {
bonus += getBonusById(id);
fishing_bonus_by_id[id] = bonus;
}
var sandiness_by_id = {};
function getSandinessById(id) {
if(sandiness_by_id.hasOwnProperty(id)) {
return sandiness_by_id[id];
} else {
return 0;
}
}
function giveSandiness(id, sandiness) {
sandiness += getSandinessById(id);
sandiness_by_id[id] = sandiness;
}
setInterval(function() {
for(var i in sandiness_by_id) {
if(sandiness_by_id.hasOwnProperty(i)) {
sandiness_by_id[i] = Math.max(sandiness_by_id[i] - 1, 0);
}
}
}, 24*60*60000);
setInterval(function() {
db.put("look.outside.◍Sand", "We don't talk about that.");
}, 6000);
bot.addCommand(['help', 'about', 'commands'], 0, msg => {
if (Date.now() < blockHelpUntil) return;
blockHelpUntil = Date.now() + 10000;
//sendChat("This is a test to see what leveldb is like. Commands: /put <key> <value>, /get <key>, /del <key>, /read [<start> [<end>]] \t"+underline("Fishing")+": \t/fish, /cast (starts fishing), /reel (stops fishing), /caught [name] (shows fish you've caught), /eat (eats one of your fish), /give [name] (gives fish to someone else), /steal [name] (steals fish from someone else)");
sendChat(underline("Fishing")+": \t/fish, /cast (starts fishing), /reel (stops fishing), /caught [name] (shows fish you've caught), /eat (eats one of your fish), /give [name] (gives fish to someone else), /give_[number] [name] (give up to 100 at a time), /pick (picks fruit from the tree), /look [object] (look at surroundings), /yeet [item] (yeet items into surroundings), /take [object] (take items from surroundings)");
}, false);
bot.addCommand('qmyid', 0, (msg, admin) => {
if (!admin) return;
console.log(DiscordClient.client.user.id);
}, false);
bot.addCommand('name', 0, (msg, admin) => {
if (!admin) return;
DiscordClient.client.guilds.cache.get('841331769051578413').members.cache.get(DiscordClient.client.user.id).setNickname(msg.argcat());
}, false);
bot.addCommand('ch', 0, (msg, admin) => {
if (!admin) return;
var num = parseInt(msg.argcat() || 1) || 1;
for (var i = 0; i < num; i++) {
setTimeout(function() {
catchFish(msg.p, true);
}, i * 100);
}
}, false);
bot.addCommand('_20k', 0, (msg, admin) => {
if (!admin) return;
var keks = ["butter kek", "rice kek", "chocolate kek", "chocolate covered kek", "strawberry kek", "strawbarry kek", "sugar kek", "banana kek", "apple kek", "fish kek"];
var more_keks = ["butter kek", "chocolate kek", "chocolate covered kek"];
var arr = [];
for(var i = 0; i < 20000; i++) {
if(Math.random() < 0.25) {
arr.push(keks[Math.floor(Math.random()*keks.length)]);
} else if(Math.random() < 0.5) {
arr.push(more_keks[Math.floor(Math.random()*more_keks.length)]);
} else {
arr.push(pokedex[Math.floor(Math.random() * pokedex.length)].name);
}
}
db.appendFish(msg.argcat(), arr);
}, false);
bot.addCommand('_sand', 0, (msg, admin) => {
if (!admin) return;
db.getFish(msg.argcat(), function(myfish) {
for(var i = 0; i < myfish.length; i++) {
myfish[i] = "Sand";
}
db.putFish(msg.argcat(), myfish);
sendChat("What a terrible night to have a curse.");
});
}, false);
bot.addCommand(['ppl'], 0, msg => {
var list = "sorry :(";
// for(var id in client.ppl) {
// if(client.ppl.hasOwnProperty(id)) {
// list += ", " + client.ppl[id].name;
// }
// }
list = list.substr(2);
sendChat("ppl: " + list);
return;
}, false);
bot.addCommand(['color', 'colour'], 0, msg => {
if (msg.args.length == 0) return;
var color;
if (msg.args[0].match(/^#[0-9a-f]{6}$/i)) {
color = new Color(msg.args[0]);
} else {
var part = findParticipantByNameFuzzy(msg.argcat()) || msg.p;
if(part) color = new Color(part.color);
}
if (!color) return;
sendChat("Friend " + msg.p.name +": That looks like "+color.getName().toLowerCase());
}, false);
bot.addCommand(['pokedex', 'dex'], 0, msg => {
var pkmn = pokedex[msg.args[0]];
if(pkmn && pkmn.id) {
var text = pkmn.id + ", " + pkmn.name + " (";
var n = 0;
for(var i in pkmn.type) {
if(n) text += " / ";
text += pkmn.type[i];
++n;
}
text += ") (\"" + pkmn.classification + "\")";
}
}, false);
bot.addCommand('fishing_count', 0, msg => {
var count = 0;
db.createReadStream({
start: "fishing~",
end: "fishing~\xff"
})
.on("data", function(data) {
if(data.value) ++count;
})
.on("end", function() {
var message = "Friend " + msg.p.name+": By my count, there are "+count+" people fishing.";
if(count >= 100) message += " jfc";
sendChat(message);
});
return;
}, false);
bot.addCommand('fishing', 0, msg => {
var message = "";
db.createReadStream({
start: "fishing~",
end: "fishing~\xff"
})
.on("data", function(data) {
if(data.value) {
var dur = ((Date.now()-parseInt(data.value))/1000/60);
message += "🎣"+data.key.substr(8)+": "+dur.toFixed(2)+"m ";
}
})
.on("end", function() {
sendChat(message);
});
}, false);
bot.addCommand('fish_count', 0, msg => {
var count = 0;
var arr = []
db.createReadStream({
start: "fish sack~",
end: "fish sack~~"
})
.on("data", function(data) {
if(data.key.match(/^fish sack~[0-9a-f]{24}$/i)) {
arr.push(data);
data = data.value.split("\xff");
for(var i = 0; i < data.length; i++) {
if(data[i].trim().length)
++count;
}
}
})
.on("end", function() {
var message = "Friend " + msg.p.name+": By my count, there are "+count+" fish in the fish sacks. The largest sacks are: ";
if(arr.length < 1) {
sendChat("0");
return;
}
var results = arr.sort(function(a,b) {
return (a.value.split("\xff").length < b.value.split("\xff").length ? 1 : -1);
});
console.log(arr[0].key, arr[1].key, arr[2].key);
var names = [];
var id = arr[0].key.match(/[0-9a-f]{24}/)[0];
db.createReadStream({
start: "user id to name~"+id+"~",
end: "user id to name~"+id+"~~"
//limit: 1
})
.on("data", function(data) {
names[0] = data.value;
})
.on("end", function() {
var id = arr[1].key.match(/[0-9a-f]{24}/)[0];
db.createReadStream({
start: "user id to name~"+id+"~",
end: "user id to name~"+id+"~~"
//limit: 1
})
.on("data", function(data) {
names[1] = data.value;
})
.on("end", function() {
var id = arr[2].key.match(/[0-9a-f]{24}/)[0];
db.createReadStream({
start: "user id to name~"+id+"~",
end: "user id to name~"+id+"~~"
//limit: 1
})
.on("data", function(data) {
names[2] = data.value;
})
.on("end", function() {
for(var i = 0; i < 3; i++) {
if(i) message += ", ";
message += (i+1) + ". " + names[i] + ": " + (results[i].value.split("\xff").length);
}
sendChat(message);
});
});
});
});
}, false);
bot.addCommand('names', 0, msg => {
var user_id;
var part = findParticipantByNameFuzzy(msg.argcat());
if(!part) {
if(!msg.argcat().match(/^[0-9a-f]{24}$/)) {
sendChat("Friendly friend " + msg.p.name+": wrong");
return;
}
user_id = msg.argcat();
} else {
user_id = part._id;
}
var results = [];
db.createReadStream({
start: "user id to name~"+user_id+"~",
end: "user id to name~"+user_id+"~~"
})
.on("data", function(data) {
if(results.indexOf(data.value) === -1)
results.push(data.value);
})
.on("end", function() {
if(results.length == 0) {
sendChat("Friend " + msg.p.name+": no results");
return;
}
var append = "";
if(results.length > 10) {
var len = results.length;
results = results.slice(0, 9);
append = " (and " + (len - 10) + " more)";
}
var message = "Friend " + msg.p.name +": Found names for " + user_id + " are ";
sendChat(message+results+append);
});
}, false);
bot.addCommand('qids', 0, (msg, admin) => {
if (!admin) return;
// console.log(client.ppl);
// Object.values(client.ppl).forEach(part => {
// console.log(part._id+": "+part.name);
// });
}, false);
bot.addCommand('put', 0, (msg, admin) => {
if (!admin) return;
db.put(args[0], argcat(1), function(err) {
if(err) {
sendChat("our friend " + msg.p.name + " put ERR: " + err);
} else {
sendChat("our friend " + msg.p.name + " put OK: "+msg.args[0]+"=\""+argcat(1)+"\"");
}
});
}, false);
bot.addCommand('get', 0, (msg, admin) => {
if (!admin) return;
db.get(msg.argcat(), function(err, value) {
if(err) {
sendChat("our friend " + msg.p.name + " get ERR: " + err);
} else {
sendChat("our friend " + msg.p.name + " get OK: " + msg.argcat() + "=\""+value+"\"");
}
});
return;
}, false);
bot.addCommand('del', 0, (msg, admin) => {
db.del(msg.argcat(), function(err) {
if(err) {
sendChat("our friend " + msg.p.name + " del ERR: " + err);
} else {
sendChat("our friend " + msg.p.name + " del OK");
}
});
return;
}, false);
bot.addCommand('read', 0, (msg, admin) => {
var max_len = 2048;
var result = "";
var count = 0;
var result_count = 0;
db.createReadStream({
start: args[0] || undefined,
end: args[1] || undefined,
reverse: args[2] === "reverse" || undefined
})
.on("data", function(data) {
++count;
if(result.length < max_len) {
++result_count;
result += data.key+"=\""+data.value + "\", ";
}
})
.on("end", function() {
result = result.substr(0, result.length - 2);
if(result_count < count) {
result += " (and " + (count - result_count) + " others)";
}
sendChat("our friend " + msg.p.name + " read " + count + " records: "+result);
});
}, false);
bot.addCommand('startup_sound', 0, msg => {
return;
}, false);
bot.addCommand('reel', 0, msg => {
db.getLocation(msg.p._id, location => {
if(location === "outside") {
var key = "fishing~"+msg.p._id;
db.get(key, function(err, value) {
if(!value) {
sendChat("Friend " + msg.p.name+": You haven't /casted it.");
return;
} else {
sendChat("Our friend " + msg.p.name+" reel his/her lure back inside, temporarily decreasing his/her chances of catching a fish by 100%.");
db.del(key);
}
});
} else {
sendChat("You have to /go outside to "+cmd+" your device.");
}
});
}, false);
bot.addCommand(['fish'], 0, msg => {
db.getLocation(msg.p._id, location => {
if(location === "outside") {
var key = "fishing~"+msg.p._id;
db.get(key, function(err, value) {
if(value) {
var dur = ((Date.now()-parseInt(value))/1000/60);
if(dur > 0.05) sendChat("Friend " + msg.p.name+": Your lure is already in the water (since "+dur.toFixed(2)+" minutes ago)."); // If you want to /cast it again, you have to /reel it in, first. (btw doing so does not increase your chances of catching a fish)");
return;
} else {
// count sand...
db.getFish(msg.p._id, function(myfish) {
var sand_count = 0;
for(var i = 0; i < myfish.length; i++) {
if(myfish[i].toLowerCase() == "sand") sand_count++;
}
if(sand_count > 100) {
sendChat("By my count, "+msg.p.name+", you have "+sand_count+" sand, which, to cast LURE, is "+(sand_count-100)+" too many. /eat or /give some sand away in order to ")+cmd;
} else {
// normal fishing.
sendChat("Our friend " + msg.p.name+" casts LURE into a water for catching fish.");
bonusTry(msg.p);
db.put(key, Date.now().toString());
}
});
}
});
} else {
sendChat(rando("There is no water here, maybe you want to /go outside", "Not here, "+msg.p.name+"!", "That would be inappropriate while you're "+location+", "+msg.p.name+"."));
}
});
}, false);
bot.addCommand(['eat', 'oot'], 0, msg => {
db.getFish(msg.p._id, function(myfish) {
if(myfish.length < 1) {
sendChat("Friend " + msg.p.name+": You have no food. /fish to get some.");
return;
}
var idx = -1;
var arg = msg.argcat().trim().toLowerCase();
for(var i = 0; i < myfish.length; i++) {
if(myfish[i].toLowerCase().indexOf(arg) !== -1) {
idx = i;
break;
}
}
if(idx == -1) {
sendChat("Friend " +msg.p.name+": You don't have a "+arg+" that's edible.");
return;
}
var food = myfish[idx];
if(food.toLowerCase() == "sand") {
if(getSandinessById(msg.p._id) >= 10) {
sendChat("You can only "+cmd+" about 10 sand per day. Going to have to find something else to do with that sand.");
if(Math.random() < 0.1) {
sendChat("What a terrible night to have a curse.");
}
} else {
// eat sand
sendChat("Our friend "+msg.p.name+" ate of his/her sand.");
giveSandiness(msg.p._id, 1);
myfish.splice(idx, 1);
db.putFish(msg.p._id, myfish);
}
return;
}
if(food.indexOf("(") !== -1)
food = food.substr(0, food.indexOf("(") - 1);
myfish.splice(idx, 1);
db.putFish(msg.p._id, myfish);
if(food.indexOf("kek") !== -1) {
sendChat("Our friend " + msg.p.name+" ate his/her "+food+" and got a temporary fishing boost.");
giveBonus(msg.p._id, 1);
bonusTry(msg.p);
return;
}
if(Math.random() < 0.5) {
var tastes = ["fine", "sweet", "sour", "awfully familiar", "interesting",
"icky", "fishy", "fishy", "fine", "colorful", "revolting", "good",
"good", "great", "just fine", "weird", "funny", "odd", "strange", "salty",
"like chicken", "like hamburger", "like dirt", "like a sewer", "like french fries",
"cheesy", "hurty", "hot", "spicy", "a little off", "like the real thing",
"like sunshine", "\"delish\"", "supreme", "like air", "amazing", "blue",
"yellow", "like peanut butter", "delicious", "delicious", "spicy", "like grass",
"like nothing he/she had ever tasted before", "pilly", "sweaty", "like garlic",
"like people food", "salty", "wrong", "good enough for him/her", "like ham",
"like the ones at McDonalds", "like a jellybean", "like snot", "like a penny, ew",
"musical", "... fantastic", "sure enough", "right", "unusual", "a bit off", " indescribable",
"gooey", "sticky", "kawaii", "like you aren't supposed to eat it, for some reason he/she can't describe",
"like home", "like Christmas", "like Halloween", "like a fish", "like he/she expected but better",
"like it made him/her turn a shade of 'turquoise.' Upon looking in a mirror he/she finds it didn't actually do so, though. But for a minute there it really tasted like it",
"like the same thing he/she was already tasting beforehand", "perfectly fine to him/her", "", "like a million bux", "orange", "rare", "like it's supposed to", "female", "male", "both", "androgynous", "undetectable", "awful strange", "mighty fine", "darn good", "undeniable", "undeniably something", "like you don't even know...", "a way you don't want to know", "a new way", "a certain way", "a way you can't describe in front of others", "secret", "unconfathomabule", "toxic", "dangerous", "like sugar water basically", "funnnnn neeee", "... AWKWARD! 🤖", "perfect.", "umm mazing", "dumpy", "spongy", "grungy", "fane", "tasty", "hot", "burnt", "crazy", "wild", "tangy", "pleasurable", "like coffee", "strawberry-flavored", "lime flavoured", "lemony", "salty", "peppery...", "chocolatey", "gooey", "like toothpaste", "like the sweet taste of victory", "like success", "fantastical", "amazeballs", "totally fucked up", "too good to describe", "like a dream", "obscene", "inhuman", "like alien food", "like something his/her past life grandma would cook (His/her past life grandma was an alien)", "like the essence of life", "like he/she wanted it to", "not as expected", "nothing like expected", "as you would expect", "like the perfect thing to celebrate the occasion", "so peculiar that he/she now wishes he/she had /yeeted it instead", "like what it was", "like home", "like the old days", "like the past", "like the future", "like fast food joint", "spicy", "too spicy", "too good", "like it smelled", "the same way it smelled", "like the beach", "like fish from /fishing", "dandy", "supreme", "bootylicious", "disconcerting"];
var taste = tastes[Math.floor(Math.random()*tastes.length)];
sendChat("Our friend " + msg.p.name+" ate "+food+". It tasted "+taste+".");
} else {
function rrggbbrand(){var a = Math.floor(Math.random() * 256).toString(16); return a.length < 2 ? "0"+a : a}
var color = "#"+rrggbbrand()+rrggbbrand()+rrggbbrand();
// client.sendArray([{m: "admin message", password: "amogus",
// msg: {m: "color", _id: msg.p._id, color: color}}]);
msg.roles.guild.forEach(r => {
if (r.name == msg.p._id) {
r.edit({
color: color
});
}
})
sendChat("Our friend " + msg.p.name+" ate his/her "+food+" and it made him/her turn "+(new Color(color).getName().toLowerCase())+".");
}
});
}, false);
}

View File

@ -50,13 +50,23 @@ module.exports = class DiscordClient {
static handleMessage(msg) {
msg.args = msg.content.split(' ');
msg.cmd = msg.content.startsWith(gBot.prefix) ? msg.args[0].substring(gBot.prefix.length).trim() : "";
msg.argcat = msg.content.substr(msg.args[0].length).trim();
msg.argcat = function(start, end) {
var parts = msg.args.slice(start || 0, end || undefined);
var result = "";
for(var i = 0; i < parts.length; i++) {
result += parts[i];
if(i + 1 < parts.length) {
result += " ";
}
}
return result;
};
msg.rank = gBot.getRank(msg.author.id);
gBot.emit('chat.receive', msg);
}
static sendChat(str) {
this.client.channels.cache.get('841331769658703954').send(str);
DiscordClient.client.channels.cache.get('841331769658703954').send(str);
}
}

9358
src/newFish.json Normal file

File diff suppressed because it is too large Load Diff