Skip to content

Commit

Permalink
fix(telegram): only detect chat type if chat object exists (#340)
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined-moe authored Feb 23, 2025
1 parent ea5a002 commit 4d25df2
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions adapters/telegram/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,21 +120,23 @@ export async function handleUpdate(update: Telegram.Update, bot: TelegramBot) {
id: update.callback_query.data,
}
const data = update.callback_query.message
if (data.chat.type === 'private') {
session.event.channel = {
id: data.chat.id.toString(),
type: Universal.Channel.Type.DIRECT,
}
} else {
session.event.guild = {
id: data.chat.id.toString(),
name: data.chat.title,
}
session.event.channel = {
id: data.is_topic_message
? data.message_thread_id.toString()
: data.chat.id.toString(),
type: Universal.Channel.Type.TEXT,
if (data) {
if (data.chat.type === 'private') {
session.event.channel = {
id: data.chat.id.toString(),
type: Universal.Channel.Type.DIRECT,
}
} else {
session.event.guild = {
id: data.chat.id.toString(),
name: data.chat.title,
}
session.event.channel = {
id: data.is_topic_message
? data.message_thread_id.toString()
: data.chat.id.toString(),
type: Universal.Channel.Type.TEXT,
}
}
}
await bot.internal.answerCallbackQuery({
Expand Down

0 comments on commit 4d25df2

Please sign in to comment.