Download the PHP package easy-keyboard/fluent-keyboard without Composer
On this page you can find all versions of the php package easy-keyboard/fluent-keyboard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download easy-keyboard/fluent-keyboard
More information about easy-keyboard/fluent-keyboard
Files in easy-keyboard/fluent-keyboard
Package fluent-keyboard
Short Description A fluent keyboard created for MTProto syntax
License MIT
Informations about the package fluent-keyboard
fluent-keyboard
A fluent keyboard created for MTProto syntax
Table of Contents
- Installation
-
Usage
- Defining a Keyboard
- Defining Buttons
-
Bind Buttons to a Keyboard
- By Row
- By Button
- By Coordinates
- As Stack
- KeyboardForceReply and KeyboardHide
- Keyboard Peer Type
- Convert Telegram Keyboard To Fluent Keyboard
Installation
Install the package using composer:
(back to top)
Usage
If you need to create a keyboard you can use the classes provided by this package as a drop-in replacement.
This is best explained with an example:
A ReplyKeyboardMarkup is created by calling the static new()
method on KeyboardMarkup
. After that every field,
like singleUse
, ... add some extras. Buttons can be added by calling
the addButton()
method. We have a detailed look on that later.(note that this keyboard need to convert to array to
readable by your robot so at the end you need to call init()
method)
(back to top)
Defining a Keyboard
You can create a keyboard by calling the static new()
method on its class.
After that you can chain methods to set additional fields that are available in the Bot API. This is done by calling the
placeholder()
method.
(back to top)
Defining Buttons
The Buttons are created in the different way:
This is done the same way for InlineButton
:
(back to top)
Bind Buttons to a Keyboard
The keyboard does not work without any buttons, so you need to pass the buttons to the keyboard. There are a few ways to do this.
By Row
If you need more than one row, call row()
multiple times:
You can add array of callbacks or texts keyboard in another way!
By Button
If you need more than one row, just call the row method without arguments, and continue calling addButton()
:
It's up to you if you define your buttons inline like in these examples or if you'd like to generate a whole row beforehand and
pass the variable to the row()
method.
You can remove the last button by calling remove
method here is an example :
In this example button D will remove from buttons.
By Coordinates
You can add button to each coordinates you want! (Note that coordinates start from 0 just like array indexes.) for example imagine we have this keyboard :
we can add new button with it coordinates(raw and column) by calling addToCoordinates
method.
This methods will add new button in the coordinate that you passed and shift next buttons of the coordinates.
This picture show you the position of new button :
The results should like this image :
You can also replace into specific coordinates unlike addToCoordinates
the replaceIntoCoordinates
method will replace
your new button into passed coordinate for example if we want to replace Add in this example like this picture :
we should use this code :
The result should like this image :
You can also remove the button by it's coordinates for example if we want remove Add button(in last example) we should run this code:
As Stack
If you want to add a bunch of buttons that have each a row for themselves you can use the Stack()
method.
You can mix and match the row()
, Stack()
and addButton()
methods as it fits your needs.
(back to top)
KeyboardForceReply and KeyboardHide
KeyboardForceReply and KeyboardHide can be used the same way as a normal keyboard, but they do not receive any buttons:
(back to top)
Keyboard Peer Type
We have 3 types of peer type can be requested by bots RequestUser , RequestGroup and RequestChannel
You can also use easier syntax to create better one
(back to top)
Convert Telegram Keyboard To Fluent Keyboard
You can now easily convert mtproto telegram keyboards to fluent keyboard for modify and ...
using fromRawReplyMarkup
methods! here is and example
As you know $fluentKeyboard
is object here and you can modify and add more buttons to it.
here is an example if $flunentKeyboard
instance of KeyboardInline
At the end you can call build
method on that and pass to some telegram method here is an
example for MadelineProto :
(back to top)
All versions of fluent-keyboard with dependencies
ext-mbstring Version *