Skip to content

Commit 765a7e8

Browse files
perf: create group ids Set once
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d890b9b commit 765a7e8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/middlewares/group-specific-actions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ const TARGET_GROUPS: Record<string, number> = {
1313
books: -1001164044303,
1414
} as const
1515

16+
const TARGET_GROUP_IDS_SET = new Set(Object.values(TARGET_GROUPS));
17+
1618
export class GroupSpecificActions<C extends Context> implements MiddlewareObj<C> {
1719
private composer = new Composer<C>()
1820

1921
constructor() {
2022
this.composer
21-
.filter((ctx) => !!ctx.chatId && Object.values(TARGET_GROUPS).includes(ctx.chatId))
23+
.filter((ctx) => !!ctx.chatId && TARGET_GROUP_IDS_SET.has(ctx.chatId))
2224
.on("message", async (ctx, next) => {
2325
if (ctx.from.id === ctx.me.id) return next() // skip if bot
2426
const { roles } = await api.tg.permissions.getRoles.query({ userId: ctx.from.id })

0 commit comments

Comments
 (0)