private void FromAlice(string body) { AliceRequest request = JsonConvert.DeserializeObject <AliceRequest>(body, Utils.ConverterSettingsSnake); Id = request.Session.MessageId.ToString(); User = new User(request.Session); Text = request.Request.OriginalUtterance; Payload = JsonConvert.SerializeObject(request.Request.Payload, Utils.ConverterSettingsSnake); AliceCommand = new AliceCommand(request); }
public bool Check(CommandContent content, Locale locale) { if (content.Text != null && !content.Text.ContainsKey(locale)) { throw new ArgumentException("Locale is not supported"); } if (AliceCommand != null) { Utils.CheckLocale(Layer.Alice, locale); if (content.IsEnter) { return(string.IsNullOrEmpty(AliceCommand.Command)); } return(AliceCommand.Check(content)); } if (TelegramCommand != null) { Utils.CheckLocale(Layer.Telegram, locale); if (content.IsEnter) { return(Text != null && Text.StartsWith("/start")); } if (content.Text == null) { return(Payload == content.Payload); } return(content.Text[locale].ToLower() == Text.ToLower()); } if (AlexaCommand != null) { Utils.CheckLocale(Layer.Alexa, locale); if (content.IsEnter) { return(AlexaCommand.IsLaunchIntent); } return(AlexaCommand.Check(content)); } throw new ArgumentException("None of layers data were assigned"); }