예제 #1
0
        public static async Task SelectiveUpdate(Clan clan)
        {
            Log.Information("Scanning for changes for " + clan.details.Name);
            var changed = await SpreadsheetTools.CheckForChangesAsync(clan);

            if (changed.TotalChanges > 0)
            {
                await SpreadsheetTools.SelectiveUpdate(clan, changed, null, null);

                DiscordEmbed discordEmbed;
                if (changed.TotalChanges == 1)
                {
                    discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.SpringGreen, "Processed changes for " + clan.details.Name, "Automatically processed 1 entry.");
                }
                else
                {
                    discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.SpringGreen, "Processed changes for " + clan.details.Name, string.Format("Automatically processed {0} entries", changed.TotalChanges));
                }
                List <DiscordMessage> messages = new List <DiscordMessage>();
                foreach (var channel in Core.Discord.updatesChannels)
                {
                    messages.Add(await Core.Discord.SendFancyMessage(channel, discordEmbed));
                }
            }
        }
예제 #2
0
        public async Task BulkUpdateSheet(CommandContext ctx, string clanTag)
        {
            var roles        = ctx.Member.Roles.ToList();
            var verification = await IsVerifiedAsync(ctx, true);

            var clan = await GetClanFromTagOrNameAsync(ctx, clanTag);

            clanTag = clanTag.ToLower();

            if (clan != null && verification == ErrorCode.Qualify && !string.IsNullOrEmpty(clan.details.Tag))
            {
                TimeSpan t            = TimeSpan.FromSeconds(5 * clan.members.SpreadsheetUsers.Count);
                var      discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.Orange, "Bulk Updating", "Updating every element in spreadsheet...", new List <Field>()
                {
                    new Field("Time Left", t.ToString(@"mm\:ss"))
                });
                DiscordMessage msg = await ctx.RespondAsync(discordEmbed);

                await SpreadsheetTools.BulkUpdate(clan, new () { msg }, BulkUpdateSheetProgress);

                discordEmbed = Core.Discord.CreateFancyMessage(clan.details.DiscordColour, "Done", string.Format("Successfully bulk updated {0} members", clan.members.BungieUsers.Count));
                await msg.ModifyAsync(discordEmbed);
                await ThankUsage(ctx, clan, 100);
            }
        }
예제 #3
0
        public static async Task BulkUpdate(Clan clan)
        {
            List <DiscordMessage> messages = new List <DiscordMessage>();
            var discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.Orange, "Bulk updating " + clan.details.Name + ".");

            Core.Discord.updatesChannels.ForEach(channel => { messages.Add(Core.Discord.SendFancyMessage(channel, discordEmbed).Result); });
            //Console.WriteLine("Bulk updating for " + clan.details.BungieNetName);

            await SpreadsheetTools.BulkUpdate(clan, messages, BulkUpdateSheetProgress);

            discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.SpringGreen, "Bulk updated " + clan.details.Name, "Updated every cell in spreadsheet.");
            messages.ForEach(async message => { await message.ModifyAsync(discordEmbed); });
        }
예제 #4
0
        //static void Main(string[] args)
        //{

        //    ConfigValues.LoadConfig();
        //    TrackTimeLive();
        //    Clans.LoadClans();
        //    MainAsync().GetAwaiter().GetResult();
        //}
        static async Task Main(string[] args)
        {
            Random = new Random();
            ConfigValues.LoadConfig();
            //TrackTimeLive();
            Clans.LoadClans();
            await SpreadsheetTools.SetUpSheet();

            startTime = DateTime.UtcNow;
            await Discord.SetupClient();

            await Task.Delay(-1);
        }
예제 #5
0
        public async Task UpdateSpreadSheet(CommandContext ctx, string clanTag)
        {
            var roles        = ctx.Member.Roles.ToList();
            var verification = await IsVerifiedAsync(ctx, true);

            var clan = await GetClanFromTagOrNameAsync(ctx, clanTag);

            clanTag = clanTag.ToLower();

            if (clan != null && verification == ErrorCode.Qualify && !string.IsNullOrEmpty(clan.details.Tag))
            {
                var            discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.Orange, "Scanning for Changes...");
                DiscordMessage msg          = await ctx.RespondAsync(discordEmbed);

                await SpreadsheetTools.Read(clan);

                var _ = await SpreadsheetTools.CheckForChangesAsync(clan);

                if (_.TotalChanges > 0)
                {
                    TimeSpan t = TimeSpan.FromSeconds((_.addedUsers.Count * 5) + (_.updatedUsers.Count * 0.1) + (_.removedUsers.Count * 0.1));
                    discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.Yellow, "Found changes", string.Format("{0} change(s) found...", _.TotalChanges), new List <Field>()
                    {
                        new Field("Time Left", t.ToString(@"mm\:ss"))
                    });
                    await msg.ModifyAsync(discordEmbed);

                    await SpreadsheetTools.SelectiveUpdate(clan, _, new() { msg }, UpdateSpreadsheetProgress);

                    discordEmbed = Core.Discord.CreateFancyMessage(clan.details.DiscordColour, "Done", string.Format("Successfully processed {0} changes.", _.TotalChanges));
                    await msg.ModifyAsync(discordEmbed);
                }
                else
                {
                    await SpreadsheetTools.SelectiveUpdate(clan);

                    discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.SpringGreen, "No changes found", "To update steam names, please run a bulk update.");
                    await msg.ModifyAsync(discordEmbed);
                }
                await ThankUsage(ctx, clan, 100);
            }
        }
예제 #6
0
 public static async Task Discord_GuildMemberRemoved(DiscordClient client, GuildMemberRemoveEventArgs e)
 {
     new Thread(async() =>
     {
         var member = SpreadsheetTools.CheckUserAgainstSpreadsheet(e.Member.Id.ToString());
         if (member != null)
         {
             var clan         = BungieTools.GetClanFromTag(member.ClanTag);
             var discordEmbed = Core.Discord.CreateFancyMessage(clan.details.DiscordColour, clan.details.Name + " Member left Discord server!", "User was found on spreadsheet.", new List <Field>(2)
             {
                 new Field("Username", e.Member.Username + '#' + e.Member.Discriminator), new Field("ID", e.Member.Id.ToString())
             });
             Log.Information("Detected " + clan.details.Name + " member leaving discord");
             List <DiscordMessage> messages = new List <DiscordMessage>();
             foreach (var channel in Core.Discord.alertsChannels)
             {
                 messages.Add(await Core.Discord.SendFancyMessage(channel, discordEmbed));
             }
         }
     }).Start();
 }
예제 #7
0
        public async Task DisplayUsers(CommandContext ctx, string clanTag, [RemainingText] string mode)
        {
            var roles        = ctx.Member.Roles.ToList();
            var verification = await IsVerifiedAsync(ctx, true);

            var clan = await GetClanFromTagOrNameAsync(ctx, clanTag);

            clanTag = clanTag.ToLower();

            if (clan != null && verification == ErrorCode.Qualify && !string.IsNullOrEmpty(clan.details.Tag))
            {
                if (string.IsNullOrEmpty(mode) || mode == "spreadsheet" || mode == "sheet")
                {
                    await SpreadsheetTools.Read(clan);

                    var users = clan.members.SpreadsheetUsers.ToList();
                    users = users.OrderBy(t => t.SteamName).ToList();

                    Core.Discord.SendFancyListMessage(ctx.Channel, clan, users, "Users on spreadsheet for " + clan.details.Name + ":");

                    await ThankUsage(ctx, clan, 100);
                }
                else if (mode == "saved data" || mode == "saved" || mode == "file")
                {
                    List <SpreadsheetTools.User> users = clan.members.BungieUsers;
                    users = users.OrderBy(t => t.SteamName).ToList();

                    Core.Discord.SendFancyListMessage(ctx.Channel, clan, users, "Users for " + clan.details.Name + ":");

                    await ThankUsage(ctx, clan, 100);
                }
                else
                {
                    var discordEmbed = Core.Discord.CreateFancyMessage(DiscordColor.IndianRed, "Sorry!", "Additional arguments required. eithe use:\ndisplayusers sheet or displayusers saved");
                    await ctx.RespondAsync(discordEmbed);
                }
            }
        }
예제 #8
0
 public static async Task Read(Clan clan)
 {
     await SpreadsheetTools.Read(clan);
 }