Skip to content

Commit

Permalink
细节优化
Browse files Browse the repository at this point in the history
  • Loading branch information
TimeRainStarSky committed Mar 28, 2024
1 parent 6a00bf3 commit d886581
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/plugins/stdin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import readline from "node:readline/promises"
import fs from "node:fs/promises"
import path from "node:path"

Expand Down Expand Up @@ -105,9 +106,16 @@ Bot.adapter.push(new class stdinAdapter {
await Bot.mkdir(this.path)
Bot[this.id] = {
adapter: this,
sdk: readline.createInterface({
input: process.stdin,
output: process.stdout,
}).on("line", data => this.message(String(data)))
.on("close", () => process.exit(1)),

uin: this.id,
nickname: this.name,
version: { id: this.id, name: this.name },

pickFriend: () => this.pickFriend(),
get stat() { return Bot.stat },
get pickUser() { return this.pickFriend },
Expand All @@ -125,8 +133,6 @@ Bot.adapter.push(new class stdinAdapter {
}
Bot[this.id].gml.set(this.id, Bot[this.id].fl)

process[this.id].on("data", data => this.message(data.toString()))

logger.mark(`${logger.blue(`[${this.id}]`)} ${this.name}(${this.id}) 已连接`)
Bot.em(`connect.${this.id}`, { self_id: this.id })
}
Expand Down

0 comments on commit d886581

Please sign in to comment.