public override async Task OnCommand(CommandArguments command) { await Task.Yield(); if (command.Message.Length > 0) { return; } var commands = Commands .Where(cmd => cmd != this && (!cmd.IsAdminCommand || command.IsUserAdmin)) .Select(cmd => cmd.Trigger); command.Notice($"Available commands: {Colors.OLIVE}{string.Join($"{Colors.NORMAL}, {Colors.OLIVE}", commands)}"); }
public override async Task OnCommand(CommandArguments command) { await Task.Yield(); if (command.Message.Length > 0) { return; } // TODO: Correctly include commands for admins if an admin uses the command var commands = Commands .Where(cmd => !cmd.IsAdminCommand && cmd != this) .Select(cmd => cmd.Trigger); command.Notice("Available commands: {0}{1}", Colors.OLIVE, string.Join(string.Format("{0}, {1}", Colors.NORMAL, Colors.OLIVE), commands)); }
public override async Task OnCommand(CommandArguments command) { await Task.Yield(); if (command.Message.Length > 0) { return; } // TODO: Correctly include commands for admins if an admin uses the command var commands = Commands .Where(cmd => !cmd.IsAdminCommand && cmd != this) .Select(cmd => cmd.Trigger); command.Notice($"Available commands: {Colors.OLIVE}{string.Join($"{Colors.NORMAL}, {Colors.OLIVE}", commands)}"); }
public static void ReloadImportant(CommandArguments command) { ReloadImportant(); command.Notice("Reloaded {0} important apps and {1} packages", ImportantApps.Count, ImportantSubs.Count); }
public static void Reload(CommandArguments command) { Reload(); command.Notice($"Reloaded {AppTokens.Count} app tokens and {PackageTokens.Count} package tokens"); }
public override async Task OnCommand(CommandArguments command) { if (command.Message.Length == 0) { command.Reply("Usage:{0} pubfile <pubfileid>", Colors.OLIVE); return; } if (!ulong.TryParse(command.Message, out var pubFileId)) { command.Reply("Invalid Published File ID"); return; } var pubFileRequest = new CPublishedFile_GetDetails_Request { includeadditionalpreviews = true, includechildren = true, includetags = true, includekvtags = true, includevotes = true, includeforsaledata = true, includemetadata = true, }; pubFileRequest.publishedfileids.Add(pubFileId); var task = PublishedFiles.SendMessage(api => api.GetDetails(pubFileRequest)); task.Timeout = TimeSpan.FromSeconds(10); var callback = await task; var response = callback.GetDeserializedResponse <CPublishedFile_GetDetails_Response>(); var details = response.publishedfiledetails.FirstOrDefault(); if (details == null) { command.Reply("Unable to make service request for published file info: the server returned no info"); return; } var result = (EResult)details.result; if (result != EResult.OK) { command.Reply("Unable to get published file info: {0}{1}", Colors.RED, result); return; } var json = JsonConvert.SerializeObject(details, Formatting.Indented); File.WriteAllText(Path.Combine(Application.Path, "ugc", string.Format("{0}.json", details.publishedfileid)), json, Encoding.UTF8); command.Reply("{0}, Title: {1}{2}{3}, Creator: {4}{5}{6}, App: {7}{8}{9}{10}, File UGC: {11}{12}{13}, Preview UGC: {14}{15}{16} -{17} {18}", (EWorkshopFileType)details.file_type, Colors.BLUE, string.IsNullOrWhiteSpace(details.title) ? "[no title]" : details.title, Colors.NORMAL, Colors.BLUE, new SteamID(details.creator).Render(true), Colors.NORMAL, Colors.BLUE, details.creator_appid, details.creator_appid == details.consumer_appid ? "" : string.Format(" (consumer {0})", details.consumer_appid), Colors.NORMAL, Colors.BLUE, details.hcontent_file, Colors.NORMAL, Colors.BLUE, details.hcontent_preview, Colors.NORMAL, Colors.DARKBLUE, SteamDB.GetUGCURL(details.publishedfileid) ); command.Notice("{0} - https://steamcommunity.com/sharedfiles/filedetails/?id={1}", details.file_url, details.publishedfileid); }
public static void Reload(CommandArguments command) { Reload(); command.Notice("Reloaded {0} token overrides", SecretTokens.Count); }
public override async Task OnCommand(CommandArguments command) { await Task.Yield(); if (command.Message.Length == 0) { command.Reply("Usage:{0} players <appid or partial game name>", Colors.OLIVE); command.Notice("Use {0}^{1} and {2}${3} just like in regex to narrow down your match, e.g:{4} !players Portal$", Colors.BLUE, Colors.NORMAL, Colors.BLUE, Colors.NORMAL, Colors.OLIVE); return; } uint appID; string name; if (!uint.TryParse(command.Message, out appID)) { name = command.Message; if (!Utils.ConvertUserInputToSQLSearch(ref name)) { command.Reply("Your request is invalid or too short."); return; } using (var db = Database.GetConnection()) { appID = db.ExecuteScalar<uint>("SELECT `AppID` FROM `Apps` LEFT JOIN `AppsTypes` ON `Apps`.`AppType` = `AppsTypes`.`AppType` WHERE (`AppsTypes`.`Name` IN ('game', 'application', 'video', 'hardware') AND (`Apps`.`StoreName` LIKE @Name OR `Apps`.`Name` LIKE @Name)) OR (`AppsTypes`.`Name` = 'unknown' AND `Apps`.`LastKnownName` LIKE @Name) ORDER BY `LastUpdated` DESC LIMIT 1", new { Name = name }); } if (appID == 0) { command.Reply("Nothing was found matching your request."); return; } } KeyValue result; using (dynamic userStats = WebAPI.GetInterface("ISteamUserStats")) { userStats.Timeout = (int)TimeSpan.FromSeconds(5).TotalMilliseconds; try { result = userStats.GetNumberOfCurrentPlayers( appid: appID ); } catch (WebException e) { if (e.Status == WebExceptionStatus.Timeout) { throw new TaskCanceledException(); } var response = (HttpWebResponse)e.Response; command.Reply("Unable to request player count: {0}{1}", Colors.RED, response.StatusDescription); return; } } var eResult = (EResult)result["result"].AsInteger(); if (eResult != EResult.OK) { command.Reply("Unable to request player count: {0}{1}", Colors.RED, eResult); return; } if (appID == 0) { appID = 753; } string appType, type = "playing"; name = Steam.GetAppName(appID, out appType); switch (appType) { case "Tool": case "Config": case "Application": type = "using"; break; case "Legacy Media": case "Video": type = "watching"; break; case "Guide": type = "reading"; break; case "Hardware": type = "bricking"; break; } command.Reply( "People {0} {1}{2}{3} right now: {4}{5:N0}{6} -{7} {8}", type, Colors.BLUE, name, Colors.NORMAL, Colors.OLIVE, result["player_count"].AsInteger(), Colors.NORMAL, Colors.DARKBLUE, SteamDB.GetAppURL(appID, "graphs") ); }
public override async Task OnCommand(CommandArguments command) { await Task.Yield(); if (command.Message.Length == 0) { command.Reply("Usage:{0} players <appid or partial game name>", Colors.OLIVE); command.Notice("Use {0}^{1} and {2}${3} just like in regex to narrow down your match, e.g:{4} !players Portal$", Colors.BLUE, Colors.NORMAL, Colors.BLUE, Colors.NORMAL, Colors.OLIVE); return; } uint appID; string name; if (!uint.TryParse(command.Message, out appID)) { name = command.Message; if (!Utils.ConvertUserInputToSQLSearch(ref name)) { command.Reply("Your request is invalid or too short."); return; } using (var db = Database.GetConnection()) { appID = db.ExecuteScalar <uint>("SELECT `AppID` FROM `Apps` LEFT JOIN `AppsTypes` ON `Apps`.`AppType` = `AppsTypes`.`AppType` WHERE (`AppsTypes`.`Name` IN ('game', 'application', 'video', 'hardware') AND (`Apps`.`StoreName` LIKE @Name OR `Apps`.`Name` LIKE @Name)) OR (`AppsTypes`.`Name` = 'unknown' AND `Apps`.`LastKnownName` LIKE @Name) ORDER BY `LastUpdated` DESC LIMIT 1", new { Name = name }); } if (appID == 0) { command.Reply("Nothing was found matching your request."); return; } } KeyValue result; using (dynamic userStats = WebAPI.GetInterface("ISteamUserStats")) { userStats.Timeout = (int)TimeSpan.FromSeconds(5).TotalMilliseconds; try { result = userStats.GetNumberOfCurrentPlayers( appid: appID ); } catch (WebException e) { if (e.Status == WebExceptionStatus.Timeout) { throw new TaskCanceledException(); } var response = (HttpWebResponse)e.Response; command.Reply("Unable to request player count: {0}{1}", Colors.RED, response.StatusDescription); return; } } var eResult = (EResult)result["result"].AsInteger(); if (eResult != EResult.OK) { command.Reply("Unable to request player count: {0}{1}", Colors.RED, eResult); return; } if (appID == 0) { appID = 753; } string appType, type = "playing"; name = Steam.GetAppName(appID, out appType); switch (appType) { case "Tool": case "Config": case "Application": type = "using"; break; case "Legacy Media": case "Video": type = "watching"; break; case "Guide": type = "reading"; break; case "Hardware": type = "bricking"; break; } command.Reply( "People {0} {1}{2}{3} right now: {4}{5:N0}{6} -{7} {8}", type, Colors.BLUE, name, Colors.NORMAL, Colors.OLIVE, result["player_count"].AsInteger(), Colors.NORMAL, Colors.DARKBLUE, SteamDB.GetAppURL(appID, "graphs") ); }
public static async Task ReloadImportant(CommandArguments command) { await ReloadImportant(); command.Notice($"Reloaded {ImportantApps.Count} important apps and {ImportantSubs.Count} packages"); }
public override async Task OnCommand(CommandArguments command) { if (command.Message.Length == 0) { command.Reply("Usage:{0} pubfile <pubfileid>", Colors.OLIVE); return; } ulong pubFileId; if (!ulong.TryParse(command.Message, out pubFileId)) { command.Reply("Invalid Published File ID"); return; } var pubFileRequest = new CPublishedFile_GetDetails_Request { includeadditionalpreviews = true, includechildren = true, includetags = true, includekvtags = true, includevotes = true, includeforsaledata = true, includemetadata = true, }; pubFileRequest.publishedfileids.Add(pubFileId); var callback = await PublishedFiles.SendMessage(api => api.GetDetails(pubFileRequest)); var response = callback.GetDeserializedResponse<CPublishedFile_GetDetails_Response>(); var details = response.publishedfiledetails.FirstOrDefault(); if (details == null) { command.Reply("Unable to make service request for published file info: the server returned no info"); return; } var result = (EResult)details.result; if (result != EResult.OK) { command.Reply("Unable to get published file info: {0}{1}", Colors.RED, result); return; } var json = JsonConvert.SerializeObject(details, Formatting.Indented); File.WriteAllText(Path.Combine(Application.Path, "ugc", string.Format("{0}.json", details.publishedfileid)), json, Encoding.UTF8); command.Reply("{0}, Title: {1}{2}{3}, Creator: {4}{5}{6}, App: {7}{8}{9}{10}, File UGC: {11}{12}{13}, Preview UGC: {14}{15}{16} -{17} {18}", (EWorkshopFileType)details.file_type, Colors.BLUE, string.IsNullOrWhiteSpace(details.title) ? "[no title]" : details.title, Colors.NORMAL, Colors.BLUE, new SteamID(details.creator).Render(true), Colors.NORMAL, Colors.BLUE, details.creator_appid, details.creator_appid == details.consumer_appid ? "" : string.Format(" (consumer {0})", details.consumer_appid), Colors.NORMAL, Colors.BLUE, details.hcontent_file, Colors.NORMAL, Colors.BLUE, details.hcontent_preview, Colors.NORMAL, Colors.DARKBLUE, SteamDB.GetUGCURL(details.publishedfileid) ); command.Notice("{0} - https://steamcommunity.com/sharedfiles/filedetails/?id={1}", details.file_url, details.publishedfileid); }
public override async Task OnCommand(CommandArguments command) { var s = command.Message.Split(' '); var count = s.Length; if (count > 0) { uint id; switch (s[0]) { case "reload": await Application.ReloadImportant(); await PICSTokens.Reload(); command.Notice("Reloaded important apps and pics tokens"); return; case "fullrun": _ = TaskManager.Run(async() => { command.Reply("Started full metadata scan, this will take a while…"); await FullUpdateProcessor.FullUpdateAppsMetadata(true); command.Reply("App full scan finished, starting packages, this will take even longer…"); await FullUpdateProcessor.FullUpdatePackagesMetadata(); command.Reply("Full metadata scan finished."); }); return; case "add": if (count < 3) { break; } if (!uint.TryParse(s[2], out id)) { break; } switch (s[1]) { case "app": if (Application.ImportantApps.Contains(id)) { command.Reply($"App {Colors.BLUE}{id}{Colors.NORMAL} ({Steam.GetAppName(id)}) is already important."); } else { Application.ImportantApps.Add(id); await using (var db = await Database.GetConnectionAsync()) { await db.ExecuteAsync("INSERT INTO `ImportantApps` (`AppID`) VALUES (@AppID)", new { AppID = id }); } command.Reply($"Marked app {Colors.BLUE}{id}{Colors.NORMAL} ({Steam.GetAppName(id)}) as important."); } return; case "sub": if (Application.ImportantSubs.Contains(id)) { command.Reply($"Package {Colors.BLUE}{id}{Colors.NORMAL} ({Steam.GetPackageName(id)}) is already important."); } else { Application.ImportantSubs.Add(id); await using (var db = await Database.GetConnectionAsync()) { await db.ExecuteAsync("INSERT INTO `ImportantSubs` (`SubID`) VALUES (@SubID)", new { SubID = id }); } command.Reply($"Marked package {Colors.BLUE}{id}{Colors.NORMAL} ({Steam.GetPackageName(id)}) as important."); } return; } break; case "remove": if (count < 3) { break; } if (!uint.TryParse(s[2], out id)) { break; } switch (s[1]) { case "app": if (!Application.ImportantApps.Contains(id)) { command.Reply($"App {Colors.BLUE}{id}{Colors.NORMAL} ({Steam.GetAppName(id)}) is not important."); } else { Application.ImportantApps.Remove(id); await using (var db = await Database.GetConnectionAsync()) { await db.ExecuteAsync("DELETE FROM `ImportantApps` WHERE `AppID` = @AppID", new { AppID = id }); } command.Reply($"Removed app {Colors.BLUE}{id}{Colors.NORMAL} ({Steam.GetAppName(id)}) from the important list."); } return; case "sub": if (!Application.ImportantSubs.Contains(id)) { command.Reply($"Package {Colors.BLUE}{id}{Colors.NORMAL} ({Steam.GetPackageName(id)}) is not important."); } else { Application.ImportantSubs.Remove(id); await using (var db = await Database.GetConnectionAsync()) { await db.ExecuteAsync("DELETE FROM `ImportantSubs` WHERE `SubID` = @SubID", new { SubID = id }); } command.Reply($"Removed package {Colors.BLUE}{id}{Colors.NORMAL} ({Steam.GetPackageName(id)}) from the important list."); } return; } break; } } command.Reply($"Usage:{Colors.OLIVE} important reload {Colors.NORMAL}or{Colors.OLIVE} important <add/remove> <app/sub> <id> {Colors.NORMAL}or{Colors.OLIVE} important fullrun"); }
public override async Task OnCommand(CommandArguments command) { if (command.Message.Length == 0) { command.Reply("Usage:{0} players <appid or partial game name>", Colors.OLIVE); command.Notice("Use {0}^{1} and {2}${3} just like in regex to narrow down your match, e.g:{4} !players Portal$", Colors.BLUE, Colors.NORMAL, Colors.BLUE, Colors.NORMAL, Colors.OLIVE); return; } uint appID; string name; if (!uint.TryParse(command.Message, out appID)) { name = command.Message; if (!Utils.ConvertUserInputToSQLSearch(ref name)) { command.Reply("Your request is invalid or too short."); return; } using (var db = Database.GetConnection()) { appID = db.ExecuteScalar <uint>("SELECT `AppID` FROM `Apps` LEFT JOIN `AppsTypes` ON `Apps`.`AppType` = `AppsTypes`.`AppType` WHERE (`AppsTypes`.`Name` IN ('game', 'application', 'video', 'hardware') AND (`Apps`.`StoreName` LIKE @Name OR `Apps`.`Name` LIKE @Name)) OR (`AppsTypes`.`Name` = 'unknown' AND `Apps`.`LastKnownName` LIKE @Name) ORDER BY `LastUpdated` DESC LIMIT 1", new { Name = name }); } if (appID == 0) { command.Reply("Nothing was found matching your request."); return; } } var callback = await Steam.Instance.UserStats.GetNumberOfCurrentPlayers(appID); if (appID == 0) { appID = 753; } string appType, type = "playing"; name = Steam.GetAppName(appID, out appType); if (callback.Result != EResult.OK) { command.Reply("Unable to request player count for {0}{1}{2}: {3}{4}", Colors.BLUE, name, Colors.NORMAL, Colors.RED, callback.Result); return; } switch (appType) { case "Tool": case "Config": case "Application": type = "using"; break; case "Legacy Media": case "Video": type = "watching"; break; case "Guide": type = "reading"; break; case "Hardware": type = "bricking"; break; } command.Reply( "People {0} {1}{2}{3} right now: {4}{5:N0}{6} -{7} {8}", type, Colors.BLUE, name, Colors.NORMAL, Colors.OLIVE, callback.NumPlayers, Colors.NORMAL, Colors.DARKBLUE, SteamDB.GetAppURL(appID, "graphs") ); }