Esempio n. 1
0
        public void LoadKeyboards(BaseChat chat)
        {
            //клавиатура с наивысшим приоритетом, коорая обновляется при каждой отправке сообщения ботом
            var keyboard = chat.BaseKeyboard = new Keyboard(null)
            {
                Id = "main_keyboard"
            };

            keyboard.Add(new KeyboardTextButton("Menu", (c, u, b, p) => c.SendKeyboardAsync("menu")));

            //вспомогательное меню с привязкой по Id
            var childKeyboard = new Keyboard("Menu opened")
            {
                Id = "menu", InMessage = true
            };

            childKeyboard.Add(new KeyboardTextButton("Test1", (c, u, b, p) => c.SendMessageAsync("test1!"))
            {
                Color = ButtonColor.Red
            });
            childKeyboard.Add(new KeyboardTextButton("Test2", (c, u, b, p) => c.SendMessageAsync("test2!"))
            {
                Color = ButtonColor.Red
            });
            chat.AddKeyboard(childKeyboard);

            //обработчик стандартной кнопки Начать
            chat.AddKeyboard(new StartKeyboard((c, u, b, p) => c.SendMessageAsync("start")));
        }
Esempio n. 2
0
        private static void UITest4(CommandContext context)
        {
            if (context.Sender.IsAppAdmin)
            {
                var k = new Keyboard("test")
                {
                    InMessage = true
                };
                k.Add(new KeyboardCallbackButton("Action void", (c, u, kb, p) => Console.WriteLine("action answer")));

                k.Add(new KeyboardCallbackButton("Snackbar", (c, u, kb, p) => new EventData()
                {
                    Type = MessageEventType.SnowSnackbar,
                    Text = "Snackbar answer"
                }));

                k.Add(new KeyboardCallbackButton("Link", (c, u, kb, p) =>
                                                 new EventData()
                {
                    Type = MessageEventType.OpenLink,
                    Link = new Uri("https://github.com/DarkLexFirst/vkBotCore")
                }));
                context.Chat.SendKeyboardAsync(k);
            }
        }
Esempio n. 3
0
 private static void VkPayTest(CommandContext context)
 {
     if (context.Sender.IsAppAdmin)
     {
         var k = new Keyboard("vk pay ptg test")
         {
             InMessage = true
         };
         k.Add(new KeyboardVkPayButton(new VkPay(VkPayAction.Pay, VkPayTarget.Group, context.Chat.VkApi.GroupId, 10)));
         context.Chat.SendKeyboardAsync(k);
         k = new Keyboard("vk pay gt test")
         {
             InMessage = true
         };
         k.Add(new KeyboardVkPayButton(new VkPay(VkPayAction.Transfer, VkPayTarget.Group, context.Chat.VkApi.GroupId)));
         context.Chat.SendKeyboardAsync(k);
         k = new Keyboard("vk pay ptu test")
         {
             InMessage = true
         };
         k.Add(new KeyboardVkPayButton(new VkPay(VkPayAction.Pay, VkPayTarget.User, context.Sender.Id, 10)));
         context.Chat.SendKeyboardAsync(k);
         k = new Keyboard("vk pay ut test")
         {
             InMessage = true
         };
         k.Add(new KeyboardVkPayButton(new VkPay(VkPayAction.Transfer, VkPayTarget.User, context.Sender.Id)));
         context.Chat.SendKeyboardAsync(k);
     }
 }
Esempio n. 4
0
 private static void UITest3(CommandContext context)
 {
     if (context.Sender.IsAppAdmin)
     {
         var k = new Keyboard("test")
         {
             InMessage = true
         };
         k.Add(new KeyboardTextButton("test button 1", "test_named_button")
         {
             Color = ButtonColor.Red
         });
         k.Add(new KeyboardLinkButton("Click me", "https://github.com/DarkLexFirst/vkBotCore"));
         context.Chat.SendKeyboardAsync(k);
     }
 }
Esempio n. 5
0
 private static void UITest2(CommandContext context)
 {
     if (context.Sender.IsAppAdmin)
     {
         var k = new Keyboard("test");
         k.Add(new KeyboardTextButton("test button 1", (c, u, b, p) => c.SendMessageAsync("Used by " + u.GetMentionLine()))
         {
             Color = ButtonColor.Green
         });
         context.Chat.SendKeyboardAsync(k);
     }
 }
Esempio n. 6
0
        static void Solve(string[] args)
        {
            using (var rdr = new StreamReader("input.txt"))
            {
                var keyboardSize = rdr.ReadLine().Split(new[] { ' ' }).Select(x => int.Parse(x)).ToArray();

                var width  = keyboardSize[0];
                var height = keyboardSize[1];

                var keyboard = new Keyboard();

                for (int row = 0; row < height; row++)
                {
                    var l = rdr.ReadLine();
                    for (int col = 0; col < width; col++)
                    {
                        keyboard.Add(l[col], new Position(row, col));
                    }
                }

                var templates = new List <Template>();
                var template  = ReadTemplate(rdr, keyboard);
                while (template != null)
                {
                    templates.Add(template);
                    template = ReadTemplate(rdr, keyboard);
                }

                var min          = templates.Min(x => x.Distance);
                var bestTemplate = templates.First(x => x.Distance == min);

                var result = string.Format("{0}{1}{2}", bestTemplate.Name, Environment.NewLine, bestTemplate.Distance);
                File.WriteAllText("output.txt", result);

                //Console.WriteLine(result);
                //Console.ReadLine();
            }
        }