Esempio n. 1
0
        private Embed CreateTPInboxEmbed(TPInbox inboxBefore, TPInbox inboxAfter)
        {
            var embed = new EmbedBuilder();

            embed.WithColor(222, 39, 0);
            embed.WithTitle(CharacterName + "s Tradepost Delivery").WithCurrentTimestamp();
            var  currency   = ToIngameCurrency(inboxAfter.coins);
            bool loss       = inboxBefore.coins > inboxAfter.coins;
            var  difference = ToIngameCurrency(loss ? inboxBefore.coins - inboxAfter.coins : inboxAfter.coins - inboxBefore.coins);

            embed.AddField("Money", $"{currency.gold}{Gold} {currency.silver}{Silver} {currency.copper}{Copper}\n{(loss ? $"-" : "+")} {difference.gold}{Gold} {difference.silver}{Silver} {difference.copper}{Copper}", true);
            var items = String.Join("\n", inboxAfter.items.Take(Math.Min(10, inboxAfter.items.Count)).Select(x => "**" + GetItemInfo(x.id).Result.name + $"** ({x.count}x)"));

            embed.AddField($"{inboxAfter.items.Count} Items ({(inboxAfter.items.Count > inboxBefore.items.Count ? "+" : "")}{inboxAfter.items.Count - inboxBefore.items.Count})", items.Length > 0 ? items : "No items in delivery", false);
            embed.WithFooter(x => {
                x.Text    = "GW2Tracker";
                x.IconUrl = "https://1001019.v1.pressablecdn.com/wp-content/uploads/2012/08/GW2-Logo.jpg";
            });

            return(embed.Build());
        }
Esempio n. 2
0
        protected async override void CheckForChange_Elapsed(object stateinfo)
        {
            try
            {
                if (ChannelConfig.Any(x => (bool)x.Value[TRACKLEVEL]))
                {
                    if (PastInformation.character == null)
                    {
                        PastInformation.character = await GetCharacterEndpoint(CharacterName, APIKey);

                        LevelGraph = new DatePlot($"{CharacterName.Replace(" ", "")}Level", "Date", "Level", "dd-MMM", false, true);
                        LevelGraph.AddValueSeperate("Level", PastInformation.character.level, relative: false);
                        LevelGraph.AddValueSeperate("M-Level", PastInformation.character.masteryLevel, relative: false);
                        await UpdateTracker();
                    }

                    else
                    {
                        Character pastInfo    = PastInformation.character;
                        Character currentInfo = await GetCharacterEndpoint(CharacterName, APIKey);

                        if (currentInfo.level != pastInfo.level || currentInfo.masteryLevel != pastInfo.masteryLevel)
                        {
                            LevelGraph.AddValueSeperate("Level", pastInfo.level, relative: false);
                            LevelGraph.AddValueSeperate("M-Level", pastInfo.masteryLevel, relative: false);
                            LevelGraph.AddValueSeperate("Level", currentInfo.level, relative: false);
                            LevelGraph.AddValueSeperate("M-Level", currentInfo.masteryLevel, relative: false);
                            foreach (var channel in ChannelConfig.Where(x => (bool)x.Value[TRACKLEVEL]))
                            {
                                await OnMajorChangeTracked(channel.Key, createLevelEmbed(pastInfo, currentInfo));
                            }

                            PastInformation.character = currentInfo;
                            await UpdateTracker();
                        }
                    }
                }

                if (ChannelConfig.Any(x => (bool)x.Value[TRACKACHIEVEMENTS]))
                {
                    //ToDo
                }

                if (ChannelConfig.Any(x => (bool)x.Value[TRACKWEALTH]))
                {
                    if (PastInformation.wallet == null)
                    {
                        PastInformation.wallet = (await GetWealth(APIKey)).FirstOrDefault();
                        MoneyGraph             = new DatePlot($"{CharacterName.Replace(" ", "")}Gold", "Date", "Gold", "dd-MMM", false);
                        MoneyGraph.AddValue("Gold", PastInformation.wallet.value, relative: false);
                        await UpdateTracker();
                    }

                    else
                    {
                        Wallet pastInfo    = PastInformation.wallet;
                        Wallet currentInfo = (await GetWealth(APIKey)).FirstOrDefault();

                        if (currentInfo.value != pastInfo.value)
                        {
                            MoneyGraph.AddValue("Gold", pastInfo.value, relative: false);
                            MoneyGraph.AddValue("Gold", currentInfo.value, relative: false);
                            foreach (var channel in ChannelConfig.Where(x => (bool)x.Value[TRACKWEALTH]))
                            {
                                await OnMajorChangeTracked(channel.Key, createWealthEmbed(pastInfo, currentInfo));
                            }

                            PastInformation.wallet = currentInfo;
                            await UpdateTracker();
                        }
                    }
                }

                if (ChannelConfig.Any(x => (bool)x.Value[TRACKTPBUYS]))
                {
                    if (PastInformation.buy == null)
                    {
                        PastInformation.buy = (await GetTPBuys(APIKey)).FirstOrDefault();
                        await UpdateTracker();
                    }

                    else
                    {
                        TPTransaction        pastInfo    = PastInformation.buy;
                        List <TPTransaction> currentInfo = (await GetTPBuys(APIKey)).TakeWhile(x => x.purchased > pastInfo.purchased).ToList();
                        currentInfo.Reverse();

                        foreach (var transaction in currentInfo)
                        {
                            foreach (var channel in ChannelConfig.Where(x => (bool)x.Value[TRACKTPBUYS]))
                            {
                                await OnMajorChangeTracked(channel.Key, await CreateTPBuyEmbed(transaction));
                            }
                        }

                        if (currentInfo.Count > 0)
                        {
                            PastInformation.buy = currentInfo.LastOrDefault();
                            await UpdateTracker();
                        }
                    }
                }

                if (ChannelConfig.Any(x => (bool)x.Value[TRACKTPSELLS]))
                {
                    if (PastInformation.sell == null)
                    {
                        PastInformation.sell = (await GetTPSells(APIKey)).FirstOrDefault();
                        await UpdateTracker();
                    }

                    else
                    {
                        TPTransaction        pastInfo    = PastInformation.sell;
                        List <TPTransaction> currentInfo = (await GetTPSells(APIKey)).TakeWhile(x => x.purchased > pastInfo.purchased).ToList();
                        currentInfo.Reverse();

                        foreach (var transaction in currentInfo)
                        {
                            foreach (var channel in ChannelConfig.Where(x => (bool)x.Value[TRACKTPSELLS]))
                            {
                                await OnMajorChangeTracked(channel.Key, await CreateTPSellEmbed(transaction));
                            }
                        }

                        if (currentInfo.Count > 0)
                        {
                            PastInformation.sell = currentInfo.LastOrDefault();
                            await UpdateTracker();
                        }
                    }
                }

                if (ChannelConfig.Any(x => (bool)x.Value[TRACKTPDELIVERY]))
                {
                    if (PastInformation.delivery == null)
                    {
                        PastInformation.delivery = await GetTPInbox(APIKey);
                        await UpdateTracker();
                    }

                    else
                    {
                        TPInbox pastInfo    = PastInformation.delivery;
                        TPInbox currentInfo = await GetTPInbox(APIKey);

                        if (currentInfo.items.Count != pastInfo.items.Count || currentInfo.coins != pastInfo.coins)
                        {
                            foreach (var channel in ChannelConfig.Where(x => (bool)x.Value[TRACKTPDELIVERY]))
                            {
                                await OnMajorChangeTracked(channel.Key, CreateTPInboxEmbed(pastInfo, currentInfo));
                            }

                            PastInformation.delivery = currentInfo;
                            await UpdateTracker();
                        }
                    }
                }

                if (ChannelConfig.Any(x => (bool)x.Value[TRACKEQUIPMENT]))
                {
                }
            }
            catch (Exception e)
            {
                await Program.MopsLog(new LogMessage(LogSeverity.Error, "", $" error by {Name}", e));
            }
        }