From c6d5037700d26194b6ac6d70f42c95dac972e741 Mon Sep 17 00:00:00 2001 From: Florian Zevedei Date: Sat, 3 Feb 2024 01:40:07 +0100 Subject: [PATCH] Adding demo for too long callback data --- .../ExternalActionManager/DemoBot/Program.cs | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Experiments/ExternalActionManager/DemoBot/Program.cs b/Experiments/ExternalActionManager/DemoBot/Program.cs index a4f406a..199ecff 100644 --- a/Experiments/ExternalActionManager/DemoBot/Program.cs +++ b/Experiments/ExternalActionManager/DemoBot/Program.cs @@ -8,6 +8,7 @@ using TelegramBotBase.Base; using TelegramBotBase.Experiments.ActionManager; using TelegramBotBase.Experiments.ActionManager.Actions; using TelegramBotBase.Experiments.ActionManager.Navigation; +using Telegram.Bot.Types; namespace DemoBot { @@ -136,6 +137,14 @@ namespace DemoBot await update.Device.ConfirmAction(message.UpdateData.CallbackQuery.Id, "Confirmed!"); }); + + config.AddGuidAction("guid.test.too.long", async (g, c, u, m) => + { + if (m.UpdateData.CallbackQuery == null) + return; + + await u.Device.ConfirmAction(m.UpdateData.CallbackQuery.Id, "Confirmed!"); + }); }); @@ -148,7 +157,7 @@ namespace DemoBot { a.Start("Starts the bot"); a.Add("test", "Sends a test notification"); - + a.Add("invalid", "Try to send an invalid data message"); }) .NoSerialization() @@ -273,6 +282,23 @@ namespace DemoBot break; + case "/invalid": + + Guid g = Guid.NewGuid(); + + var tb2 = new TelegramBotClient(Token); + + var bf2 = new ButtonForm(); + + bf2.AddButtonRow("Test test", GuidAction.GetCallback("guid.test.too.long", g).Serialize(true)); + + String message2 = "This is an invalid test message."; + + await tb2.SendTextMessageAsync(e.DeviceId, message2, disableNotification: true, replyMarkup: (InlineKeyboardMarkup)bf2); + + + break; + }