From 97fea333f7b59056be243ae5835746b017cf784b Mon Sep 17 00:00:00 2001 From: FlorianDahn Date: Tue, 3 Nov 2020 20:38:36 +0100 Subject: [PATCH] Update ConfirmDialog.cs - adding additional checks to ConfirmDialog - adding AutoCloseOnClick property, to close this modal form after button click --- TelegramBotBase/Form/ConfirmDialog.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/TelegramBotBase/Form/ConfirmDialog.cs b/TelegramBotBase/Form/ConfirmDialog.cs index 6a3013f..a5ce824 100644 --- a/TelegramBotBase/Form/ConfirmDialog.cs +++ b/TelegramBotBase/Form/ConfirmDialog.cs @@ -15,6 +15,11 @@ namespace TelegramBotBase.Form { public String Message { get; set; } + /// + /// Automatically close form on button click + /// + public bool AutoCloseOnClick { get; set; } = true; + public List Buttons { get; set; } private EventHandlerList __Events { get; set; } = new EventHandlerList(); @@ -49,6 +54,12 @@ namespace TelegramBotBase.Form public override async Task Action(MessageResult message) { + if (message.Handled) + return; + + if (!message.IsFirstHandler) + return; + var call = message.GetData(); if (call == null) return; @@ -67,6 +78,9 @@ namespace TelegramBotBase.Form } OnButtonClicked(new ButtonClickedEventArgs(button)); + + if (AutoCloseOnClick) + await CloseForm(); }