Пример #1
0
        public IActionResult Get(string message)
        {
            if (message == null)
            {
                throw new ArgumentException();
            }
            message = message.ToLower();
            var handledMessage = _vkService.GetHandledMessage(message);

            return(Ok(handledMessage));
        }
        public IActionResult Callback([FromBody] Updates updates)
        {
            switch (updates.Type)
            {
            case "confirmation": return(Ok(_configuration["Config:Confirmation"]));

            case "message_new":
            {
                var msg = Message.FromJson(new VkResponse(updates.Object));

                _vkApi.Messages.Send(new MessagesSendParams
                    {
                        RandomId = new DateTime().Millisecond,
                        PeerId   = msg.PeerId.Value,
                        Message  = _vkService.GetHandledMessage(msg.Text?.ToLower())
                    });
                break;
            }
            }

            return(Ok("ok"));
        }