Adding basic example for different types of ConfirmAction

This commit is contained in:
FlorianDahn 2021-08-01 13:50:18 +03:00
parent f021f12486
commit ef8ca3c988
2 changed files with 72 additions and 0 deletions

View File

@ -200,6 +200,13 @@ namespace TelegramBotBaseTest.Tests
break;
case "notifications":
var not = new Notifications.Start();
await NavigateTo(not);
break;
default:
message.Handled = false;
@ -247,6 +254,8 @@ namespace TelegramBotBaseTest.Tests
btn.AddButtonRow(new ButtonBase("#18 Dynamic ButtonGrid (DataSources)", new CallbackData("a", "dynamicbuttongrid").Serialize()));
btn.AddButtonRow(new ButtonBase("#19 Notifications", new CallbackData("a", "notifications").Serialize()));
await this.Device.Send("Choose your test:", btn);
}

View File

@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using TelegramBotBase.Base;
using TelegramBotBase.Form;
namespace TelegramBotBaseTest.Tests.Notifications
{
public class Start : AutoCleanForm
{
bool sent = false;
public Start()
{
this.DeleteMode = TelegramBotBase.Enums.eDeleteMode.OnLeavingForm;
}
public override async Task Action(MessageResult message)
{
if (message.Handled)
return;
switch (message.RawData)
{
case "alert":
await message.ConfirmAction("This is an alert.", true);
break;
case "back":
var mn = new Menu();
await NavigateTo(mn);
break;
default:
await message.ConfirmAction("This is feedback");
break;
}
}
public override async Task Render(MessageResult message)
{
if (sent)
return;
var bf = new ButtonForm();
bf.AddButtonRow("Normal feeback", "normal");
bf.AddButtonRow("Alert Box", "alert");
bf.AddButtonRow("Back", "back");
await Device.Send("Choose your test", bf);
sent = true;
}
}
}