-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
299 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ASFEnhance.Command; | ||
class CommandHandler | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ASFEnhance.Data; | ||
internal sealed record GetOwnedGamesResponse | ||
{ | ||
[JsonProperty("response")] | ||
public ResponseData? Response { get; set; } | ||
|
||
internal sealed record ResponseData | ||
{ | ||
[JsonProperty("game_count")] | ||
public uint GameCount { get; set; } | ||
|
||
[JsonProperty("games")] | ||
public List<GameData>? Games { get; set; } | ||
} | ||
|
||
internal sealed record GameData | ||
{ | ||
[JsonProperty("appid")] | ||
public uint AppId { get; set; } | ||
|
||
[JsonProperty("name")] | ||
public string? Name { get; set; } | ||
|
||
[JsonProperty("playtime_2weeks")] | ||
public uint PlayTime2Weeks { get; set; } | ||
|
||
[JsonProperty("playtime_forever")] | ||
public uint PlayTimeForever { get; set; } | ||
|
||
[JsonProperty("has_community_visible_stats")] | ||
public bool HasCommunityVisibleStats { get; set; } | ||
|
||
[JsonProperty("playtime_windows_forever")] | ||
public uint PlaytimeWindowsForever { get; set; } | ||
|
||
[JsonProperty("playtime_mac_forever")] | ||
public uint PlaytimeMacForever { get; set; } | ||
|
||
[JsonProperty("playtime_linux_forever")] | ||
public uint PlaytimeLinuxForever { get; set; } | ||
|
||
[JsonProperty("rtime_last_played")] | ||
public ulong RtimeLastPlayed { get; set; } | ||
|
||
[JsonProperty("playtime_disconnected")] | ||
public uint PlaytimeDisconnected { get; set; } | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using ArchiSteamFarm.Core; | ||
using ArchiSteamFarm.Web.Responses; | ||
using ASFEnhance.Data; | ||
|
||
namespace ASFEnhance.ExpansionUtils; | ||
|
||
/// <summary> | ||
/// 插件更新相关 | ||
/// </summary> | ||
public static class Update | ||
{ | ||
public static Uri GetGitHubApiUri(string repo, bool useMirror) | ||
{ | ||
var addr = useMirror ? | ||
$"https://hub.chrxw.com/{repo}/releases/latest" : | ||
$"https://api.github.com/repos/chr233/{repo}/releases/latest"; | ||
|
||
return new Uri(addr); | ||
} | ||
|
||
/// <summary> | ||
/// 获取最新的发行版 | ||
/// </summary> | ||
/// <returns></returns> | ||
public static async Task<GitHubReleaseResponse?> GetLatestRelease(string repo, bool useMirror) | ||
{ | ||
var request = GetGitHubApiUri(repo, useMirror); | ||
var response = await ASF.WebBrowser!.UrlGetToJsonObject<GitHubReleaseResponse>(request).ConfigureAwait(false); | ||
|
||
if (response == null && useMirror) | ||
{ | ||
return await GetLatestRelease(repo, false).ConfigureAwait(false); | ||
} | ||
|
||
return response?.Content; | ||
} | ||
|
||
/// <summary> | ||
/// 下载发行版 | ||
/// </summary> | ||
/// <param name="downloadUrl"></param> | ||
/// <returns></returns> | ||
public static async Task<BinaryResponse?> DownloadRelease(string? downloadUrl) | ||
{ | ||
if (string.IsNullOrEmpty(downloadUrl)) | ||
{ | ||
return null; | ||
} | ||
|
||
var request = new Uri(downloadUrl); | ||
var response = await ASF.WebBrowser!.UrlGetToBinary(request).ConfigureAwait(false); | ||
return response; | ||
} | ||
} |