private void AnnounceStreamOnline(StreamInfo streamInfo, TwitchStream twitchStream) { var message = $"@everyone ***{streamInfo.Name}*** is now live!\n" + $"{twitchStream.stream.game}\n" + $"{twitchStream.stream.channel.status}\n" + $"{twitchStream.stream.channel.url}"; _announcementDiscordClient.SendTextMessage(message); }
public StreamViewModel(TwitchStream model) { UserName = model.UserName; Type = model.Type; Title = model.Title; ViewerCount = model.ViewerCount; StartedAt = model.StartedAt; Language = model.Language; }
public void Refresh() { streamlist.Clear(); streamview.Items.Clear(); string uri = "http://api.justin.tv/api/stream/list.xml?meta_game=Dota+2"; var xmlDocument = XDocument.Load(uri); foreach (XElement stream in xmlDocument.Descendants("stream")) { try { TwitchStream temp = new TwitchStream(); if (stream.Element("title").Value != null) { temp.Title = stream.Element("title").Value; } if (stream.Element("channel").Element("login").Value != null) { temp.ChannelOwner = stream.Element("channel").Element("login").Value; } if (stream.Element("channel_count").Value != null) { temp.ViewerCount = Convert.ToInt32(stream.Element("channel_count").Value); } if (stream.Element("channel").Element("screen_cap_url_large").Value != null) { temp.image = stream.Element("channel").Element("screen_cap_url_large").Value; } streamlist.Add(temp); } catch { } } List <TwitchStream> SortedStreams = streamlist.OrderByDescending(o => o.ViewerCount).ToList <TwitchStream>(); foreach (TwitchStream stream in SortedStreams) { Button temp = new Button(); temp.Content = stream.ChannelOwner; temp.ToolTip = stream.Title + Environment.NewLine + stream.ViewerCount.ToString(); temp.Height = 50; temp.Width = 150; temp.Click += temp_Click; streamview.Items.Add(temp); } }
private Embed CreateEmbed(TwitchStream stream, uint inColor) { var now = DateTime.UtcNow; var cacheBuster = now.Year + now.Month.ToString() + now.Day + now.Hour + now.Minute / 10 % 10; var embed = new EmbedBuilder(); var color = new Color(inColor); var author = new EmbedAuthorBuilder(); var imgUrl = stream.Preview.Template.Replace("{width}", "640").Replace("{height}", "360") + "?" + cacheBuster; author.Name = stream.Channel.DisplayName ?? stream.Channel.Name; author.Url = stream.Channel.Url; author.IconUrl = stream.Channel.Logo; var streamPlayingField = new EmbedFieldBuilder { Name = "Playing", Value = !string.IsNullOrWhiteSpace(stream.Game) ? stream.Game : "(no game)", IsInline = true }; var streamViewersField = new EmbedFieldBuilder { Name = "Viewers", Value = stream.Viewers.ToString(), IsInline = true }; embed.Color = color; embed.ImageUrl = imgUrl; embed.Title = !string.IsNullOrWhiteSpace(stream.Channel.Status) ? stream.Channel.Status : "(no title)"; embed.Url = stream.Channel.Url; embed.Author = author; embed.AddField(streamPlayingField); embed.AddField(streamViewersField); return(embed.Build()); }
void temp_Click(object sender, RoutedEventArgs e) { string name = ((Button)sender).Content.ToString(); TwitchStream stream = streamlist[0]; foreach (TwitchStream get in streamlist) { if (get.ChannelOwner == name) { stream = get; } } text_owner.Text = "Owner: " + stream.ChannelOwner; text_title.Text = "Title: " + stream.Title; text_title.ToolTip = stream.Title; text_viewer.Text = "Viewers: " + stream.ViewerCount.ToString(); this.DataContext = stream.image; }
private async Task <long> SendMessageAsync(StreamToCheck streamToCheck, TwitchStream stream) { Embed embed = null; if (streamToCheck.EmbedColor != 0) { embed = CreateEmbed(stream, (uint)streamToCheck.EmbedColor); } var channel = _client.GetChannel((ulong)streamToCheck.DiscordChannelId) as SocketTextChannel; var resp = await channel.SendMessageAsync(streamToCheck.DiscordMessage, embed : embed); if (streamToCheck.PinMessage) { await resp.PinAsync(); } return((long)resp.Id); }
private void NotifyOnline(TwitchStream stream) { needNotify = false; if (Channel.TelegramNotifyChannels.Count == 0) { return; } var message = $"{stream.Channel.Status}\r\n{stream.Game}\r\nhttps://www.twitch.tv/{Channel.Name}"; var priorityDimensions = new List <ValueTuple <int, int> > { (1920, 1080), // telegram compresses pictures this size too much, no reason to use this dimension (1600, 900), (1366, 768), (1280, 720), (1152, 648), (1024, 576), };
void ITimerService.Process(double time) { if (!isconnected) { return; } followercheck -= time; if (followercheck <= 0.0) { try { CheckFollowers(); } catch (Exception e) { Logger.Error(this, "Unable to check for followers", e); } followercheck = 300.0; } viewercheck -= time; if (viewercheck <= 0.0) { if (userdata != null) { GetStreamsResponse response = twitchapi.GetStreams(userdata.ID); TwitchStream stream = response.Data.FirstOrDefault(); if (stream == null) { Logger.Warning(this, "There was no active stream found."); viewercheck = 180.0; return; } Viewers = stream.ViewerCount; viewercheck = 180.0; } } }
public void Refresh() { streamlist.Clear(); streamview.Items.Clear(); string uri = "http://api.justin.tv/api/stream/list.xml?meta_game=Dota+2"; var xmlDocument = XDocument.Load(uri); foreach (XElement stream in xmlDocument.Descendants("stream")) { try { TwitchStream temp = new TwitchStream(); if (stream.Element("title").Value != null) temp.Title = stream.Element("title").Value; if (stream.Element("channel").Element("login").Value != null) temp.ChannelOwner = stream.Element("channel").Element("login").Value; if (stream.Element("channel_count").Value != null) temp.ViewerCount = Convert.ToInt32(stream.Element("channel_count").Value); if (stream.Element("channel").Element("screen_cap_url_large").Value != null) temp.image = stream.Element("channel").Element("screen_cap_url_large").Value; streamlist.Add(temp); } catch { } } List<TwitchStream> SortedStreams = streamlist.OrderByDescending(o => o.ViewerCount).ToList<TwitchStream>(); foreach (TwitchStream stream in SortedStreams) { Button temp = new Button(); temp.Content = stream.ChannelOwner; temp.ToolTip = stream.Title + Environment.NewLine + stream.ViewerCount.ToString(); temp.Height = 50; temp.Width = 150; temp.Click += temp_Click; streamview.Items.Add(temp); } }