Ver Fonte

Merge branch 'koishi-production' into fleets-koishi

Mike L há 3 anos atrás
pai
commit
b3610c6828
4 ficheiros alterados com 7 adições e 6 exclusões
  1. 3 2
      dist/koishi.js
  2. 1 1
      dist/twitter.js
  3. 2 2
      src/koishi.ts
  4. 1 1
      src/twitter.ts

+ 3 - 2
dist/koishi.js

@@ -90,7 +90,7 @@ class default_1 {
         this.sendToUser = (userID, message) => new Promise((resolve, reject) => {
             this.enqueue('private', userID, () => this.bot.sendPrivateMessage(userID, message).then(resolve).catch(reject));
         });
-        this.sendTo = (subscriber, messageChain) => Promise.all((splitted => [splitted.message, ...splitted.attachments])(exports.Message.separateAttachment(messageChain)).map(msg => {
+        this.sendTo = (subscriber, messageChain, noErrors = false) => Promise.all((splitted => [splitted.message, ...splitted.attachments])(exports.Message.separateAttachment(messageChain)).map(msg => {
             switch (subscriber.chatType) {
                 case 'group':
                     return this.sendToGroup(subscriber.chatID.toString(), msg);
@@ -107,7 +107,8 @@ class default_1 {
         })
             .catch(reason => {
             logger.error(exports.Message.ellipseBase64(`error pushing data to ${JSON.stringify(subscriber.chatID)}, reason: ${reason}`));
-            throw reason instanceof Error ? reason : Error(reason);
+            if (!noErrors)
+                throw reason instanceof Error ? reason : Error(reason);
         });
         this.initBot = () => {
             this.app = new koishi_1.App({

+ 1 - 1
dist/twitter.js

@@ -90,7 +90,7 @@ class default_1 {
                     }
                     else {
                         logger.warn(`${count - 1} consecutive failures while sending message chain, trying plain text instead...`);
-                        terminate(this.bot.sendTo(subscriber, text));
+                        terminate(this.bot.sendTo(subscriber, text, true));
                     }
                 });
             });

+ 2 - 2
src/koishi.ts

@@ -104,7 +104,7 @@ export default class {
     this.enqueue('private', userID, () => this.bot.sendPrivateMessage(userID, message).then(resolve).catch(reject));
   });
 
-  public sendTo = (subscriber: IChat, messageChain: string) => Promise.all(
+  public sendTo = (subscriber: IChat, messageChain: string, noErrors = false) => Promise.all(
     (splitted => [splitted.message, ...splitted.attachments])(
       Message.separateAttachment(messageChain)
     ).map(msg => {
@@ -123,7 +123,7 @@ export default class {
     })
     .catch(reason => {
       logger.error(Message.ellipseBase64(`error pushing data to ${JSON.stringify(subscriber.chatID)}, reason: ${reason}`));
-      throw reason instanceof Error ? reason : Error(reason);
+      if (!noErrors) throw reason instanceof Error ? reason : Error(reason);
     });
 
   private initBot = () => {

+ 1 - 1
src/twitter.ts

@@ -228,7 +228,7 @@ export default class {
             logger.warn(`retry sending to ${subscriber.chatID} for the ${ordinal(count)} time...`);
           } else {
             logger.warn(`${count - 1} consecutive failures while sending message chain, trying plain text instead...`);
-            terminate(this.bot.sendTo(subscriber, text));
+            terminate(this.bot.sendTo(subscriber, text, true));
           }
         });
     });