Добавьте файлы проекта.

This commit is contained in:
Daria
2021-10-19 06:04:52 +03:00
parent 6ee25d0f59
commit eab3081ec2
187 changed files with 100839 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
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<ReadOnlyCollection<MessageKeyboardButton>>();
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<MessageKeyboardButton>()
{
new MessageKeyboardButton() {
Action = new MessageKeyboardButtonAction(){
Type = KeyboardButtonActionType.OpenLink,
Link = URL,
Label = "Официальный сайт",
Payload = "{\"button\":\"selectOpenLink\"}"
},
}
};
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row));
if (reg == 0)
{
var row1 = new List<MessageKeyboardButton>()
{
new MessageKeyboardButton() {
Action = new MessageKeyboardButtonAction(){
Label = "#ХочуВРосМол",
Payload = "{\"button\":\"selectRegistration\"}",
Type = KeyboardButtonActionType.Text},
Color = KeyboardButtonColor.Positive
},
};
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row1));
}
var row3 = new List<MessageKeyboardButton>()
{
new MessageKeyboardButton() {
Action = new MessageKeyboardButtonAction(){
Label = "⬅Назад",
Payload = "{\"button\":\"startPL\"}",
Type = KeyboardButtonActionType.Text},
Color = KeyboardButtonColor.Default
}
};
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row3));
var buttons = new ReadOnlyCollection<ReadOnlyCollection<MessageKeyboardButton>>(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);
}
}
}
}