public IStateClient MakeStateClient() { if(this.StateClient == null) { this.StateClient = MockIBots(this).Object; } return this.StateClient; }
private async Task<bool> ApplyUserLanguage(IMessageActivity message) { var botState = new StateClient(new Uri(message.ServiceUrl)).BotState; var userData = await botState.GetUserDataAsync(message.ChannelId, message.From.Id); var match = Regex.Match(message.Text, LanguageCommandPattern, RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.Singleline); if (match.Success) { var locale = match.Groups["locale"].Value; userData.SetProperty("userLocale", locale); await botState.SetUserDataAsync(message.ChannelId, message.From.Id, userData); return false; } var savedLocale = userData.GetProperty<string>("userLocale"); if (savedLocale != null) message.Locale = savedLocale; return true; }