Exemplo n.º 1
0
        public ActionResult <DialogsResponse> Post(DialogsRequest req)
        {
            _subscribeOperation.Subscribe(req.Session.UserId, "41946361");  // Дмитрий Емец
            _subscribeOperation.Subscribe(req.Session.UserId, "2222944");   // Андрей Ромашко
            _subscribeOperation.Subscribe(req.Session.UserId, "19458733");  // Степан Берёзкин
            _subscribeOperation.Subscribe(req.Session.UserId, "1152487");   // Владимир Киняйкин
            _subscribeOperation.Subscribe(req.Session.UserId, "562314067"); // Я

            var message = _dequeueOperation.Dequeue(req.Session.UserId) switch
            {
                Just <string> article => article.Value,
                _ => "Сохраняйте спокойствие и ждите новостей"
            };

            return(BuildDialogsResponse(req, message));
        }
Exemplo n.º 2
0
        private DialogsResponse BuildDialogsResponse(DialogsRequest req, string text)
        {
            var session    = req.Session;
            var cuttedText = text.Substring(0, Math.Min(text.Length, MAX_ANSWER_LENGTH));

            return(new DialogsResponse
            {
                Response = new WebhookResponseData
                {
                    Text = cuttedText
                },
                Session = new WebhookResponseSession
                {
                    MessageId = session.MessageId,
                    SessionId = session.SessionId,
                    UserId = session.UserId
                },
                Version = req.Version
            });
        }