Browse Source

Merge branch 'koishi-production' into fleets-koishi

Mike L 3 years ago
parent
commit
0ffdc997a0
4 changed files with 9 additions and 14 deletions
  1. 2 3
      dist/koishi.js
  2. 2 4
      dist/twitter.js
  3. 2 3
      src/koishi.ts
  4. 3 4
      src/twitter.ts

+ 2 - 3
dist/koishi.js

@@ -106,9 +106,8 @@ class default_1 {
             logger.info(`pushing data to ${JSON.stringify(subscriber.chatID)} was successful, response: ${response}`);
         })
             .catch(reason => {
-            reason = exports.Message.ellipseBase64(reason);
-            logger.error(`error pushing data to ${JSON.stringify(subscriber.chatID)}, reason: ${reason}`);
-            throw Error(reason);
+            logger.error(exports.Message.ellipseBase64(`error pushing data to ${JSON.stringify(subscriber.chatID)}, reason: ${reason}`));
+            throw reason instanceof Error ? reason : Error(reason);
         });
         this.initBot = () => {
             this.app = new koishi_1.App({

+ 2 - 4
dist/twitter.js

@@ -15,7 +15,6 @@ const path = require("path");
 const request = require("request");
 const Twitter = require("twitter");
 const loggers_1 = require("./loggers");
-const koishi_1 = require("./koishi");
 const utils_1 = require("./utils");
 const webshot_1 = require("./webshot");
 class ScreenNameNormalizer {
@@ -84,14 +83,13 @@ class default_1 {
         this.workOnFleets = (user, fleets, sendFleets) => this.webshot(user, fleets, sendFleets, this.webshotDelay);
         this.sendFleets = (source, ...to) => (msg, text) => {
             to.forEach(subscriber => {
-                logger.info(`pushing data${source ? ` of ${koishi_1.Message.ellipseBase64(source)}` : ''} to ${JSON.stringify(subscriber)}`);
+                logger.info(`pushing data${source ? ` of ${source}` : ''} to ${JSON.stringify(subscriber)}`);
                 retryOnError(() => this.bot.sendTo(subscriber, msg), (_, count, terminate) => {
                     if (count <= maxTrials) {
                         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...');
+                        logger.warn(`${count - 1} consecutive failures while sending message chain, trying plain text instead...`);
                         terminate(this.bot.sendTo(subscriber, text));
                     }
                 });

+ 2 - 3
src/koishi.ts

@@ -122,9 +122,8 @@ export default class {
       logger.info(`pushing data to ${JSON.stringify(subscriber.chatID)} was successful, response: ${response}`);
     })
     .catch(reason => {
-      reason = Message.ellipseBase64(reason);
-      logger.error(`error pushing data to ${JSON.stringify(subscriber.chatID)}, reason: ${reason}`);
-      throw Error(reason);
+      logger.error(Message.ellipseBase64(`error pushing data to ${JSON.stringify(subscriber.chatID)}, reason: ${reason}`));
+      throw reason instanceof Error ? reason : Error(reason);
     });
 
   private initBot = () => {

+ 3 - 4
src/twitter.ts

@@ -5,7 +5,7 @@ import * as Twitter from 'twitter';
 import TwitterTypes from 'twitter-d';
 
 import { getLogger } from './loggers';
-import QQBot, { Message } from './koishi';
+import QQBot from './koishi';
 import { BigNumOps } from './utils';
 import Webshot from './webshot';
 
@@ -220,15 +220,14 @@ export default class {
 
   private sendFleets = (source?: string, ...to: IChat[]) => (msg: string, text: string) => {
     to.forEach(subscriber => {
-      logger.info(`pushing data${source ? ` of ${Message.ellipseBase64(source)}` : ''} to ${JSON.stringify(subscriber)}`);
+      logger.info(`pushing data${source ? ` of ${source}` : ''} to ${JSON.stringify(subscriber)}`);
       retryOnError(
         () => this.bot.sendTo(subscriber, msg),
         (_, count, terminate: (doNothing: Promise<void>) => void) => {
           if (count <= maxTrials) {
             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...');
+            logger.warn(`${count - 1} consecutive failures while sending message chain, trying plain text instead...`);
             terminate(this.bot.sendTo(subscriber, text));
           }
         });