Initialize deploy/docker-compose

This commit is contained in:
Lucid Kobold
2025-02-19 10:12:52 -05:00
committed by GitHub
commit 621f177653
42 changed files with 8193 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,20 @@
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
return update
}
export function logHandle(id: string): Middleware<Context> {
return (ctx, next) => {
ctx.logger.info({
msg: `Handle "${id}"`,
...(id.startsWith('unhandled') ? { update: getUpdateInfo(ctx) } : {}),
})
return next()
}
}