diff --git a/bot2019.db/000168.ldb b/bot2019.db/000168.ldb deleted file mode 100644 index 63a10c1..0000000 Binary files a/bot2019.db/000168.ldb and /dev/null differ diff --git a/bot2019.db/000170.ldb b/bot2019.db/000170.ldb deleted file mode 100644 index 84b9f29..0000000 Binary files a/bot2019.db/000170.ldb and /dev/null differ diff --git a/bot2019.db/000173.ldb b/bot2019.db/000173.ldb deleted file mode 100644 index 360a41d..0000000 Binary files a/bot2019.db/000173.ldb and /dev/null differ diff --git a/bot2019.db/000174.log b/bot2019.db/000174.log deleted file mode 100644 index 520c6f7..0000000 Binary files a/bot2019.db/000174.log and /dev/null differ diff --git a/bot2019.db/000194.ldb b/bot2019.db/000194.ldb new file mode 100644 index 0000000..bf2e295 Binary files /dev/null and b/bot2019.db/000194.ldb differ diff --git a/bot2019.db/000198.ldb b/bot2019.db/000198.ldb new file mode 100644 index 0000000..fc9805d Binary files /dev/null and b/bot2019.db/000198.ldb differ diff --git a/bot2019.db/000205.ldb b/bot2019.db/000205.ldb new file mode 100644 index 0000000..91f1162 Binary files /dev/null and b/bot2019.db/000205.ldb differ diff --git a/bot2019.db/000206.log b/bot2019.db/000206.log new file mode 100644 index 0000000..92d3d1b Binary files /dev/null and b/bot2019.db/000206.log differ diff --git a/bot2019.db/CURRENT b/bot2019.db/CURRENT index 647a5d6..e75c8d4 100644 --- a/bot2019.db/CURRENT +++ b/bot2019.db/CURRENT @@ -1 +1 @@ -MANIFEST-000172 +MANIFEST-000204 diff --git a/bot2019.db/LOG b/bot2019.db/LOG index 9c7d870..bab1261 100644 --- a/bot2019.db/LOG +++ b/bot2019.db/LOG @@ -1,5 +1,5 @@ -2021/08/06-00:21:15.178 7108 Recovering log #171 -2021/08/06-00:21:15.179 7108 Level-0 table #173: started -2021/08/06-00:21:15.194 7108 Level-0 table #173: 1044 bytes OK -2021/08/06-00:21:15.213 7108 Delete type=0 #171 -2021/08/06-00:21:15.216 7108 Delete type=3 #169 +2021/08/06-00:35:25.097 6b0c Recovering log #203 +2021/08/06-00:35:25.097 6b0c Level-0 table #205: started +2021/08/06-00:35:25.105 6b0c Level-0 table #205: 316 bytes OK +2021/08/06-00:35:25.121 6b0c Delete type=0 #203 +2021/08/06-00:35:25.124 6b0c Delete type=3 #202 diff --git a/bot2019.db/LOG.old b/bot2019.db/LOG.old index ce8db5a..0ea2d79 100644 --- a/bot2019.db/LOG.old +++ b/bot2019.db/LOG.old @@ -1,5 +1,3 @@ -2021/08/06-00:12:04.964 2320 Recovering log #167 -2021/08/06-00:12:04.964 2320 Level-0 table #170: started -2021/08/06-00:12:04.970 2320 Level-0 table #170: 213 bytes OK -2021/08/06-00:12:04.985 2320 Delete type=0 #167 -2021/08/06-00:12:04.989 2320 Delete type=3 #165 +2021/08/06-00:34:35.908 5ec4 Recovering log #201 +2021/08/06-00:34:35.923 5ec4 Delete type=0 #201 +2021/08/06-00:34:35.925 5ec4 Delete type=3 #200 diff --git a/bot2019.db/MANIFEST-000172 b/bot2019.db/MANIFEST-000172 deleted file mode 100644 index fc358eb..0000000 Binary files a/bot2019.db/MANIFEST-000172 and /dev/null differ diff --git a/bot2019.db/MANIFEST-000204 b/bot2019.db/MANIFEST-000204 new file mode 100644 index 0000000..90e2155 Binary files /dev/null and b/bot2019.db/MANIFEST-000204 differ diff --git a/src/Bot.js b/src/Bot.js index fc8135e..b1423ec 100644 --- a/src/Bot.js +++ b/src/Bot.js @@ -1,3 +1,4 @@ +const { sendChat } = require('./DiscordClient'); const DiscordClient = require('./DiscordClient'); const StaticEventEmitter = require('./StaticEventEmitter'); @@ -42,12 +43,172 @@ module.exports = class Bot extends StaticEventEmitter { msg.p = { name: msg.author.username, _id: msg.author.id, - color: role.color + color: role.color, + id: msg.author.id } msg.a = msg.content; if(msg.a[0] == "∕" && msg.p.id !== client.participantId) { msg.a[0] = "/"; } + 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(); + DiscordClient.client.guilds.cache.get('841331769051578413').members.cache.forEach(p => { + if (p.user.username.toLowerCase() === name_lc) { + part = p.user; + part.name = p.user.name; + part._id = p.user.id; + DiscordClient.client.guilds.cache.get('841331769051578413').roles.cache.forEach(r => { + if (r.name === part._id) { + part.color = r.color; + } + }); + } + }); + } + 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; + }; + 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."); + } + if (msg.cmd.startsWith("bestow_")) { + // var amt = parseInt(msg.cmd.substr(8)); + // if(amt > 0) { + // if(amt > 100 && msg.p.id !== client.participantId) { + // sendChat("Friend "+msg.p.name+": you can only bestow up to 100 at a time."); + // } else { + // var thief = msg.p; + // var victim = client.ppl[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+" bestowed "+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 bestow."); + // } + // }); + // }); + // return; + // } + // } + return sendChat("You may not /bestow_, it misses every time."); + } this.commands.forEach(cmd => { let usedCommand = false; cmd.cmd.forEach(c => { diff --git a/src/Commands.js b/src/Commands.js index 5e7e0b4..382500a 100644 --- a/src/Commands.js +++ b/src/Commands.js @@ -366,7 +366,8 @@ module.exports = (bot) => { if (Date.now() < blockHelpUntil) return; blockHelpUntil = Date.now() + 10000; //sendChat("This is a test to see what leveldb is like. Commands: /put , /get , /del , /read [ []] \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")+": \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) => {