First build

This commit is contained in:
Lucid Kobold
2025-02-19 11:11:47 -05:00
43 changed files with 4061 additions and 7177 deletions

View File

@@ -1,7 +1,7 @@
export function chunk<T>(array: T[], size: number) {
const result = []
const result = [];
for (let index = 0; index < array.length; index += size)
result.push(array.slice(index, index + size))
result.push(array.slice(index, index + size));
return result
return result;
}

View File

@@ -1,20 +1,20 @@
import type { Context } from '#root/bot/context.js'
import type { Update } from '@grammyjs/types'
import type { Middleware } from 'grammy'
import type { Context } from "#root/bot/context.js";
import type { Update } from "@grammyjs/types";
import type { Middleware } from "grammy";
export function getUpdateInfo(ctx: Context): Omit<Update, 'update_id'> {
const { update_id, ...update } = ctx.update
export function getUpdateInfo(ctx: Context): Omit<Update, "update_id"> {
const { /*update_id,*/ ...update } = ctx.update;
return update
return update;
}
export function logHandle(id: string): Middleware<Context> {
return (ctx, next) => {
ctx.logger.info({
msg: `Handle "${id}"`,
...(id.startsWith('unhandled') ? { update: getUpdateInfo(ctx) } : {}),
})
...(id.startsWith("unhandled") ? { update: getUpdateInfo(ctx) } : {})
});
return next()
}
return next();
};
}