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

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,67 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
using SvetoforVKBot.Models.Updates;
using VkNet;
using VkNet.Enums.SafetyEnums;
using VkNet.Model.Keyboard;
using VkNet.Model.RequestParams;
namespace SvetoforVKBot.Models.Commands.LK.EditData
{
public class GetEditFIOCommand
{
public void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
{
var chatId = update.@object.message.from_id;
MessagesSendParams @params = new MessagesSendParams();
try
{
if (update.@object.message.text.Length > 0 && update.@object.message.text.Length <= 50)
{
var ids = new long[] { chatId };
var user = db.Users.Single(usr => usr.chatId == chatId);
user.fio = update.@object.message.text.Trim();
user.tag = "Личный кабинет - Данные";
db.SaveChanges();
SelectEditDataCommand selectEditData = new SelectEditDataCommand();
selectEditData.Execute(update, client, db);
}
else
{
@params.Message = "Данные введены некорректно 😕 Напишите, пожалуйста, текст длиной до 50 символов.";
@params.UserId = chatId;
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
}
}
catch (Exception ee)
{
@params.Message = "‼Ошибка в GetEditFIOCommand: " + ee.Message;
@params.Attachments = null;
@params.Keyboard = null;
@params.UserId = 59111081;
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
}
}
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
public int GetRandomId()
{
var intBytes = new byte[4];
Rng.GetBytes(intBytes);
return BitConverter.ToInt32(intBytes, 0);
}
}
}

View File

@@ -0,0 +1,111 @@
using SvetoforVKBot.Models.Updates;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using VkNet;
using VkNet.Model.RequestParams;
using System.Security.Cryptography;
using VkNet.Model.Keyboard;
using VkNet.Model.Attachments;
using VkNet.Enums.SafetyEnums;
using System.Collections.ObjectModel;
using System.Threading;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using SvetoforVKBot.Models.Commands.LK;
using System.Linq;
namespace SvetoforVKBot.Models.Commands.LK.EditData
{
public class GetEditPhoneCommand
{
public bool Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
{
MessagesSendParams @params = new MessagesSendParams();
MessagesSendParams @params2 = new MessagesSendParams();
var chatId = update.@object.message.from_id;
Regex regex = new Regex("[^0-9]");
int i = 0;
var row = new List<MessageKeyboardButton>();
var listButtons = new List<ReadOnlyCollection<MessageKeyboardButton>>();
var keyboardBuilder = new KeyboardBuilder().Clear();
try
{
string phone = regex.Replace(update.@object.message.text, "");
if (phone.Length == 11)
if (phone.StartsWith("8") || phone.StartsWith("7"))
{
var user = db.Users.Single(usr => usr.chatId == chatId);
var jsPhones = JsonConvert.DeserializeObject<List<string>>(user.phone);
if (jsPhones.Contains(phone))
{
jsPhones[jsPhones.FindIndex(p => p.Equals(phone))] = jsPhones[0];
jsPhones[0] = phone;
}
else
{
if (jsPhones.Count > 0)
{
for (i = jsPhones.Count; i > 0; i--)
{
if (i != 4)
{
if (i == jsPhones.Count)
jsPhones.Add("");
jsPhones[i] = jsPhones[i - 1];
}
}
}
else
jsPhones.Add("");
jsPhones[0] = phone;
}
user.tag = "Личный кабинет - Данные";
user.phone = JsonConvert.SerializeObject(jsPhones);
SelectEditDataCommand selectEditData = new SelectEditDataCommand();
selectEditData.Execute(update, client, db);
}
else
@params.Message = "Контактный телефон в формате 89123456789 (11 цифр, без плюса и через \"8\" или \"7\" обязательно).";
else
@params.Message = "Контактный телефон в формате 89123456789 (11 цифр, без плюса и через \"8\" или \"7\" обязательно).";
@params.Keyboard = keyboardBuilder.Build();
@params.UserId = chatId;
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
}
catch (Exception ee)
{
@params.Message = "‼Ошибка в GetEditPhoneCommand: " + ee.Message;
@params.Attachments = null;
@params.Keyboard = null;
@params.UserId = 59111081;
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
return true;
}
return true;
}
private static readonly RandomNumberGenerator Rng = RandomNumberGenerator.Create();
public int GetRandomId()
{
var intBytes = new byte[4];
Rng.GetBytes(intBytes);
return BitConverter.ToInt32(intBytes, 0);
}
}
}

View File

@@ -0,0 +1,58 @@
using System;
using System.Data.SqlClient;
using SvetoforVKBot.Models.Updates;
using VkNet;
using VkNet.Enums.SafetyEnums;
using VkNet.Model.Keyboard;
using VkNet.Model.RequestParams;
using Newtonsoft.Json;
using VkNet.Enums.Filters;
using System.Text.RegularExpressions;
using SvetoforVKBot.Models.Commands.LK;
using System.Collections.Generic;
using SvetoforVKBot.Models.Commands.LK.SportsLK;
using System.Linq;
namespace SvetoforVKBot.Models.Commands.LK.EditData
{
public class SelectEditNotifyCount : Command
{
public override string Name => "{\"button\":\"selectEditNotifyCount-";
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;
var keyboardBuilder = new KeyboardBuilder().Clear();
Regex regex = new Regex("[^0-9]");
double activityCoef = 0;
try
{
string[] payload = update.@object.message.payload.Split('-');
int notifyCount = Convert.ToInt32(regex.Replace(payload[1], ""));
var user = db.Users.Single(usr => usr.chatId == chatId);
user.notifyCount = notifyCount;
user.tag = "Личный кабинет - Данные";
db.SaveChanges();
SelectEditDataCommand selectEditData = new SelectEditDataCommand();
selectEditData.Execute(update, client, db);
}
catch (Exception ee)
{
@params.Message = "Ошибка в SelectEditNotifyCountCommand: " + ee.Message;
@params.Attachments = null;
@params.Keyboard = null;
@params.UserId = 59111081;
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
}
}
}
}

View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Threading;
using Newtonsoft.Json;
using SvetoforVKBot.Models.Commands.Registration;
using SvetoforVKBot.Models.Updates;
using VkNet;
using VkNet.Enums.SafetyEnums;
using VkNet.Model.Attachments;
using VkNet.Model.Keyboard;
using VkNet.Model.RequestParams;
namespace SvetoforVKBot.Models.Commands.LK.EditData
{
public class SelectUpdateSportDaysCommand : Command
{
public override string Name => "{\"button\":\"selectUpdateSportDays\"}";
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();
MessagesSendParams @params2 = new MessagesSendParams();
var keyboardBuilder = new KeyboardBuilder().Clear();
string msg = "";
DateTime dt = DateTime.Now;
string msgManager = "";
List<int> ids = new List<int>();
try
{
var user = db.Users.Single(usr => usr.chatId == chatId);
user.sportDays = "[]";
db.SaveChanges();
ShowSportDays showSportDays = new ShowSportDays();
showSportDays.Execute(update, client, db);
return;
}
catch (Exception ee)
{
@params.Message = "Ошибка в SelectUpdateSportDaysCommand: " + ee.Message;
@params.Attachments = null;
@params.Keyboard = null;
@params.UserId = 59111081;
@params.RandomId = GetRandomId();
client.Messages.SendAsync(@params);
}
}
}
}