瀏覽代碼

notify question after push

Mike L 3 年之前
父節點
當前提交
91a283ac9c
共有 2 個文件被更改,包括 24 次插入19 次删除
  1. 11 9
      dist/twitter.js
  2. 13 10
      src/twitter.ts

+ 11 - 9
dist/twitter.js

@@ -319,16 +319,18 @@ class default_1 {
                 }
                 if (currentThread.offset === '0')
                     mediaItems.splice(1);
-                if (question) {
-                    currentThread.subscribers.forEach(subscriber => {
-                        const username = cachedFeed.user.username;
-                        const author = `${cachedFeed.user.full_name} (@${username}) `;
-                        this.bot.sendTo(subscriber, `请注意,用户${author}已开启问答互动。本次推送已在此条动态后暂停。需退订请回复:/igstory_unsub ${username}\
-${Object.keys(cachedFeed.stories).some(id => id > topOfFeed) ? `\n下次推送在 ${this.workInterval * 1000 / lock.feed.length} 秒后。` : ''}`);
-                    });
-                }
                 return this.workOnMedia(mediaItems.reverse(), this.sendStories(`thread ${currentFeed}`, ...currentThread.subscribers))
-                    .then(updateOffset);
+                    .then(updateOffset)
+                    .then(() => {
+                    if (question) {
+                        currentThread.subscribers.forEach(subscriber => {
+                            const username = cachedFeed.user.username;
+                            const author = `${cachedFeed.user.full_name} (@${username}) `;
+                            this.bot.sendTo(subscriber, `请注意,用户${author}已开启问答互动。需退订请回复:/igstory_unsub ${username}${Object.keys(cachedFeed.stories).some(id => id > topOfFeed) ?
+                                `\n本次推送已截止于此条动态,下次推送在 ${Math.floor(this.workInterval * 1000 / lock.feed.length)} 秒后。` : ''}`);
+                        });
+                    }
+                });
             })
                 .then(() => {
                 lock.workon++;

+ 13 - 10
src/twitter.ts

@@ -486,17 +486,20 @@ export default class {
       if (currentThread.offset === '-1') { updateOffset(); return; }
       if (currentThread.offset === '0') mediaItems.splice(1);
 
-      if (question) {
-        currentThread.subscribers.forEach(subscriber => {
-          const username = cachedFeed.user.username;
-          const author = `${cachedFeed.user.full_name} (@${username}) `;
-          this.bot.sendTo(subscriber, `请注意,用户${author}已开启问答互动。本次推送已在此条动态后暂停。需退订请回复:/igstory_unsub ${username}\
-${Object.keys(cachedFeed.stories).some(id => id > topOfFeed) ? `\n下次推送在 ${this.workInterval * 1000 / lock.feed.length} 秒后。` : ''}`);
-        });
-      }
-
       return this.workOnMedia(mediaItems.reverse(), this.sendStories(`thread ${currentFeed}`, ...currentThread.subscribers))
-        .then(updateOffset);
+        .then(updateOffset)
+        .then(() => {
+          if (question) {
+            currentThread.subscribers.forEach(subscriber => {
+              const username = cachedFeed.user.username;
+              const author = `${cachedFeed.user.full_name} (@${username}) `;
+              this.bot.sendTo(subscriber,
+                `请注意,用户${author}已开启问答互动。需退订请回复:/igstory_unsub ${username}${
+                  Object.keys(cachedFeed.stories).some(id => id > topOfFeed) ?
+                    `\n本次推送已截止于此条动态,下次推送在 ${Math.floor(this.workInterval * 1000 / lock.feed.length)} 秒后。` : ''}`);
+            });
+          }
+        });
     })
       .then(() => {
         lock.workon++;