koishijs / koishi

Cross-platform chatbot framework made with love
https://koishi.chat
MIT License
4.5k stars 247 forks source link

Feature: Telegram 支持 callback_query 消息,监听用户点击 #1055

Closed Ice-Hazymoon closed 1 year ago

Ice-Hazymoon commented 1 year ago

Describe the problem related to the feature request

image

当前点击按钮后 koishi 无法收到任何相应

Describe the solution you'd like

如题

Describe alternatives you've considered

No response

Additional context

No response

samnyan commented 1 year ago

有的其实,首先

import '@koishijs/plugin-adapter-telegram'

然后就可以在使用

    ctx.on('telegram/callback-query', async (session) => {
      if (session.telegram.callback_query) {
        const callbackQuery = session.telegram.callback_query

        // do something...
        await session.telegram.answerCallbackQuery({
          callback_query_id: callbackQuery.id,
          text:
          show_alert:
          url:
        })
      }
    })

其他还有telegram/inline-query等等事件

Ice-Hazymoon commented 1 year ago

谢谢

MaikoTan commented 1 year ago

有的其实,首先

import '@koishijs/plugin-adapter-telegram'

Well, it should be import {} from '@koishijs/plugin-adapter-telegram' when you need the type only, which could be stripped out by the code bundler.