MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / CheckVersion

Method CheckVersion

KBotExt/Misc.h:74–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72 }
73
74 static void CheckVersion()
75 {
76 const std::string getLatest = cpr::Get(cpr::Url{ "https://api.github.com/repos/KebsCS/KBotExt/releases/latest" }).text;
77
78 if (getLatest.contains("API rate limit"))
79 return;
80
81 const Json::CharReaderBuilder builder;
82 const std::unique_ptr<Json::CharReader> reader(builder.newCharReader());
83 JSONCPP_STRING err;
84 Json::Value root;
85 if (reader->parse(getLatest.c_str(), getLatest.c_str() + static_cast<int>(getLatest.length()), &root, &err))
86 {
87 std::string latestTag = root["tag_name"].asString();
88 latestVersion = latestTag;
89
90 const std::vector<std::string> latestNameSplit = Utils::StringSplit(latestTag, ".");
91 const std::vector<std::string> programVersionSplit = Utils::StringSplit(programVersion, ".");
92
93 for (size_t i = 0; i < 2; i++)
94 {
95 if (latestNameSplit[i] != programVersionSplit[i])
96 {
97 if (MessageBoxA(nullptr, "Open download website?", "New major version available", MB_YESNO | MB_SETFOREGROUND) == IDYES)
98 {
99 Utils::OpenUrl(L"https://github.com/KebsCS/KBotExt/releases/latest", nullptr, SW_SHOW);
100 }
101 }
102 }
103 if (latestTag != programVersion
104 && std::ranges::find(S.ignoredVersions, latestTag) == S.ignoredVersions.end())
105 {
106 if (const auto status = MessageBoxA(nullptr, "Open download website?\nCancel to ignore this version forever",
107 "New minor update available", MB_YESNOCANCEL | MB_SETFOREGROUND); status == IDYES)
108 {
109 Utils::OpenUrl(L"https://github.com/KebsCS/KBotExt/releases/latest", nullptr, SW_SHOW);
110 }
111 else if (status == IDCANCEL)
112 {
113 S.ignoredVersions.emplace_back(latestTag);
114 Config::Save();
115 }
116 }
117 }
118 }
119
120 static void CheckPrerelease(std::string newName = "")
121 {

Callers

nothing calls this directly

Calls 3

findFunction · 0.85
c_strMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected