如何将EditMessageText与Telegraf框架一起使用?

发布于 2025-02-06 10:07:54 字数 856 浏览 1 评论 0原文

按下直列按钮时,我必须编辑一条消息。 这是我的代码:

bot.action("option2", (ctx) => {
  ctx.answerCbQuery();

  bot.telegram.editMessageText(
    ctx.update.callback_query.message.chat.id,
    ctx.update.callback_query.message.message_id,
    `Hello`
  );
});

我会收到错误:

{
  response: {
    ok: false,
    error_code: 400,
    description: 'Bad Request: message text is empty'  
  },
  on: {
    method: 'editMessageText',
    payload: {
      text: undefined,
      chat_id: 'Hello',
      message_id: { chat_id: -684957676, message_id: 578 },
      inline_message_id: undefined
    }
  }
}

我正在使用 telegraf 框架

我相信我相信我不了解我应该通过争论的顺序。

如何使用EditMessAgeText?

I have to edit a message when an inline button is pressed.
Here is my code:

bot.action("option2", (ctx) => {
  ctx.answerCbQuery();

  bot.telegram.editMessageText(
    ctx.update.callback_query.message.chat.id,
    ctx.update.callback_query.message.message_id,
    `Hello`
  );
});

I'm getting the error:

{
  response: {
    ok: false,
    error_code: 400,
    description: 'Bad Request: message text is empty'  
  },
  on: {
    method: 'editMessageText',
    payload: {
      text: undefined,
      chat_id: 'Hello',
      message_id: { chat_id: -684957676, message_id: 578 },
      inline_message_id: undefined
    }
  }
}

I'm using the Telegraf framework

I believe that I don't understand the order in which I should pass arguments.

How do I use the editMessageText?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微暖i 2025-02-13 10:07:54

您只能:

await ctx.editMessageText(`Hello`);

它将在聊天中自动找到最后一条消息,然后将其更改为“ Hello”

You can just:

await ctx.editMessageText(`Hello`);

It will automatically find the last message in chat and change it to 'Hello'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文