Esempio n. 1
0
        public static async void Timer_RemindVote(object sender, ElapsedEventArgs e)
        {
            if (ReminderLock)
            {
                return;
            }

            try
            {
                ReminderLock = true;
                var paramL = ParamDb.GetParam(0, "VoteReminder");
                var param  = paramL?.FirstOrDefault() ?? new Param {
                    Name = "VoteReminder", Date = System.DateTime.Now
                };

                var dateTo = System.DateTime.Now;
                dateTo = dateTo.AddHours(-12);
                var votes = await VoteDb.GetVoters(param.Date, dateTo);

                param.Date = dateTo;
                await ParamDb.UpdateParam(param);
                await SendReminders(votes.Distinct());
            }
            catch { }
            finally
            {
                ReminderLock = false;
            }
        }
Esempio n. 2
0
        public static async void Timer_Voters2(object sender, ElapsedEventArgs e)
        {
            if (Interlocked.Exchange(ref VoteLock, 1) == 0)
            {
                try
                {
                    var voters = await WebUtil.GetVotersAsync();

                    var old = await VoteDb.GetVoters(500);

                    var votersParsed = voters.Select(x => x.Id).ToList();
                    votersParsed.Reverse();

                    List <ulong> add = NewEntries(old, votersParsed);

                    if (add.Count > 500)
                    {
                        var ch = await Program.GetClient().GetUser(AppSettings.OwnerId).CreateDMChannelAsync();

                        string er = "```\n";
                        foreach (var id in voters.Take(10))
                        {
                            er += $"{id.Id}\n";
                        }
                        er += "...\n";
                        foreach (var id in voters.Skip(add.Count - 10))
                        {
                            er += $"{id.Id}\n";
                        }
                        er += "```";
                        await ch.SendMessageAsync($"Found {add.Count} new voters.\n {er}");

                        return;
                    }

                    await VoteDb.AddVoters(add);
                    await SendRewards(add);

                    if (add.Count > 0)
                    {
                        Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")} Shipped {add.Count} lootboxes.");
                    }
                }
                catch (Exception ex)
                {
                    SentrySdk.CaptureException(ex);
                }
                finally
                {
                    VoteLock = 0;
                }
            }
        }