Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how i can click reply markun button and get the response? #705

Open
zarlicho opened this issue Aug 7, 2024 · 2 comments
Open

how i can click reply markun button and get the response? #705

zarlicho opened this issue Aug 7, 2024 · 2 comments

Comments

@zarlicho
Copy link

zarlicho commented Aug 7, 2024

i have trying button.click like this
client.addEventHandler(async (event) => { if (event.message.buttons != undefined){ console.log(event.message.buttons[1][0].click()) }

and i got this error:

`Promise {
TypeError: Cannot read properties of undefined (reading 'sharePhone')
at MessageButton.click (F:\pythonProject\myProject\client dexter\telbot\node_modules\telegram\tl\custom\messageButton.js:70:19)
at F:\pythonProject\myProject\client dexter\telbot\test.js:36:47
at _dispatchUpdate (F:\pythonProject\myProject\client dexter\telbot\node_modules\telegram\client\updates.js:144:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
}
F:\pythonProject\myProject\client dexter\telbot\node_modules\telegram\tl\custom\messageButton.js:70
async click({ sharePhone = false, shareGeo = [0, 0], password, }) {
^

TypeError: Cannot read properties of undefined (reading 'sharePhone')
at MessageButton.click (F:\pythonProject\myProject\client dexter\telbot\node_modules\telegram\tl\custom\messageButton.js:70:19)
at F:\pythonProject\myProject\client dexter\telbot\test.js:36:47
at _dispatchUpdate (F:\pythonProject\myProject\client dexter\telbot\node_modules\telegram\client\updates.js:144:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)`

@painor
Copy link
Member

painor commented Aug 7, 2024

try .click({})

@MJBlack9000
Copy link

MJBlack9000 commented Aug 27, 2024

You might need to get the callback data from the button, and then just directly send that data to the bot.
For example, if the button's callback data would be "main_menu_button_data", you'd need to send it like so:

const result = await client.invoke(
    new Api.messages.GetBotCallbackAnswer({
      peer: "botusername",
      msgId: <ID of message that has the button>,
      data: Buffer.from("main_menu_button_data"),
    })
  );

I've not ran this command myself, so I don't know if it will work. But I found it in the docs, and it seems like exactly what you'd need to do: https://gram.js.org/tl/messages/GetBotCallbackAnswer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants