Exemplo n.º 1
0
        public async Task OnChannelUpdate(HelixChannelInfo info)
        {
            _channelState.State.LastCategoryId   = info.GameId;
            _channelState.State.LastCategoryName = info.GameName;
            _channelState.State.LastLanguage     = info.BroadcasterLanguage;
            _channelState.State.LastTitle        = info.Title;
            await _channelState.WriteStateAsync();

            if (_chatBot == null)
            {
                return;
            }

            var botContext = new ProcessorContext
            {
                ChannelId   = info.BroadcasterId,
                ChannelName = info.BroadcasterName,
                Language    = info.BroadcasterLanguage,
                CategoryId  = info.GameId,
            };
            var key = new CategoryKey {
                TwitchCategoryId = info.GameId, Locale = info.BroadcasterLanguage
            };

            if (_categoriesState.State.Descriptions.TryGetValue(key, out var customDescription))
            {
                botContext.CustomCategoryDescription = customDescription.Description;
            }
            else
            {
                botContext.CustomCategoryDescription = null;
            }
            await _chatBot.UpdateContext(botContext);
        }