Exemplo n.º 1
0
        private List <User> GetUsers()
        {
            var state = GetBotState();

            if (state.Any())
            {
                return(state);
            }

            var users = new List <User>();
            var text  = File.ReadAllText(
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "timus_users.txt"));

            var lines = text.Split('\n');

            foreach (var line in lines)
            {
                var tokens = line.Split(' ');
                var user   = new User
                {
                    Id   = tokens[1],
                    Name = tokens[0],
                    LastSolvedProblemTime = DateTime.Now.AddMinutes(-2),
                    SolvedCount           = timus.GetSolvedCount(tokens[1])
                };
                users.Add(user);
            }

            return(users);
        }
Exemplo n.º 2
0
        private async Task SendMessage(List <User> users, User user, Submit submit)
        {
            var action  = user.Name.StartsWith("Аня") ? "сдала" : "сдал";
            var message = $"{user.Name} {action} задачу {submit.ProblemId} [{timus.GetProblemName(submit.ProblemId)}]({timus.Host}/problem.aspx?num={submit.ProblemId}) ";

            var solved = user.SolvedCount;

            if (solved % 10 == 0)
            {
                message += $"\nУже {solved} 👍";
            }

            message += "\n" + WhoSolved(users, submit.ProblemId);
            await bot.SendTextMessageAsync(chatId, message, ParseMode.Markdown);

            log.Info($"SENT {message} to {chatId}");

            if (solved == 1000)
            {
                await bot.SendStickerAsync(chatId, new FileToSend("BQADAgADFQADkZ2hB9unroIFwbsCAg")); //ого
            }
            else if (solved % 100 == 0)
            {
                await bot.SendStickerAsync(chatId, new FileToSend("BQADAgADrgAD41AwAAENKAshbD_oQwI")); //ничосе
            }
        }
Exemplo n.º 3
0
 private void UpdateUser(User user, List <Submit> submits)
 {
     user.SolvedCount = timus.GetSolvedCount(user.Id);
     if (submits.Any())
     {
         user.LastSolvedProblemTime = submits.Max(x => x.Timestamp);
     }
 }