mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat: new stats embed / api
This commit is contained in:
parent
e88d6b7e2a
commit
9f8d3d22d2
8 changed files with 215 additions and 100 deletions
|
|
@ -4,20 +4,21 @@ public static class BuildInfoService
|
|||
{
|
||||
public static string Version { get; private set; }
|
||||
public static string FullVersion { get; private set; }
|
||||
public static string Timestamp { get; private set; }
|
||||
public static bool IsDev { get; private set; }
|
||||
|
||||
public static async Task LoadVersion()
|
||||
{
|
||||
using (var stream = typeof(BuildInfoService).Assembly.GetManifestResourceStream("version"))
|
||||
{
|
||||
// if this happens, something broke
|
||||
if (stream == null) FullVersion = "(unknown version) ";
|
||||
else
|
||||
using (var reader = new StreamReader(stream))
|
||||
FullVersion = await reader.ReadToEndAsync();
|
||||
}
|
||||
using var stream = typeof(BuildInfoService).Assembly.GetManifestResourceStream("version");
|
||||
if (stream == null) throw new Exception("missing version information");
|
||||
|
||||
// cheap hack to remove newline
|
||||
FullVersion = FullVersion.Remove(FullVersion.Length - 1);
|
||||
using var reader = new StreamReader(stream);
|
||||
var data = (await reader.ReadToEndAsync()).Split("\n");
|
||||
|
||||
FullVersion = data[0];
|
||||
Timestamp = data[1];
|
||||
|
||||
IsDev = data[2] == "";
|
||||
|
||||
// show only short commit hash to users
|
||||
Version = FullVersion.Remove(7);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue