🎈 perf: 简化腿忒配置

1. 简化配置
2. 更新README
This commit is contained in:
zhiyu1998 2023-02-19 17:32:32 +08:00
parent 9890f7366b
commit 3177408a99
3 changed files with 8 additions and 4 deletions

View File

@ -121,10 +121,10 @@ async tuiimg (e) {
### 其他进阶操作 ### 其他进阶操作
【可选】相关配置(apps/tools.js) 【可选】相关配置(apps/tools.js)
> twiiter-api:https://developer.twitter.com/en > 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 > 百度翻译api:https://fanyi-api.baidu.com/doc/21
注册完填入方式参考上方注释url (app/tools.js);另外,有群友反馈百度翻译需要充钱才能使用! 注册完填入方式参考上方注释url (config/tools.yaml);另外,有群友反馈百度翻译需要充钱才能使用!
> 更改proxy地址在config/tools.yaml > 更改proxy地址在config/tools.yaml
`proxyAddr: '127.0.0.1' # 魔法地址` `proxyAddr: '127.0.0.1' # 魔法地址`

View File

@ -90,6 +90,8 @@ export class tools extends plugin {
// 加载百度翻译配置 // 加载百度翻译配置
this.translateAppId = this.toolsConfig.translateAppId; this.translateAppId = this.toolsConfig.translateAppId;
this.translateSecret = this.toolsConfig.translateSecret; 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 twitterUrl = reg.exec(e.msg);
const id = twitterUrl[1]; const id = twitterUrl[1];
const httpAgent = new HttpProxyAgent(this.myProxy); 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 // Tell typescript it's a readonly app
const readOnlyClient = twitterClient.readOnly; const readOnlyClient = twitterClient.readOnly;

View File

@ -3,4 +3,6 @@ proxyAddr: '127.0.0.1' # 魔法地址
proxyPort: '7890' # 魔法端口 proxyPort: '7890' # 魔法端口
translateAppId: '' # 百度翻译APP ID translateAppId: '' # 百度翻译APP ID
translateSecret: '' # 百度翻译密匙 translateSecret: '' # 百度翻译密匙
bearerToken: '' # 推特Bearer Token