Skip to content

Commit 6a83982

Browse files
committed
Drop grammy-guard
1 parent 8d4f1d2 commit 6a83982

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/bot/features/admin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import { Composer } from 'grammy'
77

88
const composer = new Composer<Context>()
99

10-
const feature = composer.chatType('private').filter(ctx => isAdmin(ctx.config.botAdmins)(ctx))
10+
const feature = composer
11+
.chatType('private')
12+
.filter(isAdmin)
1113

1214
feature.command(
1315
'setcommands',

src/bot/filters/is-admin.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
import { isUserHasId } from 'grammy-guard'
1+
import type { Context } from '#root/bot/context.js'
22

3-
export const isAdmin = (ids: number[]) => isUserHasId(...ids)
3+
export function isAdmin(ctx: Context) {
4+
return !!ctx.from && ctx.config.botAdmins.includes(ctx.from.id)
5+
}

0 commit comments

Comments
 (0)