45 lines
1.4 KiB
C#
45 lines
1.4 KiB
C#
using Budet_cho_bot.Helpers;
|
||
using Budet_cho_bot.Models;
|
||
using Budet_cho_bot.Repositories;
|
||
using Discord;
|
||
using Discord_Bot;
|
||
using Newtonsoft.Json.Linq;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace Budet_cho_bot.Services
|
||
{
|
||
internal class ReminderService
|
||
{
|
||
private readonly CronRepository _cronRepository = new CronRepository();
|
||
private const long DAY_PERIOD = 24 * 60 * 60 * 1000; // 10 * 1000; //
|
||
private Timer reminderTimer;
|
||
|
||
|
||
public async void SendReminder(object? state)
|
||
{
|
||
var users = Functions.GetConfigItem("users").ToString();
|
||
//await ReplyAsync($"{users}\nБудет чо?");
|
||
}
|
||
|
||
public async Task<int> CreateTask(CronRecord record)
|
||
{
|
||
var cron = await _cronRepository.GetCronTask("reminder");
|
||
var cronUnpacked = Utility.UnpackTimetableFromString(cron);
|
||
|
||
var result = await _cronRepository.SetCronTask("reminder", Utility.PackTimetableIntoString(cronUnpacked.Append(record).ToArray()));
|
||
return result;
|
||
}
|
||
|
||
public async Task<CronRecord[]> GetTasks()
|
||
{
|
||
var cron = await _cronRepository.GetCronTask("reminder");
|
||
var cronUnpacked = Utility.UnpackTimetableFromString(cron);
|
||
return cronUnpacked;
|
||
}
|
||
}
|
||
}
|