/// <summary> /// Command to check the updatedness of a version string. /// </summary> public void CMD_VersionCheck(string[] cmds, SocketMessage message) { if (cmds.Length == 0) { SendErrorMessageReply(message, "Command Syntax Incorrect", "`!versioncheck <version text>`"); return; } string combined = string.Join(" ", cmds).Trim(); if (combined.ToLowerFast().StartsWith("loading ")) { combined = combined.Substring("loading ".Length).Trim(); } if (combined.IsEmpty()) { SendErrorMessageReply(message, "Bad Input", "Input text doesn't look like a version string (blank input?)."); return; } string projectName = BuildNumberTracker.SplitToNameAndVersion(combined, out string versionText).Replace(":", "").Trim(); versionText = versionText.Trim(); if (projectName.IsEmpty() || versionText.IsEmpty()) { SendErrorMessageReply(message, "Bad Input", "Input text doesn't look like a version string (single word input?)."); return; } if (BuildNumberTracker.TryGetBuildFor(projectName, versionText, out BuildNumberTracker.BuildNumber build, out int buildNum)) { if (build.IsCurrent(buildNum, out int behindBy)) { SendGenericPositiveMessageReply(message, "Running Current Build", $"That version is the current {build.Name} build."); } else { SendGenericNegativeMessageReply(message, "Build Outdated", $"That version is an outdated {build.Name} build.\nThe current {build.Name} build is {build.Value}.\nYou are behind by {behindBy} builds."); } return; } SendErrorMessageReply(message, "Bad Input", $"Input project name (`{EscapeUserInput(projectName)}`) doesn't look like any tracked project (or the version text is formatted incorrectly)."); return; }
/// <summary> /// Command to check the updatedness of a version string. /// </summary> public void CMD_VersionCheck(string[] cmds, IUserMessage message) { if (cmds.Length == 0) { SendErrorMessageReply(message, "Command Syntax Incorrect", "`!versioncheck <version text>`"); return; } string combined = string.Join(" ", cmds).Trim(); if (combined.ToLowerFast().StartsWith("loading ")) { combined = combined.Substring("loading ".Length).Trim(); } if (combined.IsEmpty()) { SendErrorMessageReply(message, "Bad Input", "Input text doesn't look like a version string (blank input?)."); return; } string projectName = BuildNumberTracker.SplitToNameAndVersion(combined, out string versionText).Replace(":", "").Trim(); versionText = versionText.Trim(); if (projectName.IsEmpty() || versionText.IsEmpty()) { SendErrorMessageReply(message, "Bad Input", "Input text doesn't look like a version string (single word input?)."); return; } string nameLower = projectName.ToLowerFast(); if (nameLower == "paper" || nameLower == "spigot" || nameLower == "craftbukkit") { string output = LogChecker.ServerVersionStatusOutput(combined, out bool isGood); if (string.IsNullOrWhiteSpace(output)) { SendErrorMessageReply(message, "Bad Input", $"Input text looks like a {nameLower} version, but doesn't fit the expected {nameLower} server version format. Should start with '{nameLower} version git-{nameLower}-...'"); return; } if (isGood) { SendGenericPositiveMessageReply(message, "Running Current Build", $"That version is the current {nameLower} build for an acceptable server version."); } else { SendGenericNegativeMessageReply(message, "Build Outdated", $"{output}."); } return; } if (BuildNumberTracker.TryGetBuildFor(projectName, versionText, out BuildNumberTracker.BuildNumber build, out int buildNum)) { if (build.IsCurrent(buildNum, out int behindBy)) { SendGenericPositiveMessageReply(message, "Running Current Build", $"That version is the current {build.Name} build."); } else { SendGenericNegativeMessageReply(message, "Build Outdated", $"That version is an outdated {build.Name} build.\nThe current {build.Name} build is {build.Value}.\nYou are behind by {behindBy} builds."); } return; } SendErrorMessageReply(message, "Bad Input", $"Input project name (`{EscapeUserInput(projectName)}`) doesn't look like any tracked project (or the version text is formatted incorrectly)."); return; }