static void Main(string[] args) { //Login With Bot User YoutubeLogin botLogin = new YoutubeLogin(YoutubeClientId, YoutubeClientSecret); botLogin.ShowDialog(); //Login With Channel User YoutubeLogin channelLogin = new YoutubeLogin(YoutubeClientId, YoutubeClientSecret); channelLogin.ShowDialog(); (string channelAccessToken, _) = channelLogin.RequestTokens(); YoutubeLiveChat <MyUser> youtube = new YoutubeLiveChat <MyUser>(botLogin, GoogleApiKey); youtube.LoadLiveChatId(channelAccessToken); //Only working with a live "Youtube Event"(Planned LiveStream) youtube.Userlist.Load("userlist.xml"); youtube.ChannelMessage += (o, e) => { Console.WriteLine(e.From.DisplayName + ": " + e.Message + "(Created " + e.From.Created.ToString() + ")"); if (e.Message == "!test") { youtube.Send("test received"); } }; youtube.Start(); //Stop and Save Console.ReadLine(); youtube.Stop(); youtube.Userlist.Save("userlist.xml"); }
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); } }
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); } }