diff --git a/Directory.Build.props b/Directory.Build.props index 9448230..5eb1c24 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -7,9 +7,9 @@ true true - 1.0.4.0 - 1.0.4.0 - 1.0.4.0 - 1.0.4.0 + 1.0.5.0 + 1.0.5.0 + 1.0.5.0 + 1.0.5.0 diff --git a/src/BililiveNotification/Apis/BiliApis.GetRoomInfo.cs b/src/BililiveNotification/Apis/BiliApis.GetRoomInfo.cs index d44092b..80ade23 100644 --- a/src/BililiveNotification/Apis/BiliApis.GetRoomInfo.cs +++ b/src/BililiveNotification/Apis/BiliApis.GetRoomInfo.cs @@ -1,4 +1,4 @@ -using BililiveNotification.Models; +using BililiveNotification.Models; using Executorlibs.Shared.Exceptions; using Executorlibs.Shared.Extensions; using System; @@ -24,7 +24,7 @@ public static async Task GetRoomInfoAsync(HttpClient client, int roomI throw new UnknownResponseException(in root); } JsonElement data = root.GetProperty("data"); - int userId = data.GetProperty("uid").GetInt32(); + long userId = data.GetProperty("uid").GetInt64(); UserInfo userInfo = await GetUserInfoAsync(client, userId, token); string? cover = data.GetProperty("user_cover").GetString(); if (cover == "") diff --git a/src/BililiveNotification/Apis/BiliApis.GetUserInfo.cs b/src/BililiveNotification/Apis/BiliApis.GetUserInfo.cs index 80be26c..dda87e3 100644 --- a/src/BililiveNotification/Apis/BiliApis.GetUserInfo.cs +++ b/src/BililiveNotification/Apis/BiliApis.GetUserInfo.cs @@ -11,7 +11,7 @@ namespace BililiveNotification.Apis { public static partial class BiliApis { - public static async Task GetUserInfoAsync(HttpClient client, int userId, CancellationToken token = default) + public static async Task GetUserInfoAsync(HttpClient client, long userId, CancellationToken token = default) { HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Get, $"https://api.bilibili.com/x/web-interface/card?mid={userId}"); req.Headers.Accept.ParseAdd("*/*"); diff --git a/src/BililiveNotification/MainWindow.xaml b/src/BililiveNotification/MainWindow.xaml index 0468544..ad6f532 100644 --- a/src/BililiveNotification/MainWindow.xaml +++ b/src/BililiveNotification/MainWindow.xaml @@ -19,6 +19,7 @@ + diff --git a/src/BililiveNotification/Models/RoomInfo.cs b/src/BililiveNotification/Models/RoomInfo.cs index f60eda2..b4d74df 100644 --- a/src/BililiveNotification/Models/RoomInfo.cs +++ b/src/BililiveNotification/Models/RoomInfo.cs @@ -1,16 +1,16 @@ -namespace BililiveNotification.Models +namespace BililiveNotification.Models { public class RoomInfo { public string UserName { get; } - public int UserId { get; } + public long UserId { get; } public string FaceUrl { get; } public string? CoverUrl { get; } - public RoomInfo(string userName, int userId, string faceUrl, string? coverUrl) + public RoomInfo(string userName, long userId, string faceUrl, string? coverUrl) { UserName = userName; UserId = userId; diff --git a/src/BililiveNotification/Models/UserInfo.cs b/src/BililiveNotification/Models/UserInfo.cs index 01270d6..725d03c 100644 --- a/src/BililiveNotification/Models/UserInfo.cs +++ b/src/BililiveNotification/Models/UserInfo.cs @@ -1,14 +1,14 @@ -namespace BililiveNotification.Models +namespace BililiveNotification.Models { public class UserInfo { public string UserName { get; } - public int UserId { get; } + public long UserId { get; } public string FaceUrl { get; } - public UserInfo(string userName, int userId, string faceUrl) + public UserInfo(string userName, long userId, string faceUrl) { UserName = userName; UserId = userId; diff --git a/src/BililiveNotification/RoomMonitor.cs b/src/BililiveNotification/RoomMonitor.cs index a032836..d02a059 100644 --- a/src/BililiveNotification/RoomMonitor.cs +++ b/src/BililiveNotification/RoomMonitor.cs @@ -1,4 +1,4 @@ -using BililiveNotification.Apis; +using BililiveNotification.Apis; using BililiveNotification.Models; using Executorlibs.Bilibili.Protocol.Clients; using Executorlibs.Bilibili.Protocol.Handlers; @@ -40,6 +40,8 @@ public sealed class RoomMonitor : IDisposable, public event PropertyChangedEventHandler? PropertyChanged; + private string? _masterName; + private DateTime _lastTime; private bool _status; @@ -67,6 +69,19 @@ public bool LiveStatus } } + public string? MasterName + { + get => _masterName; + set + { + if (_masterName != value) + { + _masterName = value; + OnPropertyChanged(); + } + } + } + public int RoomId { get; } public string StatusDisplay => _status ? "启用" : "禁用"; @@ -159,6 +174,15 @@ public async Task InitializeAsync() _lastTime = time.Value; OnPropertyChanged(nameof(LiveStatusDisplay)); } + try + { + var roomInfo = await BiliApis.GetRoomInfoAsync(_httpClient, RoomId); + MasterName = roomInfo.UserName; + } + catch (Exception) + { + MasterName = "<获取失败>"; + } await StartAsync(); }