public async Task CallBilibiliBeginLiveAsync(VtuberEntity vtuber, BilibiliLiveRoom room) { using (var client = HttpClientExtensions.CreateClient()) { var body = new BilibiliLiveCallbackBody() { VtuberName = vtuber.OriginalName, LiveLink = "https://live.bilibili.com/" + vtuber.BilibiliLiveRoomId, LiveTitle = room.Title, StartTime = DateTime.Now.ToTimestamp(), Sign = Sign }; await client.PostJsonAsync(Url + "bilibili/live", body); } }
public void CallBilibiliBeginLive(BilibiliLiveCallbackBody body) { foreach (var vtuberBot in Bots) { var groups = vtuberBot.GetGroupsAsync().GetAwaiter().GetResult(); if (groups == null) { continue; } foreach (var groupInfo in groups) { var config = Config.DefaultConfig.GroupConfigs.FirstOrDefault(v => v.GroupId == groupInfo.GroupId) ?.PublishConfigs.FirstOrDefault(v => v.VtuberName == body.VtuberName); if (config == null || !config.BilibiliBeginLive) { continue; } vtuberBot.GetSendingService().SendGroupMessageAsync(groupInfo.GroupId, $"{body.VtuberName} 于 {DateTimeExtensions.TimestampToDateTime(body.StartTime):yyyy-MM-dd HH:mm:ss} 在B站开始了直播\r\n{body.LiveTitle}\r\b{body.LiveLink}") .GetAwaiter().GetResult(); } } }