utilitas 1989.9.27 → 1989.9.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bot.mjs +2 -2
- package/lib/tape.mjs +5 -4
- package/package.json +1 -1
package/lib/bot.mjs
CHANGED
|
@@ -28,8 +28,8 @@ const questions = [{
|
|
|
28
28
|
const subconscious = {
|
|
29
29
|
run: true, name: 'Subconscious', func: async (bot) => {
|
|
30
30
|
bot.use(async (ctx, next) => {
|
|
31
|
-
log(ctx.update);
|
|
32
|
-
|
|
31
|
+
log(`Updated: ${ctx.update.update_id}`);
|
|
32
|
+
process.stdout.write(`${JSON.stringify(ctx.update)}\n`);
|
|
33
33
|
await next();
|
|
34
34
|
});
|
|
35
35
|
bot.on('text', async (ctx, next) => {
|
package/lib/tape.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import * as utilitas from './utilitas.mjs';
|
|
|
7
7
|
// Handle, report, or silently ignore connection errors and failures
|
|
8
8
|
const handleError = (err) => { process.stdout.write(`${err.message}\n`); };
|
|
9
9
|
const consoleMap = { log: 'verbose', info: 0, debug: 0, warn: 0, error: 0 };
|
|
10
|
-
const [TAPE, defBufSize] = ['TAPE',
|
|
10
|
+
const [TAPE, defBufSize, maxLength] = ['TAPE', 100, 4096];
|
|
11
11
|
const modLog = (content) => { return utilitas.modLog(content, TAPE); };
|
|
12
12
|
const getLogger = async () => { return (await init()).logger; };
|
|
13
13
|
const [BOT, RSYSLOG, PAPERTRAIL] = ['BOT', 'RSYSLOG', 'PAPERTRAIL'];
|
|
@@ -89,10 +89,11 @@ const botLoggerInit = async (options) => {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
const botLoggerSync = async () => {
|
|
92
|
-
let
|
|
93
|
-
|
|
92
|
+
let fetched = (botBuffer?.length ? botBuffer.splice(0) : [
|
|
93
|
+
]).map(x => x[1]).join('\n').slice(0, maxLength);
|
|
94
|
+
if (!fetched.length) { return; }
|
|
94
95
|
for (let id of chatIds) {
|
|
95
|
-
try { await bot.send(id,
|
|
96
|
+
try { await bot.send(id, fetched); } catch (err) { handleError(err); }
|
|
96
97
|
}
|
|
97
98
|
};
|
|
98
99
|
|