FedericoBruzzone / tdlib-rs

Rust wrapper around the Telegram Database Library 🦀
https://crates.io/crates/tdlib-rs
Apache License 2.0
37 stars 7 forks source link

What message should be sent when the user clicks the button in the reply markup message ? #9

Closed NPCDW closed 1 month ago

NPCDW commented 1 month ago

Here is a screenshot of the message and the json content of the message

image

{
    "total_count": 1,
    "messages": [
        {
            "id": 1527775232,
            "sender_id": {
                "@type": "messageSenderUser",
                "user_id": 7494461821
            },
            ......
            "content": {
                "@type": "messageText",
                "text": {
                    "text": "🤖V2board机器人\n\n欢迎使用一元机场,您可通过向此bot发送消息,客服将会收到您的反馈并通过此回复。",
                    "entities": []
                },
                "web_page": null,
                "link_preview_options": null
            },
            "reply_markup": {
                "@type": "replyMarkupInlineKeyboard",
                "rows": [
                    [
                        {
                            "text": "💍绑定账户",
                            "type": {
                                "@type": "inlineKeyboardButtonTypeCallback",
                                "data": "YmluZD1iaW5k"
                            }
                        },
                        {
                            "text": "🪖解绑账户",
                            "type": {
                                "@type": "inlineKeyboardButtonTypeCallback",
                                "data": "dW5iaW5kPXVuYmluZA=="
                            }
                        }
                    ],
                    [
                        {
                            "text": "🎉签到",
                            "type": {
                                "@type": "inlineKeyboardButtonTypeCallback",
                                "data": "Y2hlY2tpbj1jaGVja2lu"
                            }
                        },
                        {
                            "text": "🧑‍🍼个人信息",
                            "type": {
                                "@type": "inlineKeyboardButtonTypeCallback",
                                "data": "YWNjb3VudD1hY2NvdW50"
                            }
                        },
                        {
                            "text": "💁我的邀请",
                            "type": {
                                "@type": "inlineKeyboardButtonTypeCallback",
                                "data": "aW52aXRlPWludml0ZQ=="
                            }
                        }
                    ],
                    [
                        {
                            "text": "🛒商店",
                            "type": {
                                "@type": "inlineKeyboardButtonTypeCallback",
                                "data": "c2hvcD1zaG9w"
                            }
                        },
                        {
                            "text": "🌐前往官网",
                            "type": {
                                "@type": "inlineKeyboardButtonTypeUrl",
                                "url": "https://1vpn.sbs/"
                            }
                        },
                        {
                            "text": "💞加入TG群",
                            "type": {
                                "@type": "inlineKeyboardButtonTypeUrl",
                                "url": "https://t.me/oneyuanvpn"
                            }
                        }
                    ]
                ]
            }
        }
    ]
}

What message should be sent when the user clicks the button in the reply markup message ?

image

FedericoBruzzone commented 1 month ago

Thank you for your question.

Shouldn't it depend on the button itself? Or rather, on the action you want to do when a button is pressed?

NPCDW commented 1 month ago

Thanks for the quick response!

For example, after clicking on the "🧑‍🍼 个人信息" button, which function in functions:: should I execute, I didn't find that method for the interaction

FedericoBruzzone commented 1 month ago

Pleasure.

However, there are no existing functions for all cases. What you need to do is to capture the event and then handle the event with your bot logic and send the result on the chat.

I hope I have explained myself :D

NPCDW commented 1 month ago

Sorry I didn't express myself clearly.

this bot is someone else's, what I want to make is a telegram client and use your tdlib-rs-1.0.5 library, when the user clicks the button, which method of tdlib should I call to send the event triggered by the user

Andreal2000 commented 1 month ago

Hi,

If i understand clearly, you need to periodically check the messages in that chat and do something when apper a message generated by the user when clicking a button

NPCDW commented 1 month ago

you need to periodically check the messages in that chat and do something when apper a message generated by the user when clicking a button

I am making a telegram client, similar to trelegram x, not a bot backend. So after the user clicks the button, what should I do, what kind of messages should I send to the server, what methods should I call, in tdlib-rs

Andreal2000 commented 1 month ago

Sorry for my misunderstanding.

After some research i think this is the function that you need to use.

I'm not complitily sure because i never studied the whole tdlib and in particular the Inline Keyboards are a topic never encounter.

During my research I found this link useful, maybe it can be useful for you too.

I hope that this function will solve your problem.

NPCDW commented 1 month ago

@Andreal2000 Thank you very much for your answer, it is correct. It solved my problem, the get_callback_query_answer method does operate Inline Keyboards