Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/middlewares/bot-membership-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class BotMembershipHandler<C extends TelemetryContextFlavor<Context>> ext
redis,
prefix: "TEMP_groups",
logger,
ttl: 60 * 60 * 24, // 1 day, just in case
})

constructor() {
Expand All @@ -52,9 +53,12 @@ export class BotMembershipHandler<C extends TelemetryContextFlavor<Context>> ext
if (ctx.chat.type === "private") return next()

const redisCheck = await this.TEMP_redis.has(ctx.chat.id.toString())
if (redisCheck) {
const backendGroup = await api.tg.groups.getById.query({ telegramId: ctx.chat.id }).catch(() => null)
if (backendGroup !== null) return next()
if (redisCheck) return next()

const backendGroup = await api.tg.groups.getById.query({ telegramId: ctx.chat.id }).catch(() => null)
Comment thread
toto04 marked this conversation as resolved.
if (backendGroup !== null) {
await this.TEMP_redis.write(ctx.chat.id.toString(), ctx.chat.id)
return next()
Comment thread
toto04 marked this conversation as resolved.
}

const me = await ctx.getChatMember(ctx.me.id).catch(() => ({ status: "undefined" }))
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/message-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function parseTelegramMessageLink(link: string): Promise<{
const chatId = chatHandle
? await api.tg.groups.getByTag
.query({ tag: chatHandle })
.then((r) => stripChatId(r?.telegramId) ?? null)
.then((r) => (r?.telegramId ? stripChatId(r.telegramId) : null))
.catch(() => null)
: parseInt(match[1], 10)
const messageId = match[4] ? parseInt(match[4], 10) : parseInt(match[3], 10)
Expand Down
Loading