This commit is contained in:
Hri7566 2022-01-18 17:03:59 -05:00
parent 441a24efcf
commit 488bc83ad1
17 changed files with 144 additions and 95 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bot2022.db/000171.ldb Normal file

Binary file not shown.

BIN
bot2022.db/000173.ldb Normal file

Binary file not shown.

BIN
bot2022.db/000178.ldb Normal file

Binary file not shown.

BIN
bot2022.db/000179.log Normal file

Binary file not shown.

View File

@ -1 +1 @@
MANIFEST-000118
MANIFEST-000177

View File

@ -1,5 +1,5 @@
2022/01/18-01:51:07.050 707c Recovering log #117
2022/01/18-01:51:07.050 707c Level-0 table #119: started
2022/01/18-01:51:07.052 707c Level-0 table #119: 1851 bytes OK
2022/01/18-01:51:07.057 707c Delete type=0 #117
2022/01/18-01:51:07.058 707c Delete type=3 #115
2022/01/18-16:59:11.704 2d64 Recovering log #176
2022/01/18-16:59:11.704 2d64 Level-0 table #178: started
2022/01/18-16:59:11.707 2d64 Level-0 table #178: 446 bytes OK
2022/01/18-16:59:11.713 2d64 Delete type=0 #176
2022/01/18-16:59:11.713 2d64 Delete type=3 #175

View File

@ -1,5 +1,3 @@
2022/01/18-01:47:10.058 5334 Recovering log #113
2022/01/18-01:47:10.058 5334 Level-0 table #116: started
2022/01/18-01:47:10.059 5334 Level-0 table #116: 1573 bytes OK
2022/01/18-01:47:10.064 5334 Delete type=0 #113
2022/01/18-01:47:10.064 5334 Delete type=3 #111
2022/01/18-16:58:50.679 59bc Recovering log #174
2022/01/18-16:58:50.683 59bc Delete type=0 #174
2022/01/18-16:58:50.683 59bc Delete type=3 #172

Binary file not shown.

BIN
bot2022.db/MANIFEST-000177 Normal file

Binary file not shown.

View File

@ -210,5 +210,7 @@ process.stdin.on('data', data => {
});
process.on('SIGINT', async () => {
await db.close();
if (!db.isClosed()) {
await db.close();
}
});

View File

@ -12,7 +12,8 @@ module.exports = class Bot extends StaticEventEmitter {
this.admin = [
"2ffc3744fbc1bc6c6ef4a330",
"a41651bf8a46bafc5548dad6",
"ead940199c7d9717e5149919"
"ead940199c7d9717e5149919",
"8107156a27514cebcb65195d"
];
this.prefix = "/"; // never change this
@ -55,9 +56,9 @@ module.exports = class Bot extends StaticEventEmitter {
}
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];
for(var id in MPPClient.client.ppl) {
if(MPPClient.client.ppl.hasOwnProperty(id) && MPPClient.client.ppl[id].name === name) {
return MPPClient.client.ppl[id];
}
}
return undefined;
@ -67,12 +68,12 @@ module.exports = class Bot extends StaticEventEmitter {
if(!name || name.trim() == "") return undefined;
var part = findParticipantByName(name);
if(!part) {
name_lc = name.toLowerCase();
MPPClient.client.ppl.forEach(p => {
var name_lc = name.toLowerCase();
for (let p of Object.values(MPPClient.client.ppl)) {
if(p.name.toLowerCase() === name_lc) {
part = p;
}
});
}
}
return part;
};
@ -82,75 +83,96 @@ module.exports = class Bot extends StaticEventEmitter {
name = name.toLowerCase();
var part = findParticipantByNameCaseInsensitive(name);
for(var id in MPPClient.client.ppl) {
if(client.ppl.hasOwnProperty(id) && client.ppl[id].name.toLowerCase().indexOf(name) === 0) {
part = client.ppl[id];
break;
}
}
for(var id in MPPClient.client.ppl) {
if(client.ppl.hasOwnProperty(id) && client.ppl[id].name.toLowerCase().indexOf(name) !== -1) {
if(MPPClient.client.ppl.hasOwnProperty(id) && MPPClient.client.ppl[id].name.toLowerCase().indexOf(name) === 0) {
part = MPPClient.client.ppl[id];
break;
}
}
for(var id in MPPClient.client.ppl) {
if(MPPClient.client.ppl.hasOwnProperty(id) && MPPClient.client.ppl[id].name.toLowerCase().indexOf(name) !== -1) {
part = MPPClient.client.ppl[id];
break;
}
}
// new
if (!part) {
// for (var id in MPPClient.client.ppl) {
// let p = MPPClient.client.ppl[id];
// if (!p) continue;
// if (p._id.toLowerCase().includes(name.toLowerCase())) {
// part = p;
// break;
// }
// }
for (var p of Object.values(MPPClient.client.ppl)) {
if (!p) continue;
if (p._id.toLowerCase().includes(name.toLowerCase())) {
part = p;
break;
}
}
}
return part;
};
var TOO_MANY_FISH = 50;
if (msg.cmd.startsWith("give_")) {
// var amt = parseInt(msg.cmd.substr(5));
// console.log(msg.cmd.substr(5));
// if(amt > 0) {
// console.log('test');
// if(amt > 100 && msg.p.id !== client.participantId) {
// sendChat("Friend "+msg.p.name+": you can only give up to 100 at a time.");
// } else {
// var thief = msg.p;
// var victim = findParticipantByNameFuzzy(msg.args[0]);
// if(!victim) {
// sendChat("Friend " +thief.name+" missed");
// return;
// }
// if(victim._id == thief._id) {
// sendChat("Friendly friend " +thief.name+" fudged");
// return;
// }
// var target_fish = msg.argcat(1);
// db.getFish(thief._id, function(thief_fish) {
// db.getFish(victim._id, function(victim_fish) {
// if(victim_fish.length >= TOO_MANY_FISH) {
// sendChat("Friend " +victim.name+" is carrying too much.");
// return;
// }
// if(thief_fish.length > 0) {
// var arg = target_fish.trim().toLowerCase();
// var thefish = "items";
// for(var j = 0; j < amt; j++) {
// var idx = -1;
// for(var i = 0; i < thief_fish.length; i++) {
// if(arg == "" || thief_fish[i].toLowerCase().indexOf(arg) !== -1) {
// idx = i;
// break;
// }
// }
// if(idx == -1) {
// sendChat("Friend " +thief.name+": You don't have "+amt+" "+arg+".");
// return;
// }
// thefish = thief_fish[idx];
// thief_fish.splice(idx, 1);
// victim_fish.push(thefish);
// }
// sendChat("Our friend " +thief.name+" gave "+victim.name+" his/her e.g. ("+thefish+") x "+amt+".");
// db.putFish(thief._id, thief_fish);
// db.putFish(victim._id, victim_fish);
// } else {
// sendChat("Friend " +thief.name+": You don't have the fish to give.");
// }
// });
// });
// return;
// }
// }
return sendChat("You may not /give_, it misses every time.");
var amt = parseInt(msg.cmd.substr(5));
console.log(msg.cmd.substr(5));
if(amt > 0) {
console.log('test');
if(amt > 100 && msg.p.id !== client.participantId) {
sendChat("Friend "+msg.p.name+": you can only give up to 100 at a time.");
} else {
var thief = msg.p;
var victim = findParticipantByNameFuzzy(msg.args[0]);
if(!victim) {
sendChat("Friend " +thief.name+" missed");
return;
}
if(victim._id == thief._id) {
sendChat("Friendly friend " +thief.name+" fudged");
return;
}
var target_fish = msg.argcat(1);
db.getFish(thief._id, function(thief_fish) {
db.getFish(victim._id, function(victim_fish) {
if(victim_fish.length >= TOO_MANY_FISH) {
sendChat("Friend " +victim.name+" is carrying too much.");
return;
}
if(thief_fish.length > 0) {
var arg = target_fish.trim().toLowerCase();
var thefish = "items";
for(var j = 0; j < amt; j++) {
var idx = -1;
for(var i = 0; i < thief_fish.length; i++) {
if(arg == "" || thief_fish[i].toLowerCase().indexOf(arg) !== -1) {
idx = i;
break;
}
}
if(idx == -1) {
sendChat("Friend " +thief.name+": You don't have "+amt+" "+arg+".");
return;
}
thefish = thief_fish[idx];
thief_fish.splice(idx, 1);
victim_fish.push(thefish);
}
sendChat("Our friend " +thief.name+" gave "+victim.name+" his/her e.g. ("+thefish+") x "+amt+".");
db.putFish(thief._id, thief_fish);
db.putFish(victim._id, victim_fish);
} else {
sendChat("Friend " +thief.name+": You don't have the fish to give.");
}
});
});
return;
}
}
// return sendChat("You may not /give_, it misses every time.");
}
if (msg.cmd.startsWith("bestow_")) {
// var amt = parseInt(msg.cmd.substr(8));

View File

@ -199,14 +199,14 @@ module.exports = (bot) => {
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");
if(!silent) sendChat("Our good friend " +part.name+" caught "+aOrAn(size)+" "+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 + "!";
var text = part.name+" caught "+aOrAn(size)+" "+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)}}]);
@ -233,7 +233,7 @@ module.exports = (bot) => {
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 + ".");
if(!silent) sendChat(exclamation+" "+part.name+" caught "+aOrAn(type)+" "+type + ".");
entry = type;
}
@ -269,7 +269,7 @@ module.exports = (bot) => {
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+"...!");
sendChat("Unfortunate catch! It's "+aOrAn(type)+" "+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...");
@ -298,7 +298,7 @@ module.exports = (bot) => {
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(part.name + " received " + aOrAn(pok.name.toUpperCase()) + " " + pok.name.toUpperCase()+" for joining! By my count, "+part.name+" now has "+count+" individual pokemón.");
//sendChat("/hug " + part.name.toLowerCase());
});
@ -425,13 +425,21 @@ module.exports = (bot) => {
}
}
function aOrAn(word) {
if(/^[aeiou]/i.test(word)) {
return "an";
} else {
return "a";
}
}
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)");
// 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)");
sendChat(underline("Fishing")+": /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)");
sendChat(underline("Fishing")+": /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) => {
@ -842,7 +850,7 @@ module.exports = (bot) => {
}
}
if(idx == -1) {
sendChat("Friend " +msg.p.name+": You don't have a "+arg+" that's edible.");
sendChat("Friend " +msg.p.name+": You don't have "+aOrAn(arg)+""+arg+" that's edible.");
return;
}
var food = myfish[idx];
@ -1049,7 +1057,7 @@ module.exports = (bot) => {
if(Math.random() < 0.15) {
// hit the tree
var yeet = rando([
ye("The "+size+" "+fish+" thwapped into the kekklefruit tree sending debris flying. A kekklefruit was knocked to the ground.", "It's lying there next to the tree.", "It got splattered on the tree.", "Part of it is stuck to the tree, but it came to rest on the ground nearby.", "A distressed-looking "+fish+" on the ground near the tree.", "It landed in the grass.", "It's kinda scuffed up.", "It's got tree on it. And "+name+"prints.", "It's "+size+".", "It belongs to the tree now.", "It's by the tree now.", "It's a "+size+" "+fish+" previously owned by "+name+" if you still want it after that.")
ye("The "+size+" "+fish+" thwapped into the kekklefruit tree sending debris flying. A kekklefruit was knocked to the ground.", "It's lying there next to the tree.", "It got splattered on the tree.", "Part of it is stuck to the tree, but it came to rest on the ground nearby.", "A distressed-looking "+fish+" on the ground near the tree.", "It landed in the grass.", "It's kinda scuffed up.", "It's got tree on it. And "+name+"prints.", "It's "+size+".", "It belongs to the tree now.", "It's by the tree now.", "It's "+aOrAn(size)+" "+size+" "+fish+" previously owned by "+name+" if you still want it after that.")
]);
sendChat(yeet.message);
db.put("look.outside.◍"+fish, yeet.result);
@ -1065,7 +1073,7 @@ module.exports = (bot) => {
// yeet to rest
var yeet = rando([
// into the water
ye("Tossed "+fish+" into the water.", "It looks like somebody tossed it haphazardly into the shallow water. It is not swimming.", "It's in the shallows trying to swim away...", name+" tossed this into the shallows where it rests today. I don't think it's moving.", "I think it's a "+fish+". A very immobile one.", " It's resting at the edge of the water where you can /take it."),
ye("Tossed "+fish+" into the water.", "It looks like somebody tossed it haphazardly into the shallow water. It is not swimming.", "It's in the shallows trying to swim away...", name+" tossed this into the shallows where it rests today. I don't think it's moving.", "I think it's "+aOrAn("fish")+" "+fish+". A very immobile one.", " It's resting at the edge of the water where you can /take it."),
// on the ground
ye("Tossed "+fish+" onto the ground.", "It just sat there.", "It landed face down.", "Yeeted into this position by "+name+".", "A dirty "+fish+".", "Motionless on the ground.", "It's still moving!", "It possesses frozen on its face the expression of something yeeted", "It's missing a piece.", "It's still warm.", "Using your powers you deduce that it's been there since exactly "+time+" on an unknown day.")
@ -1171,7 +1179,7 @@ module.exports = (bot) => {
}
}
if(idx == -1) {
sendChat("Friend " +thief.name+": You don't have a "+arg+" that you can /give like that.");
sendChat("Friend " +thief.name+": You don't have "+aOrAn(arg)+" "+arg+" that you can /give like that.");
return;
}
var thefish = thief_fish[idx];
@ -1631,7 +1639,7 @@ module.exports = (bot) => {
var part = findParticipantByNameFuzzy(msg.argcat());
if (part) {
let hug = rando("a squeeze", "an affectionate hug",
"a deep, passionate hug", `a "normal" hug`, "a snug hug", "a new hug", "a special embrace", "caring hug");
"a deep, passionate hug", `a "normal" hug`, "a snug hug", "a new hug", "a special embrace", "a caring hug");
sendChat(`Our friend ` + msg.p.name + ` gave ` + part.name + ' ' + hug);
} else {
db.getLocation(msg.p._id, location => {
@ -1648,7 +1656,7 @@ module.exports = (bot) => {
var part = findParticipantByNameFuzzy(msg.argcat());
if (part) {
let kiss = rando("a kiss", "a sloppy smooch",
"a deep, passionate french kiss", `a big grandma kiss on the cheek`, "a big smooch on the cheek", "a new kiss", "a lasting mark on their face", "caring kiss");
"a deep, passionate french kiss", `a big grandma kiss on the cheek`, "a big smooch on the cheek", "a new kiss", "a lasting mark on their face", "a caring kiss");
sendChat(`Our friend ` + msg.p.name + ` gave ` + part.name + ' ' + kiss);
} else {
db.getLocation(msg.p._id, location => {
@ -1665,7 +1673,7 @@ module.exports = (bot) => {
var part = findParticipantByNameFuzzy(msg.argcat());
if (part) {
let bonk = rando("a bonk", "a slap",
"a deep, passionate bonk", `a "normal" bonk`, "a bonk on the cheek", "a new bonk", "a lasting mark on their face", "caring bonk");
"a deep, passionate bonk", `a "normal" bonk`, "a bonk on the cheek", "a new bonk", "a lasting mark on their face", "a caring bonk");
sendChat(`Our friend ` + msg.p.name + ` gave ` + part.name + ' ' + bonk);
} else {
db.getLocation(msg.p._id, location => {
@ -1733,4 +1741,23 @@ module.exports = (bot) => {
}
}])
});
bot.addCommand(['breatheonnose'], 0, msg => {
let part = findParticipantByNameFuzzy(msg.argcat());
if (part) {
sendChat(`Our friend ` + msg.p.name + ` breathed on ` + part.name + '\'s nose.');
} else {
sendChat(`Friend ` + msg.p.name + `, there's no nose here by that name.`);
}
});
bot.addCommand(['where'], 0, msg => {
db.getLocation(msg.p._id, location => {
var message = "Friend " + msg.p.name + " is in " + location;
if (location == 'outside' && Math.random() < 0.25) {
message += " and the fish are happy.";
}
sendChat(message);
});
});
}

View File

@ -53,7 +53,7 @@ module.exports = class MPPClient {
if (this.checkDayJoin) {
day = this.checkDayJoin(p);
}
if (this.catchPokemon && day) this.catchPokemon(p, true);
if (this.catchPokemon && day) this.catchPokemon(p);
});
}