public static void Main(string[] args) { Task.Run(async() => { try { Logger.SetLogLevel(LogLevel.Debug); Logger.LogOccurred += Logger_LogOccurred; System.Console.WriteLine("Connecting to Trovo..."); connection = await TrovoConnection.ConnectViaLocalhostOAuthBrowser(clientID, scopes); if (connection != null) { System.Console.WriteLine("Trovo connection successful!"); PrivateUserModel user = await connection.Users.GetCurrentUser(); if (user != null) { System.Console.WriteLine("Current User: "******"Channel Title: " + channel.live_title); chat = new ChatClient(connection); chat.OnChatMessageReceived += Chat_OnChatMessageReceived; System.Console.WriteLine("Connecting to chat..."); if (await chat.Connect(await connection.Chat.GetToken())) { System.Console.WriteLine("Successfully connected to chat!"); await chat.SendMessage("Hello World!"); ChatViewersModel viewers = await connection.Chat.GetViewers(channel.channel_id, 1000); while (true) { string line = System.Console.ReadLine(); await chat.SendMessage(line); } } } } } } catch (Exception ex) { Logger.Log(ex); } }).Wait(); System.Console.ReadLine(); }
public void GetCurrentChannelStream() { TestWrapper(async(TwitchConnection connection) => { PrivateChannelModel channel = await connection.V5API.Channels.GetCurrentChannel(); Assert.IsNotNull(channel); StreamModel result = await connection.V5API.Streams.GetChannelStream(channel); Assert.IsNotNull(result); Assert.IsTrue(result.id > 0); }); }
public void GetChannelByUsername() { TestWrapper(async(TrovoConnection connection) => { PrivateChannelModel privateChannel = await connection.Channels.GetCurrentChannel(); Assert.IsNotNull(privateChannel); Assert.IsTrue(!string.IsNullOrEmpty(privateChannel.username)); Assert.IsTrue(!string.IsNullOrEmpty(privateChannel.live_title)); ChannelModel channel = await connection.Channels.GetChannelByUsername(privateChannel.username); Assert.IsNotNull(channel); Assert.IsTrue(!string.IsNullOrEmpty(channel.username)); Assert.IsTrue(!string.IsNullOrEmpty(channel.live_title)); }); }