Ejemplo n.º 1
0
        private static async Task HandleApps(SteamApps.PICSChangesCallback callback)
        {
            await StoreQueue.AddAppToQueue(callback.AppChanges.Values.Select(x => x.ID));

            await using var db = await Database.GetConnectionAsync();

            await db.ExecuteAsync("INSERT INTO `ChangelistsApps` (`ChangeID`, `AppID`) VALUES (@ChangeNumber, @ID) ON DUPLICATE KEY UPDATE `AppID` = `AppID`", callback.AppChanges.Values);

            await db.ExecuteAsync("UPDATE `Apps` SET `LastUpdated` = CURRENT_TIMESTAMP() WHERE `AppID` IN @Ids", new { Ids = callback.AppChanges.Values.Select(x => x.ID) });
        }
Ejemplo n.º 2
0
        private void HandleApps(SteamApps.PICSChangesCallback callback)
        {
            StoreQueue.AddAppToQueue(callback.AppChanges.Values.Select(x => x.ID));

            using (var db = Database.GetConnection())
            {
                db.Execute("INSERT INTO `ChangelistsApps` (`ChangeID`, `AppID`) VALUES (@ChangeNumber, @ID) ON DUPLICATE KEY UPDATE `AppID` = `AppID`", callback.AppChanges.Values);

                db.Execute("UPDATE `Apps` SET `LastUpdated` = CURRENT_TIMESTAMP() WHERE `AppID` IN @Ids", new { Ids = callback.AppChanges.Values.Select(x => x.ID) });
            }
        }
Ejemplo n.º 3
0
        private async Task HandlePackages(SteamApps.PICSChangesCallback callback)
        {
            Dictionary <uint, byte> ignoredPackages;

            await using (var db = await Database.GetConnectionAsync())
            {
                ignoredPackages = (await db.QueryAsync("SELECT `SubID`, `SubID` FROM `SubsInfo` WHERE `SubID` IN @Subs AND `Key` = @Key AND `Value` IN @Types",
                                                       new
                {
                    Key = BillingTypeKey,
                    Subs = callback.PackageChanges.Values.Select(x => x.ID),
                    Types = IgnorableBillingTypes
                }
                                                       )).ToDictionary(x => (uint)x.SubID, _ => (byte)1);
            }

            // Steam comp
            if (!ignoredPackages.ContainsKey(0))
            {
                ignoredPackages.Add(0, 1);
            }

            // Anon dedi comp
            if (!ignoredPackages.ContainsKey(17906))
            {
                ignoredPackages.Add(17906, 1);
            }

            var subids = callback.PackageChanges.Values
                         .Select(x => x.ID).Where(x => !ignoredPackages.ContainsKey(x))
                         .ToList();

            if (subids.Count == 0)
            {
                return;
            }

            List <uint> appids;

            // Queue all the apps in the package as well
            await using (var db = await Database.GetConnectionAsync())
            {
                appids = (await db.QueryAsync <uint>("SELECT `AppID` FROM `SubsApps` WHERE `SubID` IN @Ids AND `Type` = 'app'", new { Ids = subids })).ToList();
            }

            if (appids.Count > 0)
            {
                await StoreQueue.AddAppToQueue(appids);
            }

            await StoreQueue.AddPackageToQueue(subids);
        }
Ejemplo n.º 4
0
        public override async Task OnCommand(CommandArguments command)
        {
            var s = command.Message.Split(' ');

            if (s.Length < 2)
            {
                command.Reply("Usage:{0} queue <app/sub> <id>", Colors.OLIVE);

                return;
            }

            if (!uint.TryParse(s[1], out var id))
            {
                command.Reply("Your ID does not look like a number.");

                return;
            }

            string name;

            switch (s[0])
            {
            case "app":
                using (var db = Database.Get())
                {
                    name = await db.ExecuteScalarAsync <string>("SELECT `Name` FROM `Apps` WHERE `AppID` = @AppID", new { AppID = id });
                }

                if (!string.IsNullOrEmpty(name))
                {
                    await StoreQueue.AddAppToQueue(id);

                    command.Reply("App {0}{1}{2} ({3}) has been added to the store update queue.", Colors.BLUE, id, Colors.NORMAL, Utils.RemoveControlCharacters(name));

                    return;
                }

                command.Reply("This app is not in the database.");

                return;

            case "package":
            case "sub":
                if (id == 0)
                {
                    command.Reply("Sub 0 can not be queued.");

                    return;
                }

                using (var db = Database.Get())
                {
                    name = await db.ExecuteScalarAsync <string>("SELECT `Name` FROM `Subs` WHERE `SubID` = @SubID", new { SubID = id });
                }

                if (!string.IsNullOrEmpty(name))
                {
                    await StoreQueue.AddPackageToQueue(id);

                    command.Reply("Package {0}{1}{2} ({3}) has been added to the store update queue.", Colors.BLUE, id, Colors.NORMAL, Utils.RemoveControlCharacters(name));

                    return;
                }

                command.Reply("This package is not in the database.");

                return;

            default:
                command.Reply("You can only queue apps and packages.");

                return;
            }
        }
Ejemplo n.º 5
0
        public override void OnCommand(CommandArguments command)
        {
            if (command.CommandType != ECommandType.IRC || !IRC.IsRecipientChannel(command.Recipient))
            {
                CommandHandler.ReplyToCommand(command, "This command is only available in channels.");

                return;
            }

            var channel = command.Recipient;

            var s     = command.Message.Split(' ');
            var count = s.Length;

            if (count > 0)
            {
                switch (s[0])
                {
                case "reload":
                {
                    Application.ReloadImportant(command);
                    PICSTokens.Reload(command);
                    FileDownloader.ReloadFileList();

                    return;
                }

                case "add":
                {
                    if (count < 3)
                    {
                        break;
                    }

                    uint id;

                    if (!uint.TryParse(s[2], out id))
                    {
                        break;
                    }

                    switch (s[1])
                    {
                    case "app":
                    {
                        List <string> channels;
                        var           exists = Application.ImportantApps.TryGetValue(id, out channels);

                        if (exists && channels.Contains(channel))
                        {
                            CommandHandler.ReplyToCommand(command, "App {0}{1}{2} ({3}) is already important in {4}{5}{6}.", Colors.BLUE, id, Colors.NORMAL, Steam.GetAppName(id), Colors.BLUE, channel, Colors.NORMAL);
                        }
                        else
                        {
                            if (exists)
                            {
                                Application.ImportantApps[id].Add(channel);
                            }
                            else
                            {
                                Application.ImportantApps.Add(id, new List <string> {
                                            channel
                                        });
                            }

                            using (var db = Database.GetConnection())
                            {
                                db.Execute("INSERT INTO `ImportantApps` (`AppID`, `Channel`) VALUES (@AppID, @Channel)", new { AppID = id, Channel = channel });
                            }

                            CommandHandler.ReplyToCommand(command, "Marked app {0}{1}{2} ({3}) as important in {4}{5}{6}.", Colors.BLUE, id, Colors.NORMAL, Steam.GetAppName(id), Colors.BLUE, channel, Colors.NORMAL);
                        }

                        return;
                    }

                    case "sub":
                    {
                        if (Application.ImportantSubs.ContainsKey(id))
                        {
                            CommandHandler.ReplyToCommand(command, "Package {0}{1}{2} ({3}) is already important.", Colors.BLUE, id, Colors.NORMAL, Steam.GetPackageName(id));
                        }
                        else
                        {
                            Application.ImportantSubs.Add(id, 1);

                            using (var db = Database.GetConnection())
                            {
                                db.Execute("INSERT INTO `ImportantSubs` (`SubID`) VALUES (@SubID)", new { SubID = id });
                            }

                            CommandHandler.ReplyToCommand(command, "Marked package {0}{1}{2} ({3}) as important.", Colors.BLUE, id, Colors.NORMAL, Steam.GetPackageName(id));
                        }

                        return;
                    }
                    }

                    break;
                }

                case "remove":
                {
                    if (count < 3)
                    {
                        break;
                    }

                    uint id;

                    if (!uint.TryParse(s[2], out id))
                    {
                        break;
                    }

                    switch (s[1])
                    {
                    case "app":
                    {
                        List <string> channels;

                        if (!Application.ImportantApps.TryGetValue(id, out channels) || !channels.Contains(channel))
                        {
                            CommandHandler.ReplyToCommand(command, "App {0}{1}{2} ({3}) is not important in {4}{5}{6}.", Colors.BLUE, id, Colors.NORMAL, Steam.GetAppName(id), Colors.BLUE, channel, Colors.NORMAL);
                        }
                        else
                        {
                            if (channels.Count > 1)
                            {
                                Application.ImportantApps[id].Remove(channel);
                            }
                            else
                            {
                                Application.ImportantApps.Remove(id);
                            }

                            using (var db = Database.GetConnection())
                            {
                                db.Execute("DELETE FROM `ImportantApps` WHERE `AppID` = @AppID AND `Channel` = @Channel", new { AppID = id, Channel = channel });
                            }

                            CommandHandler.ReplyToCommand(command, "Removed app {0}{1}{2} ({3}) from the important list in {4}{5}{6}.", Colors.BLUE, id, Colors.NORMAL, Steam.GetAppName(id), Colors.BLUE, channel, Colors.NORMAL);
                        }

                        return;
                    }

                    case "sub":
                    {
                        if (!Application.ImportantSubs.ContainsKey(id))
                        {
                            CommandHandler.ReplyToCommand(command, "Package {0}{1}{2} ({3}) is not important.", Colors.BLUE, id, Colors.NORMAL, Steam.GetPackageName(id));
                        }
                        else
                        {
                            Application.ImportantSubs.Remove(id);

                            using (var db = Database.GetConnection())
                            {
                                db.Execute("DELETE FROM `ImportantSubs` WHERE `SubID` = @SubID", new { SubID = id });
                            }

                            CommandHandler.ReplyToCommand(command, "Removed package {0}{1}{2} ({3}) from the important list.", Colors.BLUE, id, Colors.NORMAL, Steam.GetPackageName(id));
                        }

                        return;
                    }
                    }

                    break;
                }

                case "queue":
                {
                    if (count < 3)
                    {
                        break;
                    }

                    uint id;

                    if (!uint.TryParse(s[2], out id))
                    {
                        break;
                    }

                    switch (s[1])
                    {
                    case "app":
                    {
                        string name;

                        using (var db = Database.GetConnection())
                        {
                            name = db.ExecuteScalar <string>("SELECT `Name` FROM `Apps` WHERE `AppID` = @AppID", new { AppID = id });
                        }

                        if (!string.IsNullOrEmpty(name))
                        {
                            StoreQueue.AddAppToQueue(id);

                            CommandHandler.ReplyToCommand(command, "App {0}{1}{2} ({3}) has been added to the store update queue.", Colors.BLUE, id, Colors.NORMAL, Utils.RemoveControlCharacters(name));

                            return;
                        }

                        CommandHandler.ReplyToCommand(command, "This app is not in the database.");

                        return;
                    }

                    case "sub":
                    {
                        if (id == 0)
                        {
                            CommandHandler.ReplyToCommand(command, "Sub 0 can not be queued.");

                            return;
                        }

                        string name;

                        using (var db = Database.GetConnection())
                        {
                            name = db.ExecuteScalar <string>("SELECT `Name` FROM `Subs` WHERE `SubID` = @SubID", new { SubID = id });
                        }

                        if (!string.IsNullOrEmpty(name))
                        {
                            StoreQueue.AddPackageToQueue(id);

                            CommandHandler.ReplyToCommand(command, "Package {0}{1}{2} ({3}) has been added to the store update queue.", Colors.BLUE, id, Colors.NORMAL, Utils.RemoveControlCharacters(name));

                            return;
                        }

                        CommandHandler.ReplyToCommand(command, "This package is not in the database.");

                        return;
                    }
                    }

                    break;
                }
                }
            }

            CommandHandler.ReplyToCommand(command, "Usage:{0} important reload {1}or{2} important <add/remove/queue> <app/sub> <id>", Colors.OLIVE, Colors.NORMAL, Colors.OLIVE);
        }
Ejemplo n.º 6
0
        public override async Task OnCommand(CommandArguments command)
        {
            var s = command.Message.Split(' ');

            if (s.Length < 2)
            {
                command.Reply("Usage:{0} queue <app/sub> <id>", Colors.OLIVE);

                return;
            }

            if (!uint.TryParse(s[1], out var id))
            {
                command.Reply("Your ID does not look like a number.");

                return;
            }

            switch (s[0])
            {
            case "app":
                var appName = Steam.GetAppName(id);

                if (!string.IsNullOrEmpty(appName))
                {
                    await StoreQueue.AddAppToQueue(id);

                    command.Reply("App {0}{1}{2} ({3}) has been added to the store update queue.", Colors.BLUE, id, Colors.NORMAL, appName);

                    return;
                }

                command.Reply("This app is not in the database.");

                return;

            case "package":
            case "sub":
                if (id == 0)
                {
                    command.Reply("Sub 0 can not be queued.");

                    return;
                }

                var subName = Steam.GetPackageName(id);

                if (!string.IsNullOrEmpty(subName))
                {
                    await StoreQueue.AddPackageToQueue(id);

                    command.Reply("Package {0}{1}{2} ({3}) has been added to the store update queue.", Colors.BLUE, id, Colors.NORMAL, subName);

                    return;
                }

                command.Reply("This package is not in the database.");

                return;

            default:
                command.Reply("You can only queue apps and packages.");

                return;
            }
        }