Explorar el Código

redefine working interval to match other branches

Mike L hace 3 años
padre
commit
cb6dd2f7a4
Se han modificado 2 ficheros con 16 adiciones y 16 borrados
  1. 8 8
      dist/twitter.js
  2. 8 8
      src/twitter.ts

+ 8 - 8
dist/twitter.js

@@ -174,12 +174,12 @@ class default_1 {
     constructor(opt) {
         this.launch = () => {
             this.webshot = new webshot_1.default(this.wsUrl, this.mode, () => {
-                setTimeout(this.workForAll, this.workInterval * 1000);
+                setTimeout(this.workForAll, this.workInterval * 1000 / this.lock.feed.length);
                 setTimeout(() => {
                     this.work();
                     setInterval(() => { this.pullOrders = utils_1.Arr.shuffle(this.pullOrders); }, 21600000);
-                    setInterval(this.workForAll, this.workInterval * 10000);
-                }, this.workInterval * 1200);
+                    setInterval(this.workForAll, this.workInterval * 1000);
+                }, this.workInterval * 1200 / this.lock.feed.length);
             });
         };
         this.queryUser = (rawUserName) => {
@@ -248,7 +248,7 @@ class default_1 {
                             thread.updatedAt = (this.cache[idToUserMap[thread.id].username].updated = new Date()).toString();
                         }
                     }));
-                }), (lp1, lp2) => () => lp1().then(() => util_1.promisify(setTimeout)(this.workInterval * 1000).then(lp2)));
+                }), (lp1, lp2) => () => lp1().then(() => util_1.promisify(setTimeout)(this.workInterval * 1000 / this.lock.feed.length).then(lp2)));
             })
                 .catch((error) => {
                 if (error instanceof instagram_private_api_1.IgNetworkError) {
@@ -271,7 +271,7 @@ class default_1 {
                 setTimeout(() => {
                     this.workForAll();
                     setTimeout(this.work, this.workInterval * 200);
-                }, this.workInterval * 1000);
+                }, this.workInterval * 1000 / lock.feed.length);
                 return;
             }
             if (lock.workon >= lock.feed.length)
@@ -293,12 +293,12 @@ class default_1 {
             if (!match) {
                 logger.error(`current feed "${currentFeed}" is invalid, please remove this feed manually`);
                 lock.workon++;
-                setTimeout(this.work, this.workInterval * 1000);
+                setTimeout(this.work, this.workInterval * 1000 / lock.feed.length);
                 return;
             }
             const cachedFeed = this.cache[match[1]];
             if (!cachedFeed) {
-                setTimeout(this.work, this.workInterval * 1000);
+                setTimeout(this.work, this.workInterval * 1000 / lock.feed.length);
                 return;
             }
             const newer = (item) => utils_1.BigNumOps.compare(item.pk, lock.threads[currentFeed].offset) > 0;
@@ -380,7 +380,7 @@ class default_1 {
                 .then(userNameId => {
                 var _a, _b;
                 const [userName, userId] = userNameId.split(':');
-                if (Date.now() - ((_b = (_a = this.cache[userName]) === null || _a === void 0 ? void 0 : _a.updated) === null || _b === void 0 ? void 0 : _b.getTime()) > this.workInterval * 10000 &&
+                if (Date.now() - ((_b = (_a = this.cache[userName]) === null || _a === void 0 ? void 0 : _a.updated) === null || _b === void 0 ? void 0 : _b.getTime()) > this.workInterval * 1000 &&
                     Object.keys(this.cache[userName].stories).length > 0) {
                     return userName;
                 }

+ 8 - 8
src/twitter.ts

@@ -250,7 +250,7 @@ export default class {
       this.queryUser(rawUserName)
         .then(userNameId => {
           const [userName, userId] = userNameId.split(':');
-          if (Date.now() - this.cache[userName]?.updated?.getTime() > this.workInterval * 10000 &&
+          if (Date.now() - this.cache[userName]?.updated?.getTime() > this.workInterval * 1000 &&
             Object.keys(this.cache[userName].stories).length > 0) {
             return userName;
           }
@@ -298,12 +298,12 @@ export default class {
       this.wsUrl,
       this.mode,
       () => {
-        setTimeout(this.workForAll, this.workInterval * 1000);
+        setTimeout(this.workForAll, this.workInterval * 1000 / this.lock.feed.length);
         setTimeout(() => {
           this.work();
           setInterval(() => { this.pullOrders = Arr.shuffle(this.pullOrders); }, 21600000);
-          setInterval(this.workForAll, this.workInterval * 10000);
-        }, this.workInterval * 1200);
+          setInterval(this.workForAll, this.workInterval * 1000);
+        }, this.workInterval * 1200 / this.lock.feed.length);
       }
     );
   };
@@ -407,7 +407,7 @@ export default class {
                 }
               })) as unknown as Promise<void>;
           }),
-          (lp1, lp2) => () => lp1().then(() => promisify(setTimeout)(this.workInterval * 1000).then(lp2))
+          (lp1, lp2) => () => lp1().then(() => promisify(setTimeout)(this.workInterval * 1000 / this.lock.feed.length).then(lp2))
         );
       })
       .catch((error: IgClientError & Partial<RequestError>) => {
@@ -438,7 +438,7 @@ export default class {
       setTimeout(() => {
         this.workForAll();
         setTimeout(this.work, this.workInterval * 200);
-      }, this.workInterval * 1000);
+      }, this.workInterval * 1000 / lock.feed.length);
       return;
     }
     if (lock.workon >= lock.feed.length) lock.workon = 0;
@@ -461,11 +461,11 @@ export default class {
     const match = /https:\/\/www\.instagram\.com\/([^\/]+)/.exec(currentFeed);
     if (!match) {
       logger.error(`current feed "${currentFeed}" is invalid, please remove this feed manually`);
-      lock.workon++; setTimeout(this.work, this.workInterval * 1000); return;
+      lock.workon++; setTimeout(this.work, this.workInterval * 1000 / lock.feed.length); return;
     }
     const cachedFeed = this.cache[match[1]];
     if (!cachedFeed) {
-      setTimeout(this.work, this.workInterval * 1000); return;
+      setTimeout(this.work, this.workInterval * 1000 / lock.feed.length); return;
     }
     const newer = (item: CachedMediaItem) => BigNumOps.compare(item.pk, lock.threads[currentFeed].offset) > 0;
     const promise = Promise.resolve(Object.values(cachedFeed.stories)