public override async Task OnActivateAsync() { _channelId = this.GetPrimaryKeyString(); _logger.LogInformation("Activating channel grain {channelId}", _channelId); if (!_channelBotState.RecordExists) { var defaultBotInfo = new BotAccountInfo { IsActive = true, UserId = _options.TokenInfo.UserId, UserLogin = _options.TokenInfo.Login, }; _channelBotState.State.AllowedBotAccounts.Add(defaultBotInfo); _channelBotState.State.Commands = new Dictionary <Guid, Conceptoire.Twitch.Commands.CommandOptions>(); } else { // Temps: fix existing ids foreach ((var id, var command) in _channelBotState.State.Commands) { command.Id = id; if (command.Type == "MessageTracer") { command.Type = "Logger"; } } // Activate bot if it is supposed to be running if (_channelBotState.State.IsActive) { await RegisterEventSubSubscriptions(CancellationToken.None); await StartBot(_channelState.State.BroadcasterToken); } } await base.OnActivateAsync(); _channelInfo = await _appClient.GetChannelInfoAsync(_channelId); await OnChannelUpdate(_channelInfo); }
async Task IChannelGrain.AllowBotAccount(BotAccountInfo botAccount) { _channelBotState.State.AllowedBotAccounts.Add(botAccount); await _channelBotState.WriteStateAsync(); }