public YoutubeLiveChatRecorder(string liveChatId, VtuberEntity vtuber, string videoId) { LiveChatId = liveChatId; Vtuber = vtuber; VideoId = videoId; _chatCollection = Program.Database.GetCollection <YoutubeLiveChat>("youtube-live-chats"); }
private static async void VtuberRetweetedEvent(VtuberEntity vtuber, TweetInfo tweet) { LogHelper.Info($"Vtuber [{vtuber.OriginalName}] 转发了 {tweet.RetweetedTweet.User.Name} 的推特: {tweet.Content}"); foreach (var api in CallbackApis) { await api.CallRetweetedAsync(vtuber, tweet); } }
private static async void VtuberStoppedYoutubeLiveEvent(VtuberEntity vtuber, YoutubeVideo liveVideo) { LogHelper.Info($"Vtuber [{vtuber.OriginalName}] 结束了直播."); foreach (var api in CallbackApis) { await api.CallYoutubeStopLiveAsync(vtuber, liveVideo); } }
private static async void VtuberBeginBilibiliLiveEvent(VtuberEntity vtuber, BilibiliLiveRoom room) { LogHelper.Info($"Vtuber [{vtuber.OriginalName}] 在B站开始了直播 {room.Title}"); foreach (var api in CallbackApis) { await api.CallBilibiliBeginLiveAsync(vtuber, room); } }
private static async void VtuberCommentedYoutubeLiveEvent(VtuberEntity author, VtuberEntity target, YoutubeLiveChat message, YoutubeVideo video) { LogHelper.Info($"Vtuber [{author.OriginalName}] 在 [{target.OriginalName}] 的Youtube直播 {video.VideoLink} 中发布了评论: {message.DisplayMessage}"); foreach (var api in CallbackApis) { await api.CallYoutubeCommentedAsync(author, target, message); } }
private static async void VtuberBeginYoutubeLiveEvent(VtuberEntity vtuber, YoutubeVideo liveVideo) { LogHelper.Info($"Vtuber [{vtuber.OriginalName}] 在Youtube开始了直播 {liveVideo.VideoLink} ({liveVideo.Title})"); foreach (var api in CallbackApis) { await api.CallYoutubeBeginLiveAsync(vtuber, liveVideo); } }
private static async void VtuberPublishTweetEvent(VtuberEntity vtuber, TweetInfo tweet) { LogHelper.Info($"Vtuber [{vtuber.OriginalName}] 发布了新的推特 {tweet.Content}"); foreach (var api in CallbackApis) { await api.CallPublishTweetAsync(vtuber, tweet); } }
private static async void VtuberReplyTweetEvent(VtuberEntity vtuber, TweetInfo tweet) { LogHelper.Info($"Vtuber [{vtuber.OriginalName}] 回复了 {tweet.ReplyScreenname} 的推特 {tweet.Content}"); foreach (var api in CallbackApis) { await api.CallReplyAsync(vtuber, tweet); } }
public async Task <IActionResult> RefreshVtuber([FromQuery] string uid) { if (string.IsNullOrEmpty(uid)) { return(Json(new { error = 1, message = "UID cannot be empty or null" })); } var dbVtubers = await VtuberDatabaseApi.GetDatabaseEntitiesAsync(); var localVtubers = (await _vtuberCollection.FindAsync(v => true)).ToList(); var fromVtuber = dbVtubers.FirstOrDefault(v => v.Uuid == uid); if (fromVtuber == null) { return(Json(new { error = 2, message = $"UID {uid} not found in vdb." })); } var targetVtuber = localVtubers.FirstOrDefault(v => v.VtuberDatabaseUuid == uid || v.OriginalName == fromVtuber.DefaultName); if (targetVtuber != null) { targetVtuber.BilibiliUserId = long.Parse(fromVtuber.GetAccountIdByPlatform("bilibili")); targetVtuber.VtuberDatabaseUuid = fromVtuber.Uuid; await _vtuberCollection.ReplaceOneAsync(v => v.Id == targetVtuber.Id, targetVtuber, new UpdateOptions() { IsUpsert = true }); return(Json(new { error = 0, message = "refresh completed." })); } targetVtuber = new VtuberEntity() { Id = ObjectId.GenerateNewId(), OriginalName = fromVtuber.DefaultName, VtuberDatabaseUuid = fromVtuber.Uuid, YoutubeChannelId = fromVtuber.GetAccountIdByPlatform("youtube"), TwitterProfileId = fromVtuber.GetAccountIdByPlatform("twitter"), BilibiliUserId = long.Parse(fromVtuber.GetAccountIdByPlatform("bilibili")) }; await _vtuberCollection.InsertOneAsync(targetVtuber); return(Json(new { error = 0, message = "refresh completed." })); }
public async Task CallYoutubeUploadVideoAsync(VtuberEntity vtuber, YoutubeVideo video) { using (var client = HttpClientExtensions.CreateClient()) { var body = new YoutubeVideoCallbackBody() { VtuberName = vtuber.OriginalName, VideoLink = video.VideoLink, VideoTitle = video.Title, PublishTime = video.PublishTime.ToTimestamp(), Sign = Sign }; await client.PostJsonAsync(Url + "youtube/video", body); } }
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 async Task CallYoutubeCommentedAsync(VtuberEntity commentAuthor, VtuberEntity liveAuthor, YoutubeLiveChat comment) { using (var client = HttpClientExtensions.CreateClient()) { var body = new YoutubeLiveChatCallbackBody() { VtuberName = commentAuthor.OriginalName, LiveAuthorName = liveAuthor.OriginalName, LiveLink = "https://www.youtube.com/watch?v=" + comment.VideoId, Message = comment.DisplayMessage, PublishTime = comment.PublishTime.ToTimestamp(), Sign = Sign }; await client.PostJsonAsync(Url + "youtube/live/vtuberCommented", body); } }
public async Task CallYoutubeStopLiveAsync(VtuberEntity vtuber, YoutubeVideo live) { using (var client = HttpClientExtensions.CreateClient()) { var body = new YoutubeLiveCallbackBody() { VtuberName = vtuber.OriginalName, LiveTitle = live.Title, LiveLink = live.VideoLink, ScheduledStartTime = live.LiveDetails.ScheduledStartTime.ToTimestamp(), ActualStartTime = live.LiveDetails.ActualStartTime?.ToTimestamp() ?? DateTime.Now.ToTimestamp(), ViewersCount = 0, Sign = Sign }; await client.PostJsonAsync(Url + "youtube/live/stop", body); } }
public async Task CallReplyAsync(VtuberEntity vtuber, TweetInfo tweet) { using (var client = HttpClientExtensions.CreateClient()) { var body = new TwitterCallbackBody() { VtuberName = vtuber.OriginalName, Content = tweet.Content, IsReply = tweet.IsReply, PublishTime = tweet.CreateTime.ToTimestamp(), ReplyScreenName = tweet.ReplyScreenname, RetweetedUsername = tweet.RetweetedTweet?.User?.Name, Sign = Sign }; await client.PostJsonAsync(Url + "tweet/reply", body); } }
public async Task <IActionResult> UpdateVtuber([FromBody] VtuberEntity entity) { var groupId = long.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)); if (groupId != 399572347) { return(Unauthorized()); } var vtuber = (await _vtuberCollection.FindAsync(v => v.OriginalName == entity.OriginalName)).FirstOrDefault(); if (vtuber != null) { entity.Id = vtuber.Id; } _vtuberCollection.ReplaceOne(v => v.Id == entity.Id, entity, new UpdateOptions() { IsUpsert = true }); return(Ok(new { message = "SUCCESS" })); }
public async void AddVtuberCommand(AcceptedMessage message, string[] args) { try { var vtuberName = string.Join(" ", args.Skip(2)); var vtuber = await GetVtuberAsync(vtuberName); if (vtuber != null) { await SendingService.SendGroupMessageAsync(message.FromGroup, "已存在 " + vtuberName); return; } await SendingService.SendGroupMessageAsync(message.FromGroup, "正在搜索, 这可能需要一段时间."); var streamers = HiyokoApi.SearchStreamer(vtuberName); if (streamers.Count == 0) { await SendingService.SendGroupMessageAsync(message.FromGroup, "无法找到: " + vtuberName); return; } var streamer = streamers.First(); var bilibiliChannel = streamer.Channels.FirstOrDefault(v => v.ChannelType == 6)?.ChannelId? .Replace("BL_", string.Empty); if (await GetVtuberAsync(streamer.Name) != null) { await SendingService.SendGroupMessageAsync(message.FromGroup, "已存在 " + vtuberName); return; } var entity = new VtuberEntity() { OriginalName = streamer.Name, TwitterProfileId = streamer.TwitterId, YoutubeChannelId = streamer.Channels.FirstOrDefault(v => v.ChannelType == 1)?.ChannelId, HiyokoProfileId = streamer.Name, BilibiliUserId = string.IsNullOrEmpty(bilibiliChannel) ? 0 : long.Parse(bilibiliChannel) }; var userlocalVtuber = (await UserlocalApi.SearchAsync(vtuberName).Retry(5)) .Select(v => UserlocalApi.GetVtuberInfoAsync(v.Id).Retry(5).GetAwaiter().GetResult()).FirstOrDefault( v => { if (v.ChannelLink.EndsWith("/")) { v.ChannelLink = v.ChannelLink.Substring(0, v.ChannelLink.Length - 1); } return(v.ChannelLink.Split('/').Last() == entity.YoutubeChannelId); }); if (userlocalVtuber != null) { entity.Group = userlocalVtuber.OfficeName; entity.UserlocalProfile = userlocalVtuber.Id; } await _vtuberCollection.InsertOneAsync(entity); await SendingService.SendGroupMessageAsync(message.FromGroup, "已根据互联网相关资料添加: " + vtuberName + "\r\n可使用!Vtuber set修改"); await SendingService.SendGroupMessageAsync(message.FromGroup, $"Vtuber相关信息: \r\n" + $"原名: {streamer.Name}\r\n" + $"推特主页: https://twitter.com/{streamer.TwitterId}\r\n" + $"Youtube频道: https://www.youtube.com/channel/{streamer.Channels.FirstOrDefault(v => v.ChannelType == 1)?.ChannelId}\r\n" + $"B站主页: https://space.bilibili.com/{entity.BilibiliUserId}\r\n" + $"所属团体: {entity.Group}"); } catch (Exception ex) { await SendingService.SendGroupMessageAsync(message.FromGroup, "添加vtuber时出现错误, 请重试或反馈, 错误信息: " + ex.Message); } }
public BilibiliDanmakuRecorder(long roomId, VtuberEntity vtuber) { RoomId = roomId; Vtuber = vtuber; _commentCollection = Program.Database.GetCollection <BilibiliCommentInfo>("bili-live-comments"); }
private static void VtuberUploadYoutubeVideoEvent(VtuberEntity vtuber, YoutubeVideo video) { }