Browse Source

fix resend, temporarily disable trimming 3rd line

Mike L 4 years ago
parent
commit
fb678c632e
4 changed files with 22 additions and 22 deletions
  1. 4 4
      dist/twitter.js
  2. 7 7
      dist/webshot.js
  3. 4 4
      src/twitter.ts
  4. 7 7
      src/webshot.ts

+ 4 - 4
dist/twitter.js

@@ -96,8 +96,7 @@ class default_1 {
                 return this.webshot(tweets, msg => {
                     lock.threads[lock.feed[lock.workon]].subscribers.forEach(subscriber => {
                         logger.info(`pushing data of thread ${lock.feed[lock.workon]} to ${JSON.stringify(subscriber)}`);
-                        this.bot.sendTo(subscriber, msg)
-                            .catch(reason => {
+                        const retry = reason => {
                             if (typeof (msg) !== 'string') {
                                 logger.warn(`retry sending to ${subscriber.chatID}`);
                                 msg.forEach((message, pos) => {
@@ -105,9 +104,10 @@ class default_1 {
                                         msg[pos] = mirai_1.MiraiMessage.Plain(`[失败的图片:${message.path}]`);
                                     }
                                 });
-                                this.bot.sendTo(subscriber, msg).catch();
                             }
-                        });
+                            this.bot.sendTo(subscriber, msg).catch(retry);
+                        };
+                        this.bot.sendTo(subscriber, msg).catch(retry);
                     });
                 }, this.webshotDelay)
                     .then(() => {

+ 7 - 7
dist/webshot.js

@@ -113,13 +113,13 @@ class Webshot extends CallableInstance {
                                         const b = y + 1;
                                         if (this.height - boundary - (boundary - b) <= 1) {
                                             boundary = b;
-                                        }
-                                    }
-                                    // if "retweet" count and "like" count are two rows, this will be the line above the first
-                                    if (cnt === 6) {
-                                        const c = y + 1;
-                                        if (this.height - boundary - 2 * (boundary - c) <= 2) {
-                                            boundary = c;
+                                            //   }
+                                            // }
+                                            // // if "retweet" count and "like" count are two rows, this will be the line above the first
+                                            // if (cnt === 6) {
+                                            //   const c = y + 1;
+                                            //   if (this.height - boundary - 2 * (boundary - c) <= 2) {
+                                            //     boundary = c;
                                             break;
                                         }
                                     }

+ 4 - 4
src/twitter.ts

@@ -138,8 +138,7 @@ export default class {
       return (this.webshot as any)(tweets, msg => {
         lock.threads[lock.feed[lock.workon]].subscribers.forEach(subscriber => {
           logger.info(`pushing data of thread ${lock.feed[lock.workon]} to ${JSON.stringify(subscriber)}`);
-          this.bot.sendTo(subscriber, msg)
-          .catch(reason => { // workaround for https://github.com/mamoe/mirai/issues/194
+          const retry = reason => { // workaround for https://github.com/mamoe/mirai/issues/194
             if (typeof(msg) !== 'string') {
               logger.warn(`retry sending to ${subscriber.chatID}`);
               (msg as MessageChain).forEach((message, pos) => {
@@ -147,9 +146,10 @@ export default class {
                   msg[pos] = Message.Plain(`[失败的图片:${message.path}]`);
                 }
               });
-              this.bot.sendTo(subscriber, msg).catch();
             }
-          });
+            this.bot.sendTo(subscriber, msg).catch(retry);
+          };
+          this.bot.sendTo(subscriber, msg).catch(retry);
         });
       }, this.webshotDelay)
         .then(() => {

+ 7 - 7
src/webshot.ts

@@ -135,14 +135,14 @@ class Webshot extends CallableInstance<[number], Promise<void>> {
                       const b = y + 1;
                       if (this.height - boundary - (boundary - b) <= 1) {
                         boundary = b;
-                      }
-                    }
+                    //   }
+                    // }
 
-                    // if "retweet" count and "like" count are two rows, this will be the line above the first
-                    if (cnt === 6) {
-                      const c = y + 1;
-                      if (this.height - boundary - 2 * (boundary - c) <= 2) {
-                        boundary = c;
+                    // // if "retweet" count and "like" count are two rows, this will be the line above the first
+                    // if (cnt === 6) {
+                    //   const c = y + 1;
+                    //   if (this.height - boundary - 2 * (boundary - c) <= 2) {
+                    //     boundary = c;
                         break;
                       }
                     }