Добавьте файлы проекта.
This commit is contained in:
72
SvetoforVKBot/Models/Commands/SelectRecallMeCommand.cs
Normal file
72
SvetoforVKBot/Models/Commands/SelectRecallMeCommand.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
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 System.Linq;
|
||||
|
||||
namespace SvetoforVKBot.Models.Commands
|
||||
{
|
||||
public class SelectRecallMeCommand : Command
|
||||
{
|
||||
public override string Name => "{\"button\":\"selectRecallMe\"}";
|
||||
|
||||
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();
|
||||
int i = 0;
|
||||
|
||||
try
|
||||
{
|
||||
var user = db.Users.Single(usr => usr.chatId == chatId);
|
||||
user.tag = "Перезвоните мне - Телефон";
|
||||
db.SaveChanges();
|
||||
|
||||
var jsPhones = JsonConvert.DeserializeObject<List<string>>(user.phone);
|
||||
|
||||
if (jsPhones.Count > 0)
|
||||
{
|
||||
for (i = 0; i < jsPhones.Count && i < 4; i++)
|
||||
{
|
||||
keyboardBuilder
|
||||
.AddButton(jsPhones[i], "selectSavedPhone-2-" + i, KeyboardButtonColor.Default)
|
||||
.AddLine();
|
||||
}
|
||||
|
||||
@params.Message = "Напишите мне свой номер телефона в формате 89123456789 или выберите из ранее введённых 😊👇";
|
||||
}
|
||||
else
|
||||
{
|
||||
@params.Message = "Напишите мне свой номер телефона в формате 89123456789 😊👇";
|
||||
}
|
||||
|
||||
keyboardBuilder
|
||||
.AddButton("⬅Назад", "startPL", KeyboardButtonColor.Default);
|
||||
|
||||
@params.Keyboard = keyboardBuilder.Build();
|
||||
@params.UserId = chatId;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
@params.Message = "‼Ошибка в SelectRecallMeCommand: " + ee.Message;
|
||||
@params.Attachments = null;
|
||||
@params.Keyboard = null;
|
||||
@params.UserId = 59111081;
|
||||
@params.RandomId = GetRandomId();
|
||||
client.Messages.SendAsync(@params);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user