Giter Site home page Giter Site logo

canSendData not working about vue-telegram HOT 10 CLOSED

deptyped avatar deptyped commented on August 20, 2024
canSendData not working

from vue-telegram.

Comments (10)

johnedstone avatar johnedstone commented on August 20, 2024 1

Okay thanks .... I need to reread the docs. You've cleared some things up for me. Thanks again. I think that you can close this issue..

from vue-telegram.

deptyped avatar deptyped commented on August 20, 2024

This is a Telegram limitation, you can only use Telegram.WebApp.sendData if the web app was launched from custom keyboard:
https://core.telegram.org/bots/webapps#keyboard-button-mini-apps
Telegram.WebApp.initData === "" is the way to check this.

from vue-telegram.

johnedstone avatar johnedstone commented on August 20, 2024

I did in fact launch it from a Keyboard Button Mini Apps launched from a web_app type keyboard button can send data back to the bot in a service message....To transmit data from the user back to the bot, the Mini App can call the Telegram.WebApp.sendData method) which is the only way that allows for Telegram.WebApp.sendData with the following code from the telethon library:

async def web_app_button(event):
        bl = types.ReplyInlineMarkup([
            types.TypeKeyboardButtonRow([
                types.KeyboardButtonWebView('Test!', WEB_URL),
            ])])

        await event.respond("Open URL below", buttons=bl)

Shouldn't you be checking that there is, in fact, a string in Telegram.WebApp.initData?

from vue-telegram.

deptyped avatar deptyped commented on August 20, 2024

types.ReplyInlineMarkup

As I can see you are using inline keyboard, this is a different type of keyboard and it does not support Telegram.WebApp.sendData.
You need to use types.ReplyKeyboardMarkup to send custom keyboard.

from vue-telegram.

johnedstone avatar johnedstone commented on August 20, 2024

from vue-telegram.

deptyped avatar deptyped commented on August 20, 2024

This limitation is documented in the description of the sendData method:

IMG_20240519.jpg

https://core.telegram.org/bots/webapps#initializing-mini-apps

from vue-telegram.

johnedstone avatar johnedstone commented on August 20, 2024

from vue-telegram.

johnedstone avatar johnedstone commented on August 20, 2024

... yes, I've mixed up the two ... thank you.... if I continue to use the inline button, did you implement Bot API method answerWebAppQuery that can be used with an inline button?

from vue-telegram.

deptyped avatar deptyped commented on August 20, 2024

answerWebAppQuery is part of the Bot API and vue-tg is not a Bot API library, so you need some Bot API library like aiogram to use this method:
https://docs.aiogram.dev/en/dev-3.x/api/methods/answer_web_app_query.html

List of libraries for Python to work with Bot API:
https://core.telegram.org/bots/samples#python

from vue-telegram.

deptyped avatar deptyped commented on August 20, 2024

But if you are looking for a way to pass data from web app to bot, answerWebAppQuery method is not what you need.
For non-replykeyboard web apps, you need to send a POST request to server to transfer data, just like in a normal (non-Telegram) web app.

from vue-telegram.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.