diff --git a/bot2022.db/000822.ldb b/bot2022.db/000822.ldb deleted file mode 100644 index 9886394..0000000 Binary files a/bot2022.db/000822.ldb and /dev/null differ diff --git a/bot2022.db/000824.ldb b/bot2022.db/000824.ldb deleted file mode 100644 index df771b2..0000000 Binary files a/bot2022.db/000824.ldb and /dev/null differ diff --git a/bot2022.db/000825.log b/bot2022.db/000825.log deleted file mode 100644 index 76d17e8..0000000 Binary files a/bot2022.db/000825.log and /dev/null differ diff --git a/bot2022.db/001241.ldb b/bot2022.db/001241.ldb new file mode 100644 index 0000000..b8f5974 Binary files /dev/null and b/bot2022.db/001241.ldb differ diff --git a/bot2022.db/001257.ldb b/bot2022.db/001257.ldb new file mode 100644 index 0000000..5884fd7 Binary files /dev/null and b/bot2022.db/001257.ldb differ diff --git a/bot2022.db/001260.ldb b/bot2022.db/001260.ldb new file mode 100644 index 0000000..255db8f Binary files /dev/null and b/bot2022.db/001260.ldb differ diff --git a/bot2022.db/001295.ldb b/bot2022.db/001295.ldb new file mode 100644 index 0000000..2ed7d90 Binary files /dev/null and b/bot2022.db/001295.ldb differ diff --git a/bot2022.db/001296.log b/bot2022.db/001296.log new file mode 100644 index 0000000..fac35f9 Binary files /dev/null and b/bot2022.db/001296.log differ diff --git a/bot2022.db/CURRENT b/bot2022.db/CURRENT index d12ad75..24eb89d 100644 --- a/bot2022.db/CURRENT +++ b/bot2022.db/CURRENT @@ -1 +1 @@ -MANIFEST-000823 +MANIFEST-001294 diff --git a/bot2022.db/LOG b/bot2022.db/LOG index a3e6626..97cc86f 100644 --- a/bot2022.db/LOG +++ b/bot2022.db/LOG @@ -1,5 +1,5 @@ -2022/03/29-19:52:22.815953 7f1a93fff700 Recovering log #821 -2022/03/29-19:52:22.816067 7f1a93fff700 Level-0 table #824: started -2022/03/29-19:52:22.818365 7f1a93fff700 Level-0 table #824: 393 bytes OK -2022/03/29-19:52:22.825576 7f1a93fff700 Delete type=0 #821 -2022/03/29-19:52:22.825631 7f1a93fff700 Delete type=3 #819 +2022/04/06-22:41:18.436029 7f1868e9b700 Recovering log #1293 +2022/04/06-22:41:18.436369 7f1868e9b700 Level-0 table #1295: started +2022/04/06-22:41:18.439139 7f1868e9b700 Level-0 table #1295: 3070 bytes OK +2022/04/06-22:41:18.443935 7f1868e9b700 Delete type=0 #1293 +2022/04/06-22:41:18.443997 7f1868e9b700 Delete type=3 #1292 diff --git a/bot2022.db/LOG.old b/bot2022.db/LOG.old index 7d29580..f4a3567 100644 --- a/bot2022.db/LOG.old +++ b/bot2022.db/LOG.old @@ -1,14 +1,3 @@ -2022/03/29-19:51:38.420325 7fd2c57fa700 Recovering log #818 -2022/03/29-19:51:38.420529 7fd2c57fa700 Level-0 table #820: started -2022/03/29-19:51:38.422466 7fd2c57fa700 Level-0 table #820: 1434 bytes OK -2022/03/29-19:51:38.426305 7fd2c57fa700 Delete type=3 #816 -2022/03/29-19:51:38.426355 7fd2c57fa700 Delete type=0 #818 -2022/03/29-19:51:38.426541 7fd2b77fe700 Compacting 4@0 + 1@1 files -2022/03/29-19:51:38.433674 7fd2b77fe700 Generated table #822@0: 3388 keys, 147397 bytes -2022/03/29-19:51:38.433719 7fd2b77fe700 Compacted 4@0 + 1@1 files => 147397 bytes -2022/03/29-19:51:38.434567 7fd2b77fe700 compacted to: files[ 0 1 0 0 0 0 0 ] -2022/03/29-19:51:38.434660 7fd2b77fe700 Delete type=2 #811 -2022/03/29-19:51:38.434756 7fd2b77fe700 Delete type=2 #817 -2022/03/29-19:51:38.434823 7fd2b77fe700 Delete type=2 #814 -2022/03/29-19:51:38.434867 7fd2b77fe700 Delete type=2 #820 -2022/03/29-19:51:38.434979 7fd2b77fe700 Delete type=2 #809 +2022/04/06-22:39:28.559402 7f28d3691700 Recovering log #1291 +2022/04/06-22:39:28.563017 7f28d3691700 Delete type=3 #1290 +2022/04/06-22:39:28.563068 7f28d3691700 Delete type=0 #1291 diff --git a/bot2022.db/MANIFEST-000823 b/bot2022.db/MANIFEST-000823 deleted file mode 100644 index f928b23..0000000 Binary files a/bot2022.db/MANIFEST-000823 and /dev/null differ diff --git a/bot2022.db/MANIFEST-001294 b/bot2022.db/MANIFEST-001294 new file mode 100644 index 0000000..771321e Binary files /dev/null and b/bot2022.db/MANIFEST-001294 differ diff --git a/src/Commands.js b/src/Commands.js index 1e0a813..da2eb9c 100644 --- a/src/Commands.js +++ b/src/Commands.js @@ -33,12 +33,23 @@ module.exports = (bot) => { if (!err) time = t; }); + var banned = []; + + db.getBanned((val, val2) => { + banned = val; + }); + + setInterval(() => { time += 1; if (time >= 60) { time = 0; } db.setTime(time); + + db.getBanned((val, val2) => { + banned = val; + }); }, 60 * 1000); function underline(text) { @@ -1274,7 +1285,10 @@ module.exports = (bot) => { end: "fishing~\xff" }) .on("data", function(data) { - if(data.value) results.push(data.key); + if(data.value) { + if (banned.includes(data.key.split("~")[1])) return; + results.push(data.key); + } }) .on("end", function() { if(results.length === 0) return; diff --git a/src/Database.js b/src/Database.js index 9809b70..0751eda 100644 --- a/src/Database.js +++ b/src/Database.js @@ -209,4 +209,46 @@ db.setFruits = function(num_fruits) { db.put(key, num_fruits); } +db.getBanned = (cb) => { + let key = "banned users"; + db.get(key, (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.putBanned = (arr, cb) => { + 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 = "banned users"; + if(result.length) + db.put(key, result); + else + db.del(key); +} + +db.appendBanned = (id, cb) => { + db.getBanned((val) => { + val = val.concat(arr); + db.putBanned(arr, cb); + }); +} + module.exports = db;