From 586e2bde990030cdad73ebf983a708024b82464d Mon Sep 17 00:00:00 2001 From: Hri7566 Date: Fri, 6 Aug 2021 00:36:15 -0400 Subject: [PATCH] rc-1 --- bot2019.db/000168.ldb | Bin 661 -> 0 bytes bot2019.db/000170.ldb | Bin 213 -> 0 bytes bot2019.db/000173.ldb | Bin 1044 -> 0 bytes bot2019.db/000174.log | Bin 4951 -> 0 bytes bot2019.db/000194.ldb | Bin 0 -> 754 bytes bot2019.db/000198.ldb | Bin 0 -> 231 bytes bot2019.db/000205.ldb | Bin 0 -> 316 bytes bot2019.db/000206.log | Bin 0 -> 1133 bytes bot2019.db/CURRENT | 2 +- bot2019.db/LOG | 10 +-- bot2019.db/LOG.old | 8 +- bot2019.db/MANIFEST-000172 | Bin 316 -> 0 bytes bot2019.db/MANIFEST-000204 | Bin 0 -> 285 bytes src/Bot.js | 163 ++++++++++++++++++++++++++++++++++++- src/Commands.js | 3 +- 15 files changed, 173 insertions(+), 13 deletions(-) delete mode 100644 bot2019.db/000168.ldb delete mode 100644 bot2019.db/000170.ldb delete mode 100644 bot2019.db/000173.ldb delete mode 100644 bot2019.db/000174.log create mode 100644 bot2019.db/000194.ldb create mode 100644 bot2019.db/000198.ldb create mode 100644 bot2019.db/000205.ldb create mode 100644 bot2019.db/000206.log delete mode 100644 bot2019.db/MANIFEST-000172 create mode 100644 bot2019.db/MANIFEST-000204 diff --git a/bot2019.db/000168.ldb b/bot2019.db/000168.ldb deleted file mode 100644 index 63a10c19fce811054928bad5ad6c389c161724af..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 661 zcmaKp&ubGw9K~mnrY32ER#G&<$izlm4=$6<{zwA#kd_pwNFjwPL~)XxG@G65)Y;tz zJ=9+GBE^G(-ULBU{sR`F)ttNtf;SI>XAgqnr4-$bKaM__!}q<<{9xYm*w?$Dc(`l1 zJ>-&(y{V|WQLQRv%`h}W(KNjZFZ4kuK}}>++h(*Ye9KGbo<_N;fA1YZ%8~U&?0Z&M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c<`Fls{ uSe1D%hqQ(?xkkj5-+zNPWF}^6JyZMI*E+qIonz4c|5z}bUR{=|fA$At&ks-l diff --git a/bot2019.db/000174.log b/bot2019.db/000174.log deleted file mode 100644 index 520c6f7fb62a2cfa256205e8b09841dffe1afabe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4951 zcmeI0Pe>F|9LMLmW&boPf=D)chobe+qPy$t8l76HKm}`yvch;ePiLB$9i826v0yQh z4pE485D_XmECg9#|0oYz*&hlDI&`U%9jp#zshO7j`B_MB9GO_AKbM)q!tDFa=e>EK z?+ouvd)xge=Fr<4h?_hnf6*eD%CbW1^@J41ah+0Bni_YtZAEC1EpyjPF%ic|ot*L) z2SR+vAN27dKFIS$p`vt7HB}TXiL0nyCt{CI;v&_tLi7e&*q7Nrbe#&gJSx@GeI$uJ zF_kC^G&Ja>kz!^5eVGWfM?|8_*rQTGN~mjN(g7+!@wP;iV9yk@LL)Qu6oxBJ-EYzq z;m7EwkE=?Osi``wljP6psjkXMt!Xgjnq>Mf4EL-z;|NhyE&6Mu%8JO=HRGJ)mifoqw~YlA3V( z?h%B>*)mH_&m2vEQj@`1+0mBM;OrAC!|W_D)Y;p45~0s*nWeLrj2BB|knPrSdoEZI^7#T9viqpej zlk2tIocNyPrEpGP;=t2d&eF@YN}4E9Hwj~2eAyv2>a`f4 zH#ggPkI7evW1xgdHN9bu)%8nM^JImFMNoo;3!zgsDP^l5lJRtC@+t_;*i7?pPews# zUN>lZ0E99QX$F%0?cQm!lwJe9Ia^Qf1vul)<6J~}!c5zWKHxuspJ7l9gZN2en$)RK zqH$B>H(+@M3>Ju1vl&GL-y#`rDQmQwdkFHwPa-Hy>UH&5B;Tae4UF)QU@;imBT6Ec zF^4%0i=rU$7{lWEsiSc)M{NrgsOv~ui@{i*B8lFWRV+x7#4Eg_O0Z@@h{5!53$VlA zQ^Ed;hNaQ6Zcz=2MK}b2`hmX&BHjg=J^l)2UjXJC3hUN#OGt5?A}d%D6zrAdRT;i~ z>c4V~llc_y`2r`)JU9R+GK0uJSHx4wOytWG^}cGlbm kfi4sN`U~*J_m8{$WA4PZ58wCi?}Yx3g`L$~@y5*i-3ggq=j0`{!o~n?NpQm1;P?DIFt&o@m zRHjgpkyxT9$}ah2cbPJS3`iA7DWiN@K!yVcg8~bK023QXloN=#8C*ZA+A=6HrDf)n zq!#Jrq?V=Tq$KG%l>+&hc}_sPbKSsFMu9>gO<-HoeAgal;AF~W{0{*PK5(gNSAJDy V=+9vk1Bnm-;lCTYRZ87&0{~EzI-CFi literal 0 HcmV?d00001 diff --git a/bot2019.db/000205.ldb b/bot2019.db/000205.ldb new file mode 100644 index 0000000000000000000000000000000000000000..91f11620581100493d852249a76bd2fc175ee917 GIT binary patch literal 316 zcmX@h^1+5dMlvTqKU*)qw4^vQB~|ay^xojaycEW-yBQgPAUsteB|lHSM4==xCtD#g z38+k=BqOmzPn2Eq%kCy+28PdVZVU{c+JLN&AmRgvcn>1pfrz&t;thy+4I*BFh?gMZ z1&DYKBA!(#GsuAK0$Iqo<%wA#3xfcI0|$cwNDv5^Km;3z5CvjxhPfffUN9&zr)B1p zq!#Jrq?V=Tq$KG%l>+&hc}_sz8UN7H+Q6Z29e!&4Pf^7GV76iO0v zvK11Ofbt3@8Hpu&p*yC!0gd=hfe~DPo+ks1_(6dYvQNWwfJXeJz=$oIx<3Jp_(g#c z&Ek%`fkynMzzF_D4>tgf_(Opa67JbAfkynLz=(}L+Z=&L{G-5#wo;BNpb`HmFe3R@ zq$kh_hCSq`&MWU9O#m9fNP!WyDt5PkMlexe#H&3M6oE!CQ(#1=>C_rC21XWSBc#$Y zi!(Cw((8;3O)ShTjLnVAEX>T!%nU3Hcn!^rER2jyOwG&<%`GqX-a8DmpA}g%iP_wu Ni+MKC2sR3g004!(Uoijx literal 0 HcmV?d00001 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 fc358eb29f3df2ea8ea0e78a54f6fa7ec2c6eab0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 316 zcmcb6aKp)442+CYIjLo-IVnkcPL(C8<(b8)&iT0oiA9Me`9-V@>N)xO*?ReO3 zsd|s5_ZFq5C}gK*XXm7*6_sX|Fet<_fB-wgD#ojfN@==H{m6My94_mW-ZR zAj24B(47~Yn3uvhA7a(@>$NLF7#Nw>F>*36uV-X=`<0EIVJ+hn4kV+oIP?faH+G{J GLL>pwB3=go diff --git a/bot2019.db/MANIFEST-000204 b/bot2019.db/MANIFEST-000204 new file mode 100644 index 0000000000000000000000000000000000000000..90e2155cc4b8219e6ea6fe0bdd21df9c5837985b GIT binary patch literal 285 zcmWGqqi1%Qfss)vC$%g!CnZVGsj?)sJhM2}IX|}`u_&=5zlfDVCMQ2XTQ9$~q&PDr zRqxUC-r&T%6vivN85w|po#7bcb4Kh+oabj|Ioso%| zxuvC%v8lPaskxDsU8Vp4 literal 0 HcmV?d00001 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) => {