Skip to content

Commit

Permalink
fix(telegram): support slash command with at, fix koishijs/koishi#1439
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Aug 13, 2024
1 parent d42ba28 commit 91414cc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion adapters/telegram/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export async function handleUpdate(update: Telegram.Update, bot: TelegramBot) {
if (isBotCommand) {
session.type = 'interaction/command'
await decodeMessage(bot, message, session.event.message = {}, session.event)
session.content = session.content.slice(1)
// content: /command@bot ...args
const [group] = session.content.split(' ', 1)
const [command, username] = group.slice(1).split('@')
if (username !== bot.user.name) return
session.content = command + session.content.slice(group.length)
} else if (message) {
if (update.message?.media_group_id) {
if (!mediaGroupMap.has(update.message.media_group_id)) { mediaGroupMap.set(update.message.media_group_id, [new Date(), []]) }
Expand Down

0 comments on commit 91414cc

Please sign in to comment.