ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Ruby를 사용하여 Telegram 봇 메시지를 편집 하시겠습니까?
    카테고리 없음 2020. 8. 16. 14:39

    질문

    인라인 키보드를 print하는 Ruby Wrapper 로 구축 된 텔레그램 봇이 있습니다. 사용자 입력을 요청하는 메시지.

    그러나 사용자가 옵션을 클릭하면 메시지를 새 메시지로 바꾸고 싶습니다.

        bot.api.edit_message_text(chat_id: message.from.id, 
            message_id: message.message_id,
            text: "What would you like Athena to do?",
            reply_markup: tasks_keyboard()
            )

    위 코드에서 다음 오류가 발생합니다.

    C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/telegram-bot-ruby-0.8.6.1/lib/telegram/bot/api.rb:76:in `call': Telegram API has returned the error. (ok: "false", error_code: "400", description: "Bad Request: message to edit not found") (Telegram::Bot::Exceptions::ResponseError)

    이것은 전체 코드입니다.

       Telegram::Bot::Client.run(token) do |bot|
      bot.listen do |message|
        case message
        when Telegram::Bot::Types::CallbackQuery
          case message.data
            bot.api.edit_message_text(chat_id: message.from.id, 
                message_id: message.id,
                text: "What would you like Athena to do?",
                reply_markup: tasks_keyboard()
                )

    편집할 이전 메시지를 어떻게 참조 (ID 가져오기)합니까?

     

    답변1

    message_id: message.message.message_id

    다음 message.id 를 가져 왔습니다. 여기에 rel = "nofollow noreferrer"> 스레드 가 있습니다.



     

     

     

     

    출처 : https://stackoverflow.com/questions/48559078/editing-telegram-bot-messages-using-ruby

    댓글

Designed by Tistory.