1
0
This repository has been archived on 2023-08-03. You can view files and clone it, but cannot push or open issues or pull requests.
budet-cho-bot/Budet-cho-bot/Services/ReminderService.cs

45 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}
}
}