Browse Source

show text of deleted tweet

Mike L 3 years ago
parent
commit
f587d2a1b7
3 changed files with 5 additions and 2 deletions
  1. 2 1
      dist/webshot.js
  2. 0 0
      dist/webshot.js.map
  3. 3 1
      src/webshot.ts

+ 2 - 1
dist/webshot.js

@@ -105,6 +105,7 @@ class Webshot extends CallableInstance {
                         return utils_1.chainPromises(sensitiveToggles.filter(toggle => toggle.isVisible()).map(toggle => () => toggle.click()));
                     })
                         .then(() => handle))
+                        .then(handle => handle.$('xpath=.//a[contains(@href,"notices-on-twitter")]').then(placeholder => placeholder ? null : handle))
                         .catch((err) => {
                         if (err.name !== 'TimeoutError')
                             throw err;
@@ -298,7 +299,7 @@ class Webshot extends CallableInstance {
                     .then(fileurl => {
                     if (fileurl)
                         return koishi_1.Message.Image(fileurl);
-                    return author + text;
+                    return '[截图不可用] ' + author + text;
                 })
                     .then(msg => {
                     if (msg)

File diff suppressed because it is too large
+ 0 - 0
dist/webshot.js.map


+ 3 - 1
src/webshot.ts

@@ -134,6 +134,8 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
               })
               .then(() => handle)
             )
+            // throw early if tweet is unavailable
+            .then(handle => handle.$('xpath=.//a[contains(@href,"notices-on-twitter")]').then(placeholder => placeholder ? null : handle))
             .catch((err: Error): Promise<puppeteer.ElementHandle<HTMLDivElement> | null> => {
               if (err.name !== 'TimeoutError') throw err;
               logger.warn(`navigation timed out at ${getTimerTime()} ms`);
@@ -330,7 +332,7 @@ class Webshot extends CallableInstance<[Tweets, (...args) => void, number], Prom
         promise = promise.then(() => this.renderWebshot(url, 1920, webshotDelay))
           .then(fileurl => {
             if (fileurl) return Message.Image(fileurl);
-            return author + text;
+            return '[截图不可用] ' + author + text;
           })
           .then(msg => {
             if (msg) messageChain += msg;

Some files were not shown because too many files changed in this diff