From 3177408a994146d460c56edf4f2b69f3b81cd216 Mon Sep 17 00:00:00 2001 From: zhiyu1998 Date: Sun, 19 Feb 2023 17:32:32 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf:=20=E7=AE=80=E5=8C=96?= =?UTF-8?q?=E8=85=BF=E5=BF=92=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 简化配置 2. 更新README --- README.md | 4 ++-- apps/tools.js | 4 +++- config/tools.yaml | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c5149d4..0c475b4 100644 --- a/README.md +++ b/README.md @@ -121,10 +121,10 @@ async tuiimg (e) { ### 其他进阶操作 【可选】相关配置(apps/tools.js): > twiiter-api:https://developer.twitter.com/en -注册完之后将`Bearer Token`填入app/tools.js twitter方法的TwitterApi后面的单引号里`const twitterClient = new TwitterApi('', {httpAgent});` +注册完之后将`Bearer Token`填入config/tools.yaml` > 百度翻译api:https://fanyi-api.baidu.com/doc/21 -注册完填入方式参考上方注释url (app/tools.js);另外,有群友反馈百度翻译需要充钱才能使用! +注册完填入方式参考上方注释url (config/tools.yaml);另外,有群友反馈百度翻译需要充钱才能使用! > 更改proxy地址在config/tools.yaml: `proxyAddr: '127.0.0.1' # 魔法地址` diff --git a/apps/tools.js b/apps/tools.js index 2784217..9985906 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -90,6 +90,8 @@ export class tools extends plugin { // 加载百度翻译配置 this.translateAppId = this.toolsConfig.translateAppId; this.translateSecret = this.toolsConfig.translateSecret; + // 加载twitter配置 + this.bearerToken = this.toolsConfig.bearerToken; } // 翻译插件 @@ -354,7 +356,7 @@ export class tools extends plugin { const twitterUrl = reg.exec(e.msg); const id = twitterUrl[1]; const httpAgent = new HttpProxyAgent(this.myProxy); - const twitterClient = new TwitterApi("", { httpAgent }); + const twitterClient = new TwitterApi(this.bearerToken, { httpAgent }); // Tell typescript it's a readonly app const readOnlyClient = twitterClient.readOnly; diff --git a/config/tools.yaml b/config/tools.yaml index 387d4ae..b0fb93e 100644 --- a/config/tools.yaml +++ b/config/tools.yaml @@ -3,4 +3,6 @@ proxyAddr: '127.0.0.1' # 魔法地址 proxyPort: '7890' # 魔法端口 translateAppId: '' # 百度翻译APP ID -translateSecret: '' # 百度翻译密匙 \ No newline at end of file +translateSecret: '' # 百度翻译密匙 + +bearerToken: '' # 推特Bearer Token \ No newline at end of file