Skip to content

Commit

Permalink
adapter-telegram: only detect chat type if chat object exists
Browse files Browse the repository at this point in the history
  • Loading branch information
undefined-moe committed Feb 19, 2025
1 parent 060df0b commit b44289a
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 b44289a

Please sign in to comment.