tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

Unable to call the shareChatWithBot method #2572

Closed abbb closed 1 year ago

abbb commented 1 year ago

I run it with all necessary parameters from td_api.tl after getting messageChatShared, but I get Error: (400, 'The method is not available to bots')

This is the method for adding a bot to groups, how can it not be available to bots?

levlam commented 1 year ago

Bots can't write to other bots and they can't join groups by themselves, hence they definitely can't use shareChatWithBot.

abbb commented 1 year ago

Look at td_api.tl (master), line 1576:

//@description A button that requests a chat to be shared by the current user; available only in private chats. Use the method shareChatWithBot to complete the request
...
keyboardButtonTypeRequestChat ...

Why is it phrased that way?

PS: Overall solved. Setting parameters for keyboardButtonTypeRequestChat turned out to be quite a challenge, in case of omission of parameters user_administrator_rights and bot_administrator_rights the button appears, allows to select a chat, after selection even a notification about successful addition appears, but the actual addition does not happen. Taking into account this fact, as well as the text from the comment, it seems that it is necessary to run the shareChatWithBot method.

levlam commented 1 year ago

Why is it phrased that way?

Because TDLib documentation is for app developers and regular users. When a user receives the button, it can use the method shareChatWithBot to process the button. Bot API documentation can be found at https://core.telegram.org/bots/api.

03-HM commented 1 year ago

De