public async Task JoinChannelAsync(string channelName) { if (!_client.Connected) { _client.Connect(); } _client.JoinChannel(await _apiRequester.GetStream(channelName)); }
public async Task <ChatMessage> FromRawString(string rawString, DateTime time) { var result = new ChatMessage(); var match = rawChatMessageRegex.Match(rawString); result.Badges = GetBadges(rawString); result.DisplayName = match.Groups["displayname"].Value; result.IsChannelMod = match.Value.TryParse <bool>(bool.TryParse); result.RoomId = match.Groups["roomid"].Value.TryParse <int>(int.TryParse); result.IsSubscriber = match.Groups["subscriber"].Value.TryParse <bool>(bool.TryParse); result.IsTurbo = match.Groups["turbo"].Value.TryParse <bool>(bool.TryParse); result.UserId = match.Groups["userid"].Value.TryParse <int>(int.TryParse); result.UserType = match.Groups["usertype"].Value; result.Username = match.Groups["username"].Value; result.Channel = match.Groups["channel"].Value; result.MessageBody = match.Groups["messagebody"].Value; result.Emotes = GetEmotes(rawString); result.Time = time; result.Color = match.Groups["color"].Value; if (result.Channel != string.Empty) { Stream stream; if (_streamsCache.ContainsKey(result.Channel)) { stream = _streamsCache[result.Channel]; } else { stream = await _requester.GetStream(result.Channel); _streamsCache.TryAdd(result.Channel, stream); } result.Stream = stream; } return(result); }