public void ProcessMessage(IInboundMessage message) { if (message == null) { throw new ArgumentNullException(nameof(message)); } var synonymService = _controller.GetService <SynonymService>(); var messageContextFactory = new MessageContextFactory(synonymService); _messageContext = messageContextFactory.Create(message); try { Answer = ProcessMessage(); if (_messageContext.GetContainsWord("debug")) { Answer += Environment.NewLine + Environment.NewLine + GenerateDebugOutput(); } } catch (Exception exception) { Answer = $"{Emoji.Scream} Mist! Da ist etwas total schief gelaufen! Bitte stelle mir nie wieder solche Fragen!"; Log.Error(exception, $"Error while processing message '{message.Text}'."); } }
public string ProcessMessage(IInboundMessage message) { if (message == null) throw new ArgumentNullException(nameof(message)); var messageContextFactory = new MessageContextFactory(_synonymService, _areaService); var messageContext = messageContextFactory.Create(message); string answer; try { answer = ProcessMessage(messageContext); if (messageContext.GetContainsWord("debug")) { answer += Environment.NewLine + Environment.NewLine + GenerateDebugOutput(messageContext); } } catch (Exception exception) { answer = $"{Emoji.Scream} Mist! Da ist etwas total schief gelaufen! Bitte stelle mir nie wieder solche Fragen!"; Log.Error(exception, $"Error while processing message '{message.Text}'."); } return answer; }
public string ProcessTextMessage(string text) { if (text == null) { throw new ArgumentNullException(nameof(text)); } var messageContextFactory = new MessageContextFactory(_areaService, _componentsRegistry, _settingsService); var messageContext = messageContextFactory.Create(text); ProcessMessage(messageContext); return(messageContext.Reply); }
public void ParseWords() { var testController = new TestController(); var synonymService = new SynonymService(testController.ComponentService); var messageContextFactory = new MessageContextFactory(synonymService, testController.AreaService); MessageContext messageContext = messageContextFactory.Create(new TestInboundMessage("Hello World. Hello World.")); messageContext.IdentifiedAreaIds.Count.ShouldBeEquivalentTo(0); messageContext.IdentifiedComponentIds.Count.ShouldBeEquivalentTo(0); messageContext.IdentifiedComponentStates.Count.ShouldBeEquivalentTo(0); messageContext.Words.Count.ShouldBeEquivalentTo(2); }
public void ProcessSkillServiceRequest(IApiCall apiCall) { var request = apiCall.Parameter.ToObject <SkillServiceRequest>(); var messageContextFactory = new MessageContextFactory(_areaService, _componentsRegistry, _settingsService); var messageContext = messageContextFactory.Create(request); ProcessMessage(messageContext); var response = new SkillServiceResponse(); response.Response.OutputSpeech.Text = messageContext.Reply; apiCall.Result = JObject.FromObject(response); }
public void IdentifyAreaIds() { var testController = new TestController(); var synonymService = new SynonymService(testController.ComponentService); synonymService.AddSynonymsForArea(new AreaId("Office"), "Büro"); var messageContextFactory = new MessageContextFactory(synonymService, testController.AreaService); MessageContext messageContext = messageContextFactory.Create(new TestInboundMessage("Hello World. Büro.")); messageContext.IdentifiedAreaIds.Count.ShouldBeEquivalentTo(1); messageContext.IdentifiedComponentIds.Count.ShouldBeEquivalentTo(0); messageContext.IdentifiedComponentStates.Count.ShouldBeEquivalentTo(0); messageContext.Words.Count.ShouldBeEquivalentTo(3); }