Пример #1
0
        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public async Task <Result> FunctionHandlerAsync(SlackSlashCommand input, ILambdaContext context)
        {
            // Parse to result
            var split = input.Body.Split('&');

            if (split.Length != 10)
            {
                throw new ArgumentOutOfRangeException(nameof(split));
            }
            var result = new ParseResult(split);

            // Authentication Validation
            if (string.IsNullOrWhiteSpace(validToken))
            {
                throw new NullReferenceException(validToken);
            }

            // Validate
            if (result.Token != validToken)
            {
                throw new UnauthorizedAccessException();
            }

            // For Test purpose. You can check what was request strings.
            //return new Result("in_channel", input.Body);

            // Only you can see response when you change in_channel -> ephemeral.
            return(new Result("in_channel", "Hello from Lambda .NET Core."));
        }
Пример #2
0
 public static void Main(string[] args)
 {
     var input = new SlackSlashCommand {
         Body = "token=XXXXXXXXXXXXXXXXXXXXXX&team_id=1234&team_domain=hogemoge&channel_id=1234&channel_name=hogemoge&user_id=hogemoge&user_name=hogemoge&command=%2Fnow&text=&response_url=https%3A%2F%2Fhooks.slack.com%2Fcommands%2123%2F456%2F789"
     };
     var response = new Function().FunctionHandlerAsync(input, new LambdaContext());
 }