From 388a107a1070e91beb7a6b6fd46d64f55684809f Mon Sep 17 00:00:00 2001 From: Nikolay Matyushin Date: Tue, 6 Feb 2024 10:02:33 +0300 Subject: [PATCH] Add Markdown check to testbot --- .../Funogram.TestBot/Commands/Base.fs | 20 ++++++++++++++++--- .../Funogram.TestBot/Commands/Markup.fs | 3 ++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/examples/Funogram.TestBot/Commands/Base.fs b/src/examples/Funogram.TestBot/Commands/Base.fs index 8ad9732..cf41c45 100644 --- a/src/examples/Funogram.TestBot/Commands/Base.fs +++ b/src/examples/Funogram.TestBot/Commands/Base.fs @@ -25,9 +25,10 @@ let defaultText = """⭐️Available test commands: /cmdscan stringA stringB - Test cmdScan, concatenate stringA and stringB""" let updateArrived (ctx: UpdateContext) = - let fromId () = ctx.Update.Message.Value.From.Value.Id - let wrap fn = fn ctx.Config (fromId ()) + let wrap fn = + let fromId () = ctx.Update.Message.Value.From.Value.Id + fn ctx.Config (fromId ()) let result = processCommands ctx [| @@ -55,4 +56,17 @@ let updateArrived (ctx: UpdateContext) = |] if result then - Api.sendMessage (fromId()) defaultText |> bot ctx.Config \ No newline at end of file + match ctx.Update.CallbackQuery with + | Some ({ Data = Some "callback2" } as c) -> + match c.Message with + | Some (MaybeInaccessibleMessage.Message msg) -> + let inlineKeyboardMarkup = InlineKeyboardMarkup.Create([| [| InlineKeyboardButton.Create("Changed!", callbackData = "Test") |] |]) + Req.EditMessageReplyMarkup.Make(msg.Chat.Id, msg.MessageId, replyMarkup = inlineKeyboardMarkup) + |> bot ctx.Config + | _ -> () + | _ -> () + + match ctx.Update.Message with + | Some { From = Some { Id = id } } -> + Api.sendMessage id defaultText |> bot ctx.Config + | _ -> () \ No newline at end of file diff --git a/src/examples/Funogram.TestBot/Commands/Markup.fs b/src/examples/Funogram.TestBot/Commands/Markup.fs index 983f45b..9c15229 100644 --- a/src/examples/Funogram.TestBot/Commands/Markup.fs +++ b/src/examples/Funogram.TestBot/Commands/Markup.fs @@ -18,7 +18,8 @@ let testRemoveKeyboard config chatId = let testInlineKeyboard config chatId = let keyboard = [| - [| InlineKeyboardButton.Create("Test", callbackData = "1234") |] + [| InlineKeyboardButton.Create("Test", callbackData = "callback1") |] + [| InlineKeyboardButton.Create("Replace", callbackData = "callback2") |] |] let markup = Markup.InlineKeyboardMarkup { InlineKeyboard = keyboard } sendMessageMarkup "That's inline keyboard!" markup config chatId \ No newline at end of file