Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reply_parameters doesn't work in Context.replyWithPhoto #1970

Open
haruki-nikaidou opened this issue Mar 10, 2024 · 3 comments · May be fixed by #1992
Open

reply_parameters doesn't work in Context.replyWithPhoto #1970

haruki-nikaidou opened this issue Mar 10, 2024 · 3 comments · May be fixed by #1992

Comments

@haruki-nikaidou
Copy link

Context

In a typescript + webpack project, using webpack --watch and nodemon to develop.

  • Telegraf.js Version: 4.16.3
  • Node.js Version: 20.11.1
  • Operating System: Kubuntu 23.10 x86_64

Minimal Example Code Reproducing the Issue

export async function replyAPhoto(ctx: Context) {
    const command_message_id = ctx.message.message_id;
    const photoBuffer = await getPhotoBuffer();
    await ctx.replyWithPhoto({source: photoBuffer}, {
        reply_parameters: { message_id: command_message_id },
    });
}

I have registered that function in /see command. When I send the command, the photo is sent, but not reply.

Expected Behavior

Send the photo and reply my command message

Current Behavior

Send the photo but not reply my command message

Error Message and Logs (export DEBUG='telegraf:*')

  telegraf:main Created a `Telegraf` instance +0ms
Bot is running
  telegraf:main Connecting to Telegram +1ms
  telegraf:client HTTP call getMe {} +0ms
  telegraf:main Launching @mybot +1s
  telegraf:client HTTP call deleteWebhook { drop_pending_updates: undefined } +1s
  telegraf:main Bot started with long polling +298ms
  telegraf:polling Starting long polling +0ms
  telegraf:client HTTP call getUpdates { timeout: 50, offset: 0, allowed_updates: [] } +299ms
  telegraf:main Processing update 306145224 +4s
  telegraf:client HTTP call sendPhoto {
  chat_id: 6152025353,
  photo: {
    source: <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 02 80 00 00 04 70 08 06 00 00 00 7a 8f e5 00 00 03 30 8f 49 44 41 54 78 01 ec c1 07 80 5e f7 59 ... 209046 more bytes>
  },
  message_thread_id: undefined,
  reply_parameters: { message_id: 88 }
} +4s
  telegraf:main Finished processing update 306145224 +2s
  telegraf:client HTTP call getUpdates { timeout: 50, offset: 306145225, allowed_updates: [] } +2s

@BlackYuzia
Copy link

BlackYuzia commented Mar 15, 2024

Semi equal for Videos.

                // reply
                await bot.telegram.sendMessage(chatId, "telegraf гівна поїв", {
                    disable_notification: true,
                    reply_parameters: {
                        chat_id: chatId,
                        message_id: infoMessage.message_id,
                        allow_sending_without_reply: false
                    }
                })
                // no reply
                await bot.telegram.sendVideo(chatId, Input.fromLocalFile(lessonPath, lesson.state.output), {
                    caption: lesson.state.output,
                    disable_notification: true,
                    reply_parameters: {
                        chat_id: chatId,
                        message_id: infoMessage.message_id,
                        allow_sending_without_reply: false
                    }
                })

image

If you use Telegram REST API manualy and send request with all the same data, all will works fine
image

@Jsouwl
Copy link

Jsouwl commented May 18, 2024

Same issue

@clansty
Copy link

clansty commented May 19, 2024

Look at attachFormValue of client.ts, it did't process the situation of typeof value === 'object' but value have no media or type props (is not a attachment media)

But with reply_parameters, the value is something like { message_id: 114514 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants