|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
};
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
exports.ellipseBase64InMessage = exports.message = void 0;
|
|
|
-const getPort = require("get-port");
|
|
|
const koishi_1 = require("koishi");
|
|
|
require("koishi-adapter-onebot");
|
|
|
const command_1 = require("./command");
|
|
@@ -62,20 +61,16 @@ class default_1 {
|
|
|
logger.info(response);
|
|
|
})
|
|
|
.catch(reason => {
|
|
|
+ reason = exports.ellipseBase64InMessage(reason);
|
|
|
logger.error(`error pushing data to ${JSON.stringify(subscriber.chatID)}, reason: ${reason}`);
|
|
|
throw Error(reason);
|
|
|
});
|
|
|
- this.initBot = () => __awaiter(this, void 0, void 0, function* () {
|
|
|
- const port = yield getPort();
|
|
|
+ this.initBot = () => {
|
|
|
this.app = new koishi_1.App({
|
|
|
type: 'onebot',
|
|
|
- port,
|
|
|
- server: `http://${this.botInfo.host}:${this.botInfo.port}`,
|
|
|
+ server: `ws://${this.botInfo.host}:${this.botInfo.port}`,
|
|
|
selfId: this.botInfo.bot_id.toString(),
|
|
|
token: this.botInfo.access_token,
|
|
|
- onebot: {
|
|
|
- quickOperation: 100,
|
|
|
- },
|
|
|
axiosConfig: {
|
|
|
maxContentLength: Infinity,
|
|
|
},
|
|
@@ -164,11 +159,22 @@ count 与 since/until 并用时,取二者中实际查询结果较少者
|
|
|
其中不包含原生转推(实际上用户只发了 1 条)`));
|
|
|
}
|
|
|
}
|
|
|
- }));
|
|
|
+ }), true);
|
|
|
+ };
|
|
|
+ this.listen = (logMsg = 'connecting to bot provider...') => __awaiter(this, void 0, void 0, function* () {
|
|
|
+ logger.warn(logMsg);
|
|
|
+ try {
|
|
|
+ yield this.app.start();
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ logger.error(`error connecting to bot provider at ${this.app.options.server}, will retry in 2.5s...`);
|
|
|
+ yield koishi_1.sleep(2500);
|
|
|
+ yield this.listen('retry connecting...');
|
|
|
+ }
|
|
|
});
|
|
|
this.connect = () => __awaiter(this, void 0, void 0, function* () {
|
|
|
- yield this.initBot();
|
|
|
- yield this.app.start();
|
|
|
+ this.initBot();
|
|
|
+ yield this.listen();
|
|
|
this.bot = this.app.getBot('onebot');
|
|
|
});
|
|
|
logger.warn(`Initialized koishi on ${opt.host}:${opt.port} with access_token ${opt.access_token}`);
|