74 lines
2.8 KiB
C#
74 lines
2.8 KiB
C#
using Newtonsoft.Json;
|
|
using SvetoforVKBot.Models.Updates;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using System.Text.RegularExpressions;
|
|
using VkNet;
|
|
using VkNet.Enums.SafetyEnums;
|
|
using VkNet.Model.Attachments;
|
|
using VkNet.Model.Keyboard;
|
|
using VkNet.Model.RequestParams;
|
|
|
|
|
|
namespace SvetoforVKBot.Models.Commands.Water
|
|
{
|
|
public class SelectGoWaterNotifyCommand : Command
|
|
{
|
|
public override string Name => "{\"button\":\"selectGoWaterNotify\"}";
|
|
|
|
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();
|
|
List<UserObject> users = new List<UserObject>();
|
|
List<int> chatIds = new List<int>();
|
|
string name = "";
|
|
try
|
|
{
|
|
var user = db.Users.Single(usr => usr.chatId == chatId);
|
|
user.waterNotify = 1;
|
|
db.SaveChanges();
|
|
|
|
//SqlCommand updUser = new SqlCommand("UPDATE Users SET waterNotify = 1 WHERE chatId = @chatId;", Con);
|
|
//updUser.Parameters.AddWithValue("@chatId", chatId);
|
|
//updUser.ExecuteNonQuery();
|
|
|
|
//@params.Message = "Отлично! Напоминания включены.\n" +
|
|
// "Самое время выпить воду😉";
|
|
|
|
@params.Message = "Сколько раз в день Вы готовы получать напоминания?";
|
|
|
|
keyboardBuilder
|
|
.AddButton("1", "selectWaterNotifyCount-1", KeyboardButtonColor.Primary)
|
|
.AddButton("3", "selectWaterNotifyCount-3", KeyboardButtonColor.Primary)
|
|
.AddButton("6", "selectWaterNotifyCount-6", KeyboardButtonColor.Primary)
|
|
.SetInline();
|
|
|
|
@params.Keyboard = keyboardBuilder.Build();
|
|
@params.UserId = chatId;
|
|
@params.RandomId = GetRandomId();
|
|
client.Messages.SendAsync(@params);
|
|
|
|
}
|
|
catch (Exception ee)
|
|
{
|
|
@params.Message = "Ошибка в SelectGoWaterNotifyCommand: " + ee.Message;
|
|
@params.Attachments = null;
|
|
@params.Keyboard = null;
|
|
@params.UserId = 59111081;
|
|
@params.RandomId = GetRandomId();
|
|
client.Messages.SendAsync(@params);
|
|
}
|
|
}
|
|
|
|
public override void Execute(RootObject update, VkApi client, SvetoforVKBot.Data.SvetoforVKBotEntities db)
|
|
{
|
|
|
|
}
|
|
}
|
|
} |