电报机器人菜单按钮

电报机器人可以选择显示在文本输入字段旁边的菜单按钮的行为。

有关使用 HTTP 机器人 API 的简化说明,请参见此处 »。

设置菜单按钮

模式:

botMenuButtonDefault#7533a588 = BotMenuButton; botMenuButtonCommands#4258c205 = BotMenuButton; botMenuButton#c7b57ce6 text:string url:string = BotMenuButton;inputUserEmpty#b98886cf = InputUser; inputUser#f21158c6 user_id:long access_hash:long = InputUser;---functions---bots.setBotMenuButton#4504d54f user_id:InputUser button:BotMenuButton = Bool;

机器人可以使用bots.setBotMenuButton来更改特定用户或所有用户的菜单按钮。

设置范围:所有用户

要更改所有用户的菜单按钮,请使用以下参数:

不应该使用botMenuButtonDefault,因为它没有效果,会保留先前设置的菜单按钮(botMenuButton或botMenuButtonCommands)。

设置范围:特定用户

要更改特定用户的菜单按钮,请使用以下参数:

获取菜单按钮

机器人

botMenuButtonDefault#7533a588 = BotMenuButton; botMenuButtonCommands#4258c205 = BotMenuButton; botMenuButton#c7b57ce6 text:string url:string = BotMenuButton;inputUserEmpty#b98886cf = InputUser; inputUser#f21158c6 user_id:long access_hash:long = InputUser;---functions---bots.getBotMenuButton#9c60eb28 user_id:InputUser = BotMenuButton;

机器人可能需要知道给定聊天或所有聊天中当前使用的按钮类型:可以使用bots.getBotMenuButton来实现这一点。

用户无法使用此方法,而应改用用户方法。

获取范围:所有用户

要获取所有用户使用的菜单按钮,请使用以下参数:

将返回以下构造函数之一:

在这种情况下, botMenuButtonDefault将永远不会返回。

获取范围:特定用户

要获取特定用户使用的菜单按钮,请使用以下参数:

将返回以下构造函数之一:

用户

updateBotMenuButton#14b85813 bot_id:long button:BotMenuButton = Update;botMenuButtonCommands#4258c205 = BotMenuButton; botMenuButton#c7b57ce6 text:string url:string = BotMenuButton;botInfo#4d8a0299 flags:# has_preview_medias:flags.6?true user_id:flags.0?long description:flags.1?string description_photo:flags.4?Photo description_document:flags.5?Document commands:flags.2?Vector<BotCommand> menu_button:flags.3?BotMenuButton privacy_policy_url:flags.7?string app_settings:flags.8?BotAppSettings verifier_settings:flags.9?BotVerifierSettings = BotInfo;userFull#c577b5ad flags:# blocked:flags.0?true phone_calls_available:flags.4?true phone_calls_private:flags.5?true can_pin_message:flags.7?true has_scheduled:flags.12?true video_calls_available:flags.13?true voice_messages_forbidden:flags.20?true translations_disabled:flags.23?true stories_pinned_available:flags.26?true blocked_my_stories_from:flags.27?true wallpaper_overridden:flags.28?true contact_require_premium:flags.29?true read_dates_private:flags.30?true flags2:# sponsored_enabled:flags2.7?true can_view_revenue:flags2.9?true bot_can_manage_emoji_status:flags2.10?true display_gifts_button:flags2.16?true id:long about:flags.1?string settings:PeerSettings personal_photo:flags.21?Photo profile_photo:flags.2?Photo fallback_photo:flags.22?Photo notify_settings:PeerNotifySettings bot_info:flags.3?BotInfo pinned_msg_id:flags.6?int common_chats_count:int folder_id:flags.11?int ttl_period:flags.14?int theme:flags.15?ChatTheme private_forward_name:flags.16?string bot_group_admin_rights:flags.17?ChatAdminRights bot_broadcast_admin_rights:flags.18?ChatAdminRights wallpaper:flags.24?WallPaper stories:flags.25?PeerStories business_work_hours:flags2.0?BusinessWorkHours business_location:flags2.1?BusinessLocation business_greeting_message:flags2.2?BusinessGreetingMessage business_away_message:flags2.3?BusinessAwayMessage business_intro:flags2.4?BusinessIntro birthday:flags2.5?Birthday personal_channel_id:flags2.6?long personal_channel_message:flags2.6?int stargifts_count:flags2.8?int starref_program:flags2.11?StarRefProgram bot_verification:flags2.12?BotVerification send_paid_messages_stars:flags2.14?long disallowed_gifts:flags2.15?DisallowedGiftsSettings stars_rating:flags2.17?StarsRating stars_my_pending_rating:flags2.18?StarsRating stars_my_pending_rating_date:flags2.18?int main_tab:flags2.20?ProfileTab saved_music:flags2.21?Document = UserFull;---functions---users.getFullUser#b60f5918 id:InputUser = users.UserFull;

当机器人全局更改菜单按钮的行为或在与用户的私聊中更改菜单按钮的行为时,用户将收到updateBotMenuButton更新。

对于新机器人,可以使用users.getFullUser获取与机器人相关的userFull ,其中包含botInfo构造函数,该构造函数包含有关机器人的各种信息,包括菜单按钮的行为。

botMenuButtonDefault永远不会在updateBotMenuButton或botInfo中返回(但如果确实发生了,请将其视为botMenuButtonCommands)。

机器人应该改用机器人方法。