Commit 67f09097 authored by nanahira's avatar nanahira

update logger

parent 33efe1d6
...@@ -17,3 +17,7 @@ plugins: ...@@ -17,3 +17,7 @@ plugins:
adapter-wechaty: adapter-wechaty:
name: 'koishi' # Wechaty 配置文件保存路径。 name: 'koishi' # Wechaty 配置文件保存路径。
``` ```
## 使用方法
启动插件,并在 Koishi 控制台的『日志』或是 stdout 中查看二维码,扫描登录。
\ No newline at end of file
...@@ -3,12 +3,17 @@ import TargetPlugin from '../src'; ...@@ -3,12 +3,17 @@ import TargetPlugin from '../src';
import * as Help from '@koishijs/plugin-help'; import * as Help from '@koishijs/plugin-help';
import ExtrasInDev from './extras'; import ExtrasInDev from './extras';
import fs from 'fs'; import fs from 'fs';
import Console from '@koishijs/plugin-console';
import LogProvider from '@koishijs/plugin-logger';
const app = new App({ const app = new App({
prefix: '.', prefix: '.',
port: 14514,
}); });
app.plugin(Help); app.plugin(Help);
app.plugin(Console);
app.plugin(LogProvider);
// Some extras // Some extras
app.plugin(ExtrasInDev); app.plugin(ExtrasInDev);
......
This diff is collapsed.
...@@ -57,7 +57,9 @@ ...@@ -57,7 +57,9 @@
"koishi": "^4.11.1" "koishi": "^4.11.1"
}, },
"devDependencies": { "devDependencies": {
"@koishijs/plugin-console": "^5.4.0",
"@koishijs/plugin-help": "^2.0.2", "@koishijs/plugin-help": "^2.0.2",
"@koishijs/plugin-logger": "^2.2.3",
"@types/jest": "^29.2.4", "@types/jest": "^29.2.4",
"@types/node": "^18.11.17", "@types/node": "^18.11.17",
"@types/qrcode-terminal": "^0.12.0", "@types/qrcode-terminal": "^0.12.0",
......
...@@ -76,8 +76,13 @@ export default class WechatyBot extends Bot< ...@@ -76,8 +76,13 @@ export default class WechatyBot extends Bot<
this.offline(error); this.offline(error);
}); });
this.internal.on('scan', (qrcode, status) => { this.internal.on('scan', (qrcode, status) => {
this.logger.info(`Scan (${status}):`); qrcodeTerminal.generate(qrcode, { small: false }, (img) =>
qrcodeTerminal.generate(qrcode); this.logger.info(
`Scan (${status}): https://wechaty.js.org/qrcode/${encodeURIComponent(
qrcode,
)}\n` + img,
),
);
}); });
await this.internal.start(); await this.internal.start();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment