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

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,189 @@
using SvetoforVKBot.Models.Updates;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using VkNet;
using VkNet.Enums.SafetyEnums;
using VkNet.Model.Keyboard;
using VkNet.Model.RequestParams;
using VkNet.Model;
using System.Collections.ObjectModel;
using VkNet.Model.Attachments;
namespace SvetoforVKBot.Models.Commands.Admin
{
public class SelectAdminCommand : Command
{
private const int ADMIN1 = 59111081;
private const int ADMIN2 = 369217524;
private const int ADMIN3 = 10160301;
public override string Name => "{\"button\":\"selectAdminMenu\"}";
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
{
}
public override void ExecutePL(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
{
MessagesSendParams @params = new MessagesSendParams();
var chatId = update.@object.message.from_id;
SalesFunnel salesFunnel = new SalesFunnel();
//var keyboardBuilder = new KeyboardBuilder().Clear();
var listButtons = new List<ReadOnlyCollection<MessageKeyboardButton>>();
try
{
if (update.@object.message.from_id == ADMIN1 || update.@object.message.from_id == ADMIN2 || update.@object.message.from_id == ADMIN3 || update.@object.message.from_id == 178385801)
{
//List<MediaAttachment> listVideo = new List<MediaAttachment>()
//{
// new VkNet.Model.Attachments.Video() { Id = 456239343, OwnerId = 59111081, AccessKey = "5530abb97b1da2077b" }
//};
//@params.Attachments = listVideo;
Uri URL = new Uri("https://docs.google.com/spreadsheets/d/1nWHvWufxDy6g2ZJtqd4K8MDM6Gh8OHWasRGXIyqbT2k/");
Uri URLSHEET_ALL = new Uri("https://docs.google.com/spreadsheets/d/1jr68NfIrlz2bVsN-HZg0Kv2sSJ82J5G-EbtXl-YMK44/");
Uri URLDOC = new Uri("https://docs.google.com/document/d/1DQcBuS9g6KYphJZRdcc-tdqgQ_oSvV2PsZt3U-pO_oo/");
Uri URLDIALOGS = new Uri("https://vk.com/gim194717824");
/*
if (admin == 1)
{
keyboardBuilder
.AddButton("📅Каталог мероприятий", "selectEvents-0-1", KeyboardButtonColor.Primary)
.AddLine()
.AddButton("➕Добавить мероприятие", "Добавить мероприятие", KeyboardButtonColor.Default)
.AddLine()
.AddButton("Создать рассылку", "Создать рассылку", KeyboardButtonColor.Default)
.AddLine()
.AddButton("Статистика", "Статистика", KeyboardButtonColor.Default)
.AddButton("Обращения", "Обращения", KeyboardButtonColor.Default);
@params.Message = "Режим администратора. Выберите интересующее действие👇🏻";
@params.Keyboard = keyboardBuilder.Build();
@params.UserId = chatId;
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
return;
}
*/
//keyboardBuilder.AddButton("Открыть таблицу", URL, "open_link");
var row = new List<MessageKeyboardButton>()
{
new MessageKeyboardButton() {
Action = new MessageKeyboardButtonAction(){
Type = KeyboardButtonActionType.OpenLink,
Link = URL,
Label = "Заявки на консультацию",
Payload = "{\"button\":\"selectOpenSheet\"}"
},
}
};
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row));
var row1 = new List<MessageKeyboardButton>()
{
new MessageKeyboardButton() {
Action = new MessageKeyboardButtonAction(){
Type = KeyboardButtonActionType.OpenLink,
Link = URLSHEET_ALL,
Label = "Все участники",
Payload = "{\"button\":\"selectOpenSheet\"}"
},
}
};
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row1));
row1 = new List<MessageKeyboardButton>()
{
new MessageKeyboardButton() {
Action = new MessageKeyboardButtonAction(){
Type = KeyboardButtonActionType.OpenLink,
Link = URLDIALOGS,
Label = "Перейти в диалоги",
Payload = "{\"button\":\"selectOpenSheet\"}"
},
}
};
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row1));
row1 = new List<MessageKeyboardButton>()
{
new MessageKeyboardButton() {
Action = new MessageKeyboardButtonAction(){
Type = KeyboardButtonActionType.OpenLink,
Link = URLDOC,
Label = "Инструкция",
Payload = "{\"button\":\"selectOpenSheet\"}"
},
}
};
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row1));
var row2 = new List<MessageKeyboardButton>()
{
new MessageKeyboardButton() {
Action = new MessageKeyboardButtonAction(){
Label = "Статистика",
Payload = "{\"button\":\"selectStatistic\"}",
Type = KeyboardButtonActionType.Text},
Color = KeyboardButtonColor.Primary
}
};
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row2));
//var row3 = new List<MessageKeyboardButton>()
//{
// new MessageKeyboardButton() {
// Action = new MessageKeyboardButtonAction(){
// Label = "Личный кабинет специалиста",
// Payload = "{\"button\":\"selectExpertLK\"}",
// Type = KeyboardButtonActionType.Text},
// Color = KeyboardButtonColor.Primary
// }
//};
//listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row3));
var row4 = new List<MessageKeyboardButton>()
{
new MessageKeyboardButton() {
Action = new MessageKeyboardButtonAction(){
Label = "В начало",
Payload = "{\"button\":\"startPL\"}",
Type = KeyboardButtonActionType.Text},
Color = KeyboardButtonColor.Default
}
};
listButtons.Add(new ReadOnlyCollection<MessageKeyboardButton>(row4));
var buttons = new ReadOnlyCollection<ReadOnlyCollection<MessageKeyboardButton>>(listButtons);
var keyboard = new MessageKeyboard()
{
Buttons = buttons,
OneTime = false
};
//@params.Attachments = listVideo;
@params.Keyboard = keyboard;
@params.UserId = chatId;
@params.Message = "✅ Вы перешли в панель администратора. Выберите интересующее действие";
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
}
}
catch (Exception ee)
{
@params.Message = "‼Ошибка в SelectAdminCommand: " + ee.Message;
@params.Attachments = null;
@params.Keyboard = null;
@params.UserId = 59111081;
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
}
}
}
}