Beispiel #1
0
        private async void button52_Click(object sender, EventArgs e)
        {
            //textBox41
            var response = await TwitchApi.PostToChannelFeed(textBox41.Text, checkBox1.Checked, textBox14.Text, textBox15.Text);

            MessageBox.Show($"Message body: {response.Post.Body}");
        }
Beispiel #2
0
        private async Task <UploadMetaData.TwitchVodData> UpdateTwitchVodData(bool streaming)
        {
            if (!streaming)
            {
                return(null);
            }
            bool Selected(TwitchAccount x) => x.Id == Config.Instance.SelectedTwitchUser;

            var user = HSReplayNetOAuth.TwitchUsers?.FirstOrDefault(Selected);

            if (user == null)
            {
                return(null);
            }
            var url = await TwitchApi.GetVodUrl(user.Id);

            if (url == null)
            {
                return(null);
            }
            var streamerLanguage = await TwitchApi.GetStreamerLanguage(user.Id);

            return(new UploadMetaData.TwitchVodData
            {
                ChannelName = user.Username,
                Url = url,
                Language = streamerLanguage
            });
        }
Beispiel #3
0
        public async Task <TwitchApi> CreateHost(string username, string clientId, string connectionId, NavigationManager navigationManager)
        {
            var accessToken = this.GetTwitchAuthenticationToken(navigationManager);

            var twitchApi = new TwitchApi(clientId, accessToken);

            var lowerUsername = username.ToLower();

            if (!DbContext.Hosts.ContainsKey(lowerUsername))
            {
                DbContext.Hosts.Add(lowerUsername, null);
            }

            var channel = (await twitchApi.api.Helix.Users.GetUsersAsync()).Users.FirstOrDefault(x => x.DisplayName.ToLower().Equals(lowerUsername));

            if (DbContext.Hosts[username.ToLower()] != null)
            {
                DbContext.Hosts[username.ToLower()].TwitchApi   = twitchApi;
                DbContext.Hosts[username.ToLower()].IsHosting   = false;
                DbContext.Hosts[username.ToLower()].DisplayName = channel.DisplayName;
                DbContext.Hosts[username.ToLower()].ImageUrl    = channel.ProfileImageUrl;
                DbContext.Hosts[username.ToLower()].StreamUrl   = $"https://www.twitch.tv/{username}";
            }
            else
            {
                DbContext.Hosts[username.ToLower()] = new Host {
                    ConnectionId = connectionId, IsHosting = false, TwitchApi = twitchApi, DisplayName = channel.DisplayName, ImageUrl = channel.ProfileImageUrl, StreamUrl = $"https://www.twitch.tv/{username}"
                };
            }

            HostsUpdated(this, new ChangeEventArgs());

            return(twitchApi);
        }
Beispiel #4
0
        private async void button32_Click(object sender, EventArgs e)
        {
            //textbox32
            var follow = await TwitchApi.FollowChannel(textBox14.Text, textBox32.Text, textBox15.Text);

            MessageBox.Show($"Channel: {follow.Channel.Name}\nIsFollowing: {follow.IsFollowing}\nCreated at: {follow.CreatedAt}");
        }
Beispiel #5
0
        private async void button35_Click(object sender, EventArgs e)
        {
            //textbox33
            var block = await TwitchApi.BlockUser(textBox14.Text, textBox33.Text, textBox15.Text);

            MessageBox.Show($"Updated at: {block.UpdatedAt}\nUser: {block.User.Name}");
        }
Beispiel #6
0
        public async Task GetViewersInfoAsync(string channelName)
        {
            if (channelName.Length == 0)
            {
                Logger.Log("Channel name is empy.");
                return;
            }

            // Change the name to lowercase, because twitch api only works with lowercase names
            channelName = channelName.ToLower();

            Logger.Log($"Getting information for channel: {channelName}...");

            var streamer = new StreamerInformation(channelName, ClientId);
            await streamer.GetChattersInformationAsync();

            await streamer.GetStreamInformationAsync();

            var featuredStreams = await TwitchApi.GetFeaturedStreamsAsync(TwitchViewerCounterConfiguration.Instance.GetFeaturedStreamsLocation(),
                                                                          TwitchViewerCounterConfiguration.Instance.GetFeaturedStreamsLanguage());

            var featuredStream = StreamHelpers.CheckIfStreamIsFeatured(streamer.Stream, featuredStreams.Featured);

            await DisplayInformation(streamer, channelName, featuredStream);
        }
Beispiel #7
0
        private async Task CheckLiveStreamsStatusAsync(List <string> liveStreamsCheckList, int liveCheckInterval)
        {
            while (true)
            {
                var liveStreams = await TwitchApi.GetLiveStreamsInformationAsync(liveStreamsCheckList.ToArray());

                Logger.Log("Running check live streams status...");
                foreach (var live in liveStreams.StreamsInfo)
                {
                    // Add stream to online streams list if it turns online
                    if (StreamHelpers.IsLiveOnline(live) && !OnlineLiveStreams.Contains(live.Channel.Name))
                    {
                        OnlineLiveStreams.Add(live.Channel.Name);
                    }

                    // Remove stream from online streams list if it turns offline
                    if (OnlineLiveStreams.Contains(live.Channel.Name) && !StreamHelpers.IsLiveOnline(live))
                    {
                        OnlineLiveStreams.Remove(live.Channel.Name);
                    }
                }

                await Task.Delay(TimeSpan.FromSeconds(liveCheckInterval));
            }
        }
Beispiel #8
0
        private async void button21_Click(object sender, EventArgs e)
        {
            TwitchLib.TwitchAPIClasses.Stream stream = await TwitchApi.GetTwitchStream(textBox25.Text);

            MessageBox.Show(string.Format("average fps: {0}\nchannel name: {1}\ncreated at: {2}\ndelay: {3}\ngame: {4}\nid: {5}\nplaylist: {6}\npreview large: {7}\nvideo height: {8}\n viewers: {9}",
                                          stream.AverageFps, stream.Channel.Name, stream.CreatedAt, stream.Delay, stream.Game, stream.Id, stream.IsPlaylist, stream.Preview.Large, stream.VideoHeight, stream.Viewers));
        }
Beispiel #9
0
        private async void button45_Click(object sender, EventArgs e)
        {
            //textbox38
            TwitchLib.TwitchAPIClasses.Channels channels = await TwitchApi.GetChannelsObject(textBox38.Text);

            MessageBox.Show($"Display name: {channels.DisplayName}\n Fighting Ad Block: {channels.FightAdBlock}\nSteam Id: {channels.SteamId}");
        }
Beispiel #10
0
    public override void Handle()
    {
        Regex  channelPattern = PatternCreator.Create(Alias, ChatMessage.Channel.Prefix, @"\s\w+");
        Stream?stream;

        Response = $"{ChatMessage.Username}, ";

        if (channelPattern.IsMatch(ChatMessage.Message))
        {
            stream = TwitchApi.GetStream(ChatMessage.Split[1]);
        }
        else
        {
            stream = TwitchApi.GetStream(ChatMessage.ChannelId);
        }

        if (stream is null)
        {
            Response += "this channel is currently not streaming";
            return;
        }
        Response += $"{stream.UserName} is currently streaming {stream.GameName} with {stream.ViewerCount} viewer{(stream.ViewerCount > 1 ? 's' : string.Empty)} for ";
        TimeSpan streamSpan   = stream.StartedAt.Subtract(DateTime.Now);
        long     milliseconds = streamSpan.TotalMilliseconds.ToLong() + TimeHelper.Now();

        if (!DateTime.Now.IsDaylightSavingTime())
        {
            milliseconds += new Hour().Milliseconds;
        }
        string streamTime = TimeHelper.GetUnixDifference(milliseconds).ToString();

        Response += streamTime;
        return;
    }
Beispiel #11
0
        private async void Run()
        {
            await LoadReminderContext(); // initial load

            DateTime midnightNextDay = DateTime.Today.AddDays(1);

            while (true)
            {
                ChannelJSON channelJSON = await TwitchApi.GetBroadcasterChannelById(_twitchClientId);

                string gameTitle = channelJSON.Game;

                TwitchGameCategory game = await _gameDirectory.GetGameId(gameTitle);

                if (game == null || game.Id == 0)
                {
                    _gameId = null;
                }
                else
                {
                    _gameId = game.Id;
                }

                // remove pending reminders
                Program.DelayedMessages.RemoveAll(r => r.ReminderId > 0);

                foreach (RemindUser reminder in _reminders.OrderBy(m => m.RemindEveryMin))
                {
                    if (IsEveryMinReminder(reminder))
                    {
                        continue;
                    }
                    else if (IsCountdownEvent(reminder))
                    {
                        continue;
                    }
                    else
                    {
                        AddDayOfReminder(reminder);
                    }
                }

                if (_refreshReminders)
                {
                    _irc.SendPublicChatMessage("Reminders refreshed!");
                }

                // reset refresh
                midnightNextDay   = DateTime.Today.AddDays(1);
                _refreshReminders = false;

                // wait until midnight to check reminders
                // unless a manual refresh was called
                while (DateTime.Now < midnightNextDay && !_refreshReminders)
                {
                    Thread.Sleep(1000); // 1 second
                }
            }
        }
Beispiel #12
0
    public override void Handle()
    {
        Regex afkPattern = PatternCreator.Create(Alias, ChatMessage.Channel.Prefix, @"\safk\s\w+");

        if (afkPattern.IsMatch(ChatMessage.Message))
        {
            Response = $"{ChatMessage.Username}, ";
            string username = ChatMessage.LowerSplit[2];
            int?   userId   = TwitchApi.GetUserId(username);
            if (userId is null)
            {
                Response += PredefinedMessages.UserNotFoundMessage;
                return;
            }

            UserNew?user = DbController.GetUser(userId.Value, username);
            if (user is null)
            {
                Response += PredefinedMessages.UserNotFoundMessage;
                return;
            }

            if (user.IsAfk == true)
            {
                Response += new AfkMessage(userId.Value).GoingAway !;
                string message = user.AfkMessage.Decode();
                if (!string.IsNullOrEmpty(message))
                {
                    Response += $": {message}";
                }
                Response += $" ({TimeHelper.GetUnixDifference(user.AfkTime)} ago)";
            }
            else
            {
                Response += $"{username} is not afk";
            }
            return;
        }

        Regex reminderPattern = PatternCreator.Create(Alias, ChatMessage.Channel.Prefix, @"\sreminder\s\d+");

        if (reminderPattern.IsMatch(ChatMessage.Message))
        {
            Response = $"{ChatMessage.Username}, ";
            int      id       = ChatMessage.Split[2].ToInt();
            Reminder?reminder = DbController.GetReminder(id);
            if (reminder is null)
            {
                Response += PredefinedMessages.ReminderNotFoundMessage;
                return;
            }

            Response += $"From: {reminder.GetAuthor()} || To: {reminder.GetTarget()} || ";
            Response += $"Set: {TimeHelper.GetUnixDifference(reminder.Time)} ago || ";
            Response += reminder.ToTime > 0 ? $"Fires in: {TimeHelper.GetUnixDifference(reminder.ToTime)} || " : string.Empty;
            Response += $"Message: {reminder.Message.Decode()}";
            return;
        }
    }
		public BasicTwitchConnector(TwitchApi api, IUnityContainer dependencyInjector)
		{
			Verify.NotNull(api, "api");
			Verify.NotNull(dependencyInjector, "dependencyInjector");
			Api = api;
			DependencyInjector = dependencyInjector;
			Decoder = DependencyInjector.Resolve<ProtocolDecoder>(new DependencyOverride(typeof(TwitchConnector), this));
		}
Beispiel #14
0
        public ActionResult Streams(int gameId)
        {
            TwitchApi        twitch  = new TwitchApi(_key);
            StreamsModel     games   = twitch.GetStreams(_clientId, gameId);
            StreamsViewModel gamesVm = _mapper.Map <StreamsViewModel>(games);

            return(View(gamesVm));
        }
Beispiel #15
0
        public ActionResult TopGames()
        {
            TwitchApi         twitch  = new TwitchApi(_key);
            TopGamesModel     games   = twitch.GetTopGames(_clientId);
            TopGamesViewModel gamesVm = _mapper.Map <TopGamesViewModel>(games);

            return(View(gamesVm));
        }
Beispiel #16
0
        private void updateOnline()
        {
            for (int i = 0; i < entries.Length; i++)
            {
                if (abortThread)
                {
                    return;
                }
                string name = entries[i];
                string s    = "\"stream\":null";
                if (!IsLinux)
                {
                    //ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback;
                    WebClient wc = new WebClient();
                    s = wc.UploadString("http://api.twitch.tv/kraken/streams/" +
                                        TwitchApi.GetName(name), "");
                    wc.Dispose();
                }
                else
                {
                    Process p = new Process();
                    p.StartInfo.FileName  = "wget";
                    p.StartInfo.Arguments = "-q -O - https://api.twitch.tv/kraken/streams/" +
                                            TwitchApi.GetName(name);
                    p.StartInfo.RedirectStandardOutput = true;
                    p.StartInfo.UseShellExecute        = false;
                    p.Start();
                    while (!p.HasExited)
                    {
                        if (abortThread)
                        {
                            p.Kill();
                            return;
                        }
                    }
                    //p.BeginOutputReadLine();
                    s = p.StandardOutput.ReadToEnd();
                }
                if (s.Contains("\"stream\":null"))
                {
                    isOnline[i] = false;
                }
                else
                {
                    isOnline[i] = true;
                    if (abortThread)
                    {
                        return;
                    }
                    Console.Clear();
                    DrawMenue();
                }
            }

            loaded = true;
            Console.Clear();
            DrawMenue();
        }
Beispiel #17
0
        private async void button37_Click(object sender, EventArgs e)
        {
            var editors = await TwitchApi.GetChannelEditors(textBox14.Text, textBox15.Text);

            foreach (TwitchLib.TwitchAPIClasses.User user in editors)
            {
                MessageBox.Show($"User: {user.Name}");
            }
        }
Beispiel #18
0
        private void button20_Click(object sender, EventArgs e)
        {
            List <TwitchLib.TwitchAPIClasses.TwitchFollower> followers = TwitchApi.GetTwitchFollowers(textBox24.Text).Result;

            foreach (TwitchLib.TwitchAPIClasses.TwitchFollower follower in followers)
            {
                MessageBox.Show(string.Format("notifications: {0}\ncreated at:{1}\n[user] name: {2}\n[user] display name: {3}\n[user] bio: {4}\n [user] logo: {5}\n[user] created at: {6}\n[user] updated at: {7}", follower.Notifications, follower.CreatedAt, follower.User.Name, follower.User.DisplayName, follower.User.Bio, follower.User.Logo, follower.User.CreatedAt, follower.User.UpdatedAt));
            }
        }
Beispiel #19
0
        private async void button50_Click(object sender, EventArgs e)
        {
            var games = await TwitchApi.GetGamesByPopularity();

            foreach (var game in games)
            {
                MessageBox.Show($"Game: {game.Game.Name}\nViewer Count: {game.Viewers}\nChannel Count: {game.Channels}");
            }
        }
Beispiel #20
0
        private async void button48_Click(object sender, EventArgs e)
        {
            var featuredStreams = await TwitchApi.GetFeaturedStreams();

            foreach (TwitchLib.TwitchAPIClasses.FeaturedStream stream in featuredStreams)
            {
                MessageBox.Show($"Stream name: {stream.Stream.Channel.Name}\nStream text: {stream.Text}\nViewers: {stream.Stream.Viewers}");
            }
        }
Beispiel #21
0
        private async void button16_Click(object sender, EventArgs e)
        {
            List <TwitchLib.TwitchAPIClasses.Video> videos = await TwitchApi.GetChannelVideos(textBox20.Text);

            foreach (TwitchLib.TwitchAPIClasses.Video vid in videos)
            {
                MessageBox.Show($"Title: {vid.Title}\nDescription: {vid.Description}\nStatus: {vid.Status}\nId: {vid.Id}\nTag List: {vid.TagList}\n Recorded At: {vid.RecordedAt}\n" +
                                $"Game: {vid.Game}\nPreview: {vid.Preview}\nBroadcast Id: {vid.BroadcastId}\nLength: {vid.Length}\nUrl: {vid.Url}\nViews: {vid.Views}\n");
            }
        }
Beispiel #22
0
        private async void button36_Click(object sender, EventArgs e)
        {
            //textbox34
            var blocks = await TwitchApi.GetBlockedList(textBox14.Text, textBox15.Text);

            foreach (TwitchLib.TwitchAPIClasses.Block block in blocks)
            {
                MessageBox.Show($"Updated at: {block.UpdatedAt}\nUsername: {block.User.Name}");
            }
        }
Beispiel #23
0
    public static BttvRequest?GetBttvRequest(string channel)
    {
        int?id = TwitchApi.GetUserId(channel);

        if (id.HasValue)
        {
            return(GetBttvRequest(id.Value));
        }
        return(null);
    }
Beispiel #24
0
        private async void button18_Click(object sender, EventArgs e)
        {
            List <TwitchLib.TwitchAPIClasses.TeamMember> members = await TwitchApi.GetTeamMembers(textBox22.Text);

            foreach (TwitchLib.TwitchAPIClasses.TeamMember member in members)
            {
                MessageBox.Show($"Name: {member.Name}\nDescription: {member.Description}\nTitle: {member.Title}\nMeta Game: {member.MetaGame}\nDisplay Name: {member.DisplayName}\n" +
                                $"Link: {member.Link}\nFollower Count: {member.FollowerCount}\nTotal Views: {member.TotalViews}\nCurrent Views: {member.CurrentViews}");
            }
        }
Beispiel #25
0
        private async void button40_Click(object sender, EventArgs e)
        {
            //textbox36
            List <TwitchLib.TwitchAPIClasses.BadgeResponse.Badge> badges = (await TwitchApi.GetChannelBadges(textBox36.Text)).ChannelBadges;

            foreach (TwitchLib.TwitchAPIClasses.BadgeResponse.Badge badge in badges)
            {
                MessageBox.Show($"Available images for: {badge.BadgeName}\nAlpha: {badge.Alpha}\nImage: {badge.Image}\nSVG: {badge.SVG}");
            }
        }
Beispiel #26
0
        private async void button20_Click(object sender, EventArgs e)
        {
            TwitchLib.TwitchAPIClasses.FollowersResponse response = await TwitchApi.GetTwitchFollowers(textBox24.Text);

            MessageBox.Show($"Cursor: {response.Cursor}\nFollower Count: {response.TotalFollowerCount}");
            foreach (TwitchLib.TwitchAPIClasses.Follower follower in response.Followers)
            {
                MessageBox.Show(string.Format("notifications: {0}\ncreated at:{1}\n[user] name: {2}\n[user] display name: {3}\n[user] bio: {4}\n [user] logo: {5}\n[user] created at: {6}\n[user] updated at: {7}", follower.Notifications, follower.CreatedAt, follower.User.Name, follower.User.DisplayName, follower.User.Bio, follower.User.Logo, follower.User.CreatedAt, follower.User.UpdatedAt));
            }
        }
Beispiel #27
0
 private async void button11_Click(object sender, EventArgs e)
 {
     if ((await TwitchApi.UserFollowsChannel(textBox11.Text, textBox12.Text)).IsFollowing)
     {
         MessageBox.Show(String.Format("'{0}' follows the channel '{1}'!", textBox11.Text, textBox12.Text));
     }
     else
     {
         MessageBox.Show(String.Format("'{0}' does NOT follow the channel '{1}'!", textBox11.Text, textBox12.Text));
     }
 }
Beispiel #28
0
        /// <summary>Downloads recent followers from Twitch, starts service, fires OnServiceStarted event.</summary>
        public async void StartService()
        {
            TwitchAPIClasses.FollowersResponse response = await TwitchApi.GetTwitchFollowers(Channel, QueryCount);

            ActiveCache = response.Followers;
            _followerServiceTimer.Start();
            OnServiceStarted?.Invoke(this,
                                     new OnServiceStartedArgs {
                Channel = Channel, CheckIntervalSeconds = CheckIntervalSeconds, QueryCount = QueryCount
            });
        }
Beispiel #29
0
        private async void button29_Click(object sender, EventArgs e)
        {
            //textbox29
            TwitchLib.TwitchAPIClasses.FollowedUsersResponse response = await TwitchApi.GetFollowedUsers(textBox29.Text);

            MessageBox.Show($"Channe: {textBox29.Text}\nTotal followed users: {response.TotalFollowCount}");
            foreach (TwitchLib.TwitchAPIClasses.Follow follow in response.Follows)
            {
                MessageBox.Show($"Followed user: {follow.Channel.DisplayName}\nFollow created at: {follow.CreatedAt}");
            }
        }
Beispiel #30
0
 private async void button12_Click(object sender, EventArgs e)
 {
     if (await TwitchApi.BroadcasterOnline(textBox13.Text))
     {
         MessageBox.Show(String.Format("'{0}' is ONLINE!", textBox13.Text));
     }
     else
     {
         MessageBox.Show(string.Format("'{0}' is OFFLINE!", textBox13.Text));
     }
 }
Beispiel #31
0
 private async void button19_Click(object sender, EventArgs e)
 {
     if (await TwitchApi.ChannelHasUserSubscribed(textBox23.Text, textBox14.Text, textBox15.Text))
     {
         MessageBox.Show("User is subscribed!");
     }
     else
     {
         MessageBox.Show("User is not subscribed!");
     }
 }