public async Task GetStoreAppDetailsAsync_Should_Succeed()
        {
            var response = await steamStore.GetStoreAppDetailsAsync(1086940);

            Assert.NotNull(response);
            Assert.NotNull(response.Name);
        }
Beispiel #2
0
        private static async Task <Steam.Models.SteamStore.StoreAppDetailsDataModel> GetSteamAppModel(string appID)
        {
            uint uintAppID = (uint)Int32.Parse(appID);

            var steamStore = new SteamStore();
            var appDetais  = await steamStore.GetStoreAppDetailsAsync(uintAppID);

            return(appDetais);
        }
        /// <remarks>https://github.com/babelshift/SteamWebAPI2/issues/81</remarks>
        public static async Task <StoreAppDetailsDataModel> GetSteamAppAsync(string query)
        {
            SteamInterface = new SteamWebInterfaceFactory(TokenHandler.Tokens.SteamToken);
            //var steam = SteamInterface.CreateSteamWebInterface<SteamStore>(new HttpClient());
            //var appId = SteamAppList.FirstOrDefault(n => string.Equals(n.Value, query, StringComparison.InvariantCultureIgnoreCase)).Key;
            var steam = SteamInterface.CreateSteamWebInterface <SteamApps>(new HttpClient());
            var store = new SteamStore();
            var list  = await steam.GetAppListAsync();

            var appId = list.Data.FirstOrDefault(n => string.Equals(n.Name, query, StringComparison.InvariantCultureIgnoreCase)).AppId;

            return(await store.GetStoreAppDetailsAsync(appId).ConfigureAwait(false));
        }
Beispiel #4
0
        public async Task <StoreAppDetailsDataModel> GetAppInfoAsync(uint appId)
        {
            StoreAppDetailsDataModel appInfo;

            try
            {
                appInfo = await _steamStore.GetStoreAppDetailsAsync(appId);
            }
            catch (NullReferenceException)
            {
                return(null);
            }
            return(appInfo);
        }
Beispiel #5
0
        public async Task SteamGame(CommandContext ctx)
        {
            var check = false;

            while (check == false)
            {
                try
                {
                    var rnd   = new Random();
                    var store = new SteamStore();
                    var app   = await store.GetStoreAppDetailsAsync(GlobalVariables.SteamAppList.Keys.ToArray()[rnd.Next(0, GlobalVariables.SteamAppList.Keys.Count - 1)]);

                    await ctx.TriggerTypingAsync();

                    var output = new DiscordEmbedBuilder()
                                 .WithTitle(app.Name)
                                 .WithThumbnailUrl(app.HeaderImage)
                                 .WithUrl($"http://store.steampowered.com/app/{app.SteamAppId}")
                                 .WithFooter($"App ID: {app.SteamAppId}")
                                 .WithColor(DiscordColor.MidnightBlue);
                    if (!string.IsNullOrWhiteSpace(app.DetailedDescription))
                    {
                        output.WithDescription(Regex.Replace(app.DetailedDescription.Length <= 500 ? app.DetailedDescription : $"{app.DetailedDescription.Substring(0, 500)}...", "<[^>]*>", ""));
                    }
                    if (app.Developers.Length > 0 && !string.IsNullOrWhiteSpace(app.Developers[0]))
                    {
                        output.AddField("Developers", app.Developers[0], true);
                    }
                    if (app.Publishers.Length > 0 && !string.IsNullOrWhiteSpace(app.Publishers[0]))
                    {
                        output.AddField("Publisher", app.Publishers[0], true);
                    }
                    if (!string.IsNullOrWhiteSpace(app.ReleaseDate.Date))
                    {
                        output.AddField("Release Date", app.ReleaseDate.Date, true);
                    }
                    if (app.Metacritic != null)
                    {
                        output.AddField("Metacritic", app.Metacritic.Score.ToString(), true);
                    }
                    await ctx.RespondAsync(embed : output.Build());

                    check = true;
                }
                catch
                {
                    check = false;
                }
            }
        }
Beispiel #6
0
        public async Task <StoreAppDetailsDataModel> GetStoreAppDetail(uint appId)
        {
            var response = await _store.GetStoreAppDetailsAsync(appId);

            return(response);
        }
Beispiel #7
0
 public async Task <SteamAppDetails> GetStoreDetails(uint id) =>
 await _caches[StoreAppDetailsCacheKey].AddOrGetExisting(id.ToString(), async() => (SteamAppDetails)await SteamStore.GetStoreAppDetailsAsync(id));
Beispiel #8
0
        private static async void OnTimerTicked(object sender, ElapsedEventArgs e)
        {
            if (Global.Client == null) //Ensures the Discord Client is running before the timer begins
            {
                Console.WriteLine("Timer Ticked before Client was ready");
                return;
            }
            //Console.WriteLine("Timer Cycle Complete");
            try
            {
                if (count == 0)                                  //On the first cycle of the timer get critical information and store it in the database
                {
                    foreach (var guild in Global.Client.Guilds)  //For every server currently running the bot
                    {
                        foreach (var user in guild.Users)        //For every user in each server
                        {
                            string userID  = user.Id.ToString(); //Retrieve userID
                            string steamID = null;
                            while (steamID == null && !user.IsBot)
                            {
                                steamID = DataStorage.getSteamID(userID).Result; //Use userID to access users steam ID in the database
                            }

                            if (!user.IsBot && userID != null) //If the user is not a bot and the user exists
                            {
                                var    gameResponse = steamInterface.GetPlayerSummaryAsync(Convert.ToUInt64(steamID));
                                string game         = gameResponse.Result.Data.PlayingGameName;
                                if (game == null)
                                {
                                    game = "none";
                                }
                                DataStorage.setNowPlaying(userID, game); //Set the nowPlaying value in the database for this user to the game received from the Steam API
                            }
                        }
                    }
                }
                else
                {
                    foreach (var guild in Global.Client.Guilds)  //For each server running the bot
                    {
                        foreach (var chan in guild.TextChannels) //For each channel in each server
                        {
                            if (chan.Name == "general")          //Find the channel named general and assign its ID to a variable channel
                            {
                                channel = chan;
                            }
                        }
                        foreach (var user in guild.Users) //For each user in the server
                        {
                            //Retrieve the users steam ID from the database
                            string userID  = user.Id.ToString();
                            string steamID = null;
                            while (steamID == null && !user.IsBot)
                            {
                                steamID = DataStorage.getSteamID(userID).Result;
                            }

                            //If the user is not a bot
                            if (!user.IsBot)
                            {
                                //Get the data from the Steam API for the game that the current Steam ID is playing
                                var    gameResponse = steamInterface.GetPlayerSummaryAsync(Convert.ToUInt64(steamID));
                                string game         = gameResponse.Result.Data.PlayingGameName;
                                string gameID       = gameResponse.Result.Data.PlayingGameId;
                                var    store        = steamStoreIntferace.GetStoreAppDetailsAsync(Convert.ToUInt32(gameID));
                                string imageURL     = store.Result.HeaderImage;


                                if (game == null)
                                {
                                    game = "none";
                                }
                                string checkGame = DataStorage.getNowPlaying(userID); //Gets the nowPlaying value from the database

                                //If the game in the current users row for nowPlaying in the database does not match the report from the Steam API
                                //A change has occured and the user is now playing a game so create an embed and post it to the channel as an alert.
                                if (game.Trim() != checkGame.Trim())
                                {
                                    embed.WithTitle(user.Username + " Is Now Playing: " + game);
                                    embed.WithColor(0, 173, 238);

                                    if (imageURL == null)
                                    {
                                        game     = "none";
                                        gameID   = "none";
                                        imageURL = "none";
                                    }
                                    DataStorage.setNowPlaying(userID, game);

                                    if (game != "none")
                                    {
                                        embed.WithImageUrl(imageURL);

                                        //await channel.SendMessageAsync("", false, embed);
                                    }
                                }
                            }
                        }
                    }
                }
                count = 1; //Increments the count variable to ensure the initial check does not happen twice.
            }
            catch (Exception exc)
            {
            }
        }