koishijs / koishi

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

Bug: Telegram 适配器,无法获取 web_app_data 的数据 #1107

Closed Ice-Hazymoon closed 1 year ago

Ice-Hazymoon commented 1 year ago

Describe the bug

举个例子,在 Telegraf 中可以这样实现接收 web_app_data 数据

const { Telegraf, Markup } = require("telegraf");

const bot = new Telegraf("bot token");

bot.command("register", (ctx) => {
  return ctx.reply(
    "open webapp",
    Markup.keyboard([
      Markup.button.webApp(
        "Open",
        "https://uture-tg-web.imiku.me/"
      ),
    ])
  );
});
bot.on("message", async (ctx) => {
  console.log(ctx.message.web_app_data)
  return ctx.reply(ctx.message.web_app_data.data)
});

bot.launch();

但是在 koishi 中不知道该怎样获取这些数据,session 是否有某个字段可以获取收到的原始数据

image

telegram 文档:https://core.telegram.org/bots/webapps#initializing-web-apps

Steps to reproduce

如题

Expected behavior

如题

Screenshots

No response

Versions

"koishi": "^4.12.9",

Additional context

No response

Anillc commented 1 year ago

session.telegram 上有你想要的属性,需要你先导入一下适配器的类型

import {} from 'koishi-plugin-adapter-telegram'
Ice-Hazymoon commented 1 year ago

session.telegram 上有你想要的属性,需要你先导入一下适配器的类型

import {} from 'koishi-plugin-adapter-telegram'

谢谢