From f6a0c63846eb8e98c33a2406a3244c717d762f72 Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Wed, 10 Apr 2024 15:19:09 +0530 Subject: [PATCH] =?UTF-8?q?=E2=8C=A8=EF=B8=8F=20Add=20remaining=20parts=20?= =?UTF-8?q?of=20`InlineKeyboard`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../televerse/markups/inline_keyboard.dart | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/lib/src/televerse/markups/inline_keyboard.dart b/lib/src/televerse/markups/inline_keyboard.dart index 0fc91fc3..09aaceff 100644 --- a/lib/src/televerse/markups/inline_keyboard.dart +++ b/lib/src/televerse/markups/inline_keyboard.dart @@ -104,4 +104,106 @@ class InlineKeyboard extends InlineKeyboardMarkup { ); return this; } + + /// Adds a button withgiven [text] and login url ([url]) + InlineKeyboard addLogin( + String text, + String url, { + String? forwardText, + String? botUsername, + bool? requestWriteAccess, + }) { + inlineKeyboard.last.add( + InlineKeyboardButton( + text: text, + loginUrl: LoginURL( + url: url, + forwardText: forwardText, + botUsername: botUsername, + requestWriteAccess: requestWriteAccess, + ), + ), + ); + return this; + } + + /// Adds a button with the given [text] label when tapped prompts user to prompt the user to select one of their chats, open that chat and insert the bot's username and the specified inline [query] in the input field + InlineKeyboard switchInlineQuery( + String text, [ + String query = "", + ]) { + inlineKeyboard.last.add( + InlineKeyboardButton( + text: text, + switchInlineQuery: query, + ), + ); + return this; + } + + /// Adds a button with the given [text] label when tapped the button will insert the bot's username and the specified inline [query] in the current chat's input field. + InlineKeyboard switchInlineQueryCurrentChat( + String text, [ + String query = "", + ]) { + inlineKeyboard.last.add( + InlineKeyboardButton( + text: text, + switchInlineQueryCurrentChat: query, + ), + ); + return this; + } + + /// Adds a button with the given [text] label when tapped the button will prompt the user to select one of their chats of the specified type, open that chat and insert the bot's username and the specified inline query in the input field. + InlineKeyboard switchInlineQueryChosenChat( + String text, { + String query = "", + bool? allowUserChats, + bool? allowBotChats, + bool? allowGroupChats, + bool? allowChannelChats, + }) { + inlineKeyboard.last.add( + InlineKeyboardButton( + text: text, + switchInlineQueryChosenChat: SwitchInlineQueryChosenChat( + query: query, + allowUserChats: allowUserChats, + allowBotChats: allowBotChats, + allowGroupChats: allowGroupChats, + allowChannelChats: allowChannelChats, + ), + ), + ); + return this; + } + + /// Adds a callback game button to the keyboard + InlineKeyboard game( + String text, { + CallbackGame game = const CallbackGame(), + }) { + inlineKeyboard.last.add( + InlineKeyboardButton( + text: text, + callbackGame: game, + ), + ); + return this; + } + + /// Adds a [Pay Button](https://core.telegram.org/bots/api#payments) to the keyboard + InlineKeyboard pay( + String text, { + bool pay = true, + }) { + inlineKeyboard.last.add( + InlineKeyboardButton( + text: text, + pay: pay, + ), + ); + return this; + } }