using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data.SqlClient; using System.Linq; using SvetoforVKBot.Models.Updates; using VkNet; using VkNet.Enums.SafetyEnums; using VkNet.Model.Keyboard; using VkNet.Model.RequestParams; namespace SvetoforVKBot.Models.Commands { public class SelectAboutCommand : Command { public override string Name => "{\"button\":\"selectAbout\"}"; public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db) { } public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db) { var chatId = update.@object.message.from_id; MessagesSendParams @params = new MessagesSendParams(); var keyboardBuilder = new KeyboardBuilder().Clear(); var listButtons = new List>(); try { var user = db.Users.Single(usr => usr.chatId == chatId); int reg = user.reg; @params.Message = "✒Росмолодежь — федеральный орган исполнительной власти, деятельность которого целиком сосредоточена на создании равных условий для самореализации нашего подрастающего поколения.\n\n" + "Задача Росмолодежи сегодня состоит в создании максимального количества возможностей для самореализации молодых людей и, как следствие, эффективной реализации инновационного потенциала молодежи в обществе."; Uri URL = new Uri("https://fadm.gov.ru/"); #region keyboard var row = new List() { new MessageKeyboardButton() { Action = new MessageKeyboardButtonAction(){ Type = KeyboardButtonActionType.OpenLink, Link = URL, Label = "Официальный сайт", Payload = "{\"button\":\"selectOpenLink\"}" }, } }; listButtons.Add(new ReadOnlyCollection(row)); if (reg == 0) { var row1 = new List() { new MessageKeyboardButton() { Action = new MessageKeyboardButtonAction(){ Label = "#ХочуВРосМол", Payload = "{\"button\":\"selectRegistration\"}", Type = KeyboardButtonActionType.Text}, Color = KeyboardButtonColor.Positive }, }; listButtons.Add(new ReadOnlyCollection(row1)); } var row3 = new List() { new MessageKeyboardButton() { Action = new MessageKeyboardButtonAction(){ Label = "⬅Назад", Payload = "{\"button\":\"startPL\"}", Type = KeyboardButtonActionType.Text}, Color = KeyboardButtonColor.Default } }; listButtons.Add(new ReadOnlyCollection(row3)); var buttons = new ReadOnlyCollection>(listButtons); var keyboard = new MessageKeyboard() { Buttons = buttons, OneTime = false }; #endregion keyboard @params.Keyboard = keyboard; @params.UserId = chatId; @params.RandomId = GetRandomId(); client.Messages.SendAsync(@params); } catch (Exception ee) { @params.Message = "Ошибка в SelectAboutCommand: " + ee.Message; @params.Attachments = null; @params.Keyboard = null; @params.UserId = 59111081; @params.RandomId = GetRandomId(); client.Messages.SendAsync(@params); } } } }