Closed bretbas closed 1 year ago
Which kind of keyboard are you using ? The answer depends on it. If using the ButtonGrid control it does manage everything for you.
But i want to handle this pressing in the Action method. How can i to do that?
Which kind of Keyboard are you using ? The Reply one or the Inline one? You have to use the InlineReplyKeboard to get the Action method invoked. Check Readme and Telegram documentaion.
Ok, but i need Reply keyboard. I try this:
public class StartForm : AutoCleanForm
{
public StartForm()
{
Init += OnInit;
}
private async Task OnInit(object sender, InitEventArgs ev)
{
var btn = new ButtonForm();
btn.AddButtonRow(new ButtonBase(KeyboardButtons.SearchTrips, Commands.SearchTrips));
btn.AddButtonRow(new ButtonBase(KeyboardButtons.SetFilters, Commands.SetFilters));
btn.AddButtonRow(new ButtonBase(KeyboardButtons.CreateTrip, Commands.CreateTrip));
var grid = new ButtonGrid(btn)
{
KeyboardType = TelegramBotBase.Enums.eKeyboardType.ReplyKeyboard,
Enabled = true,
HideKeyboardOnCleanup = true,
ResizeKeyboard = true
};
grid.ButtonClicked += async (s, e) =>
{
FormBase form = e.Button.Value switch
{
Commands.SearchTrips => new SearchTripsForm(),
Commands.SetFilters => new SetFiltersForm(),
Commands.CreateTrip => new CreateTripForm()
};
await NavigateTo(form);
};
AddControl(grid);
}
}
The main reason, why it didnt worked in the first place was that ReplyKeyboard does only send "Text" back. So like a normal chat message. Thats why the Action method did not get invoked.
How can i handle message when press on keyboard button?