()
| 88 | } |
| 89 | |
| 90 | async run() { |
| 91 | const cached = this.getCachedToken(); |
| 92 | if (cached?.accessToken) { |
| 93 | this.applyToken(cached); |
| 94 | $.log(`账号[${this.index}] 使用缓存token: ${shortToken(this.token)}`); |
| 95 | if (!(await this.checkToken())) { |
| 96 | this.removeCachedToken(); |
| 97 | $.log(`账号[${this.index}] 缓存token失效,重新登录`); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | if (!this.token) { |
| 102 | await this.loginByWxCode(); |
| 103 | if (!this.token) return; |
| 104 | } |
| 105 | |
| 106 | await this.userInfoRequest(); |
| 107 | await this.getTreadList(); |
| 108 | if (this.threadId && this.postId) { |
| 109 | await this.likePost(this.threadId, this.postId); |
| 110 | await $.wait(5000); |
| 111 | await this.sharePost(this.threadId); |
| 112 | await $.wait(5000); |
| 113 | await this.viewPost(this.threadId); |
| 114 | await $.wait(5000); |
| 115 | await this.commonPost(this.threadId); |
| 116 | } |
| 117 | await this.getDrawNum(); |
| 118 | await this.signIn(); |
| 119 | } |
| 120 | |
| 121 | getCachedToken() { |
| 122 | const cache = readTokenCache(); |
no test coverage detected