diff --git a/lib/bot.js b/lib/bot.js index 3aec1bb6..d6169fbd 100644 --- a/lib/bot.js +++ b/lib/bot.js @@ -41,13 +41,20 @@ export default class Yunzai extends EventEmitter { this.adapter = [] this.express = express() + this.express.quiet = [] for (const i of ["urlencoded", "json", "raw", "text"]) this.express.use(express[i]({ extended: false })) this.express.use(req => { + req.next() + let quiet = false + for (const i of req.app.quiet) + if (req.originalUrl.startsWith(i)) { + quiet = true + break + } req.rid = `${req.ip}:${req.socket.remotePort}` req.sid = `${req.protocol}://${req.hostname}:${req.socket.localPort}${req.originalUrl}` - this.makeLog("mark", ["HTTP", req.method, "请求", req.headers, req.query, req.body], `${req.sid} <= ${req.rid}`) - req.next() + this.makeLog(quiet ? "debug" : "mark", ["HTTP", req.method, "请求", req.headers, req.query, req.body], `${req.sid} <= ${req.rid}`) }) this.express.use("/exit", req => { if (["::1", "::ffff:127.0.0.1"].includes(req.ip) || req.hostname == "localhost") @@ -519,8 +526,7 @@ export default class Yunzai extends EventEmitter { getFriendList() { const array = [] for (const bot_id of this.uin) - for (const [id, i] of this.bots[bot_id].fl || []) - array.push(id) + array.push(...(this.bots[bot_id].fl?.keys() || [])) return array } @@ -544,8 +550,7 @@ export default class Yunzai extends EventEmitter { getGroupList() { const array = [] for (const bot_id of this.uin) - for (const [id, i] of this.bots[bot_id].gl || []) - array.push(id) + array.push(...(this.bots[bot_id].gl?.keys() || [])) return array }