1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using CardCollector.DataBase.Entity;
- using CardCollector.DataBase.EntityDao;
- using Telegram.Bot.Types;
- namespace CardCollector.Commands.ChosenInlineResult
- {
- public abstract class SendStickerCommand : ChosenInlineResultCommand
- {
- private static PeopleSendsSticker info = PeopleSendsSticker.Build().Result;
-
- public override async Task AfterExecute()
- {
- if (!info.Actual())
- {
- info.WriteResults();
- info = await PeopleSendsSticker.Build();
- }
- info.Add(User.Id);
- }
-
- private class PeopleSendsSticker
- {
- private DateTime infoDate;
- private CountLogs logsEntity;
- private HashSet<long> People = new();
- public static async Task<PeopleSendsSticker> Build()
- {
- var result = new PeopleSendsSticker();
- result.infoDate = DateTime.Today;
- result.logsEntity = await CountLogsDao.Get(result.infoDate);
- return result;
- }
- public bool Actual()
- {
- return infoDate.Equals(DateTime.Today);
- }
- public void Add(long userId)
- {
- People.Add(userId);
- }
- public void WriteResults()
- {
- logsEntity.PeopleSendsStickerOneOrMoreTimes += People.Count;
- }
- }
- public static void WriteLogs()
- {
- info.WriteResults();
- }
- protected SendStickerCommand() { }
- protected SendStickerCommand(UserEntity user, Update update) : base(user, update) { }
- }
- }
|