|
@@ -4,7 +4,7 @@ const CQWebsocket = require("cq-websocket");
|
|
const log4js = require("log4js");
|
|
const log4js = require("log4js");
|
|
const helper_1 = require("./helper");
|
|
const helper_1 = require("./helper");
|
|
const logger = log4js.getLogger('cq-websocket');
|
|
const logger = log4js.getLogger('cq-websocket');
|
|
-logger.level = 'info';
|
|
|
|
|
|
+logger.level = global.loglevel;
|
|
class default_1 {
|
|
class default_1 {
|
|
constructor(opt) {
|
|
constructor(opt) {
|
|
this.retryInterval = 1000;
|
|
this.retryInterval = 1000;
|
|
@@ -63,16 +63,16 @@ class default_1 {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
this.bot.on('api.send.pre', (type, apiRequest) => {
|
|
this.bot.on('api.send.pre', (type, apiRequest) => {
|
|
- logger.info(`sending request ${type}: ${JSON.stringify(apiRequest)}`);
|
|
|
|
|
|
+ logger.debug(`sending request ${type}: ${JSON.stringify(apiRequest)}`);
|
|
});
|
|
});
|
|
this.bot.on('api.send.post', (type) => {
|
|
this.bot.on('api.send.post', (type) => {
|
|
- logger.info(`sent request ${type}`);
|
|
|
|
|
|
+ logger.debug(`sent request ${type}`);
|
|
});
|
|
});
|
|
this.bot.on('api.response', (type, result) => {
|
|
this.bot.on('api.response', (type, result) => {
|
|
if (result.retcode !== 0)
|
|
if (result.retcode !== 0)
|
|
logger.warn(`${type} respond: ${JSON.stringify(result)}`);
|
|
logger.warn(`${type} respond: ${JSON.stringify(result)}`);
|
|
else
|
|
else
|
|
- logger.info(`${type} respond: ${JSON.stringify(result)}`);
|
|
|
|
|
|
+ logger.debug(`${type} respond: ${JSON.stringify(result)}`);
|
|
});
|
|
});
|
|
};
|
|
};
|
|
this.connect = () => {
|
|
this.connect = () => {
|
|
@@ -84,13 +84,13 @@ class default_1 {
|
|
this.retryInterval *= 2;
|
|
this.retryInterval *= 2;
|
|
if (this.retryInterval > 300000)
|
|
if (this.retryInterval > 300000)
|
|
this.retryInterval = 300000;
|
|
this.retryInterval = 300000;
|
|
- logger.info(`retrying in ${this.retryInterval / 1000}s...`);
|
|
|
|
|
|
+ logger.warn(`retrying in ${this.retryInterval / 1000}s...`);
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
logger.warn('reconnecting to websocket...');
|
|
logger.warn('reconnecting to websocket...');
|
|
this.connect();
|
|
this.connect();
|
|
}, this.retryInterval);
|
|
}, this.retryInterval);
|
|
};
|
|
};
|
|
- logger.info(`init cqwebsocket for ${opt.host}:${opt.port}, with access_token ${opt.access_token}`);
|
|
|
|
|
|
+ logger.warn(`init cqwebsocket for ${opt.host}:${opt.port}, with access_token ${opt.access_token}`);
|
|
this.botInfo = opt;
|
|
this.botInfo = opt;
|
|
}
|
|
}
|
|
}
|
|
}
|