Example #1
0
        public async Task CmdLive(bool hasTwitterInfo)
        {
            try
            {
                RootStreamJSON streamJSON = await _twitchInfo.GetBroadcasterStream();

                if (streamJSON.Stream == null)
                {
                    _irc.SendPublicChatMessage("This channel is not streaming right now");
                }
                else if (!_botConfig.EnableTweets)
                {
                    _irc.SendPublicChatMessage("Tweets are disabled at the moment");
                }
                else if (_botConfig.EnableTweets && hasTwitterInfo)
                {
                    string tweetResult = _twitter.SendTweet($"Live on Twitch playing {streamJSON.Stream.Game} "
                                                            + $"\"{streamJSON.Stream.Channel.Status}\" twitch.tv/{_botConfig.Broadcaster}");

                    _irc.SendPublicChatMessage($"{tweetResult} @{_botConfig.Broadcaster}");
                }
            }
            catch (Exception ex)
            {
                await _errHndlrInstance.LogError(ex, "CmdBrdCstr", "CmdLive(bool)", false, "!live");
            }
        }
Example #2
0
        private async void Run()
        {
            while (true)
            {
                RootStreamJSON streamJSON = await _twitchInfo.GetBroadcasterStream();

                if (streamJSON.Stream == null)
                {
                    if (IsLive)
                    {
                        // ToDo: Clear greeted user list
                    }

                    IsLive = false;
                }
                else
                {
                    CurrentCategory = streamJSON.Stream.Game;
                    CurrentTitle    = streamJSON.Stream.Channel.Status;

                    // tell the chat the stream is now live
                    if (!IsLive)
                    {
                        _irc.SendPublicChatMessage($"Live on Twitch playing {CurrentCategory} \"{CurrentTitle}\"");
                    }

                    IsLive = true;
                }

                Thread.Sleep(15000); // check every 15 seconds
            }
        }