Пример #1
0
        public async Task <bool> QuerySheetAsync(int linkedMessageId, string callbackQueryId, int chatId, int scale)
        {
            var coordinates = await _amazonDynamoDbService.QueryAsync(chatId);

            var sheets = _sheetService.GetSheetsByCoordinate(coordinates.lat, coordinates.lon, scale).ToList();

            if (!sheets.Any())
            {
                return(false);
            }

            var deleteMessage = new TelegramDeleteMessage
            {
                ChatId    = chatId,
                MessageId = linkedMessageId
            };
            await _telegramService.DeleteMessage(deleteMessage);

            var answerCallbackQuery = new AnswerCallbackQuery
            {
                CallbackQueryId = callbackQueryId,
                Text            = "Sorgu tamamlandı."
            };

            await _telegramService.AnswerCallbackQuery(answerCallbackQuery);

            string messageText;

            if (sheets.Count() > 1)
            {
                messageText = "Birden fazla pafta ile kesişiyor:";
                foreach (var sheetDto in sheets)
                {
                    messageText += "\n" + sheetDto.Name;
                }
            }
            else
            {
                messageText = sheets.FirstOrDefault().Name;
            }

            messageText += $"\nÖlçek: 1:{scale}.000";
            messageText += $"\nKoordinatlar: {coordinates.lat:F6}, {coordinates.lon:F6}";

            var message = new TelegramMessage
            {
                ChatId = chatId.ToString(),
                Text   = messageText
            };

            return(await _telegramService.SendMessage(message));
        }
Пример #2
0
        public async Task <bool> SetMagnitudeAsync(int linkedMessageId, string callbackQueryId, int chatId, double magnitude)
        {
            var updateRequest = _updateRequestBuilder
                                .CreateRequest(chatId)
                                .SetMagnitude(magnitude)
                                .Build();

            var updateResult = await _subscribtionStore.UpdateAsync(updateRequest);

            if (!updateResult)
            {
                return(false);
            }

            var deleteMessage = new TelegramDeleteMessage
            {
                ChatId    = chatId,
                MessageId = linkedMessageId
            };
            await _telegramService.DeleteMessage(deleteMessage);

            var answerCallbackQuery = new AnswerCallbackQuery
            {
                CallbackQueryId = callbackQueryId,
                Text            = string.Format(BotDialog.REPLY_MAGNITUDE, magnitude)
            };
            await _telegramService.AnswerCallbackQuery(answerCallbackQuery);

            var message = new TelegramMessage
            {
                ChatId = chatId.ToString(),
                Text   = string.Format(BotDialog.REPLY_MAGNITUDE, magnitude)
            };

            return(await _telegramService.SendMessage(message));
        }