Ejemplo n.º 1
0
        public async Task HandleRequestAsync(BotRequest botRequest)
        {
            // default destination (sender)

            if (botRequest.IsDirectMessage)
            {
                try
                {
                    bool isRegistered = await _botRepository.IsLinkRegistered(botRequest.Messenger, botRequest.UserId);

                    if (!isRegistered)
                    {
                        var bindAccountCommand = new BindAccountCommand(botRequest.Messenger, botRequest.ChannelId, botRequest.UserId);
                        await _mediator.Send(bindAccountCommand);

                        return;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }

            var isSuccess = await TryRunCheckVacationCommand(botRequest);

            if (isSuccess)
            {
                return;
            }

            isSuccess = await TryRunSetVacationCommand(botRequest);

            if (isSuccess)
            {
                return;
            }

            isSuccess = await TryRunRepostCommand(botRequest);

            if (isSuccess)
            {
                return;
            }

            var command = new UnknownCommand(botRequest.Messenger, botRequest.ChannelId, botRequest.UserId, botRequest.Text);
            await _mediator.Send(command);
        }