С# Телеграмм(Telegram) получение координат
Есть проблема с получением координат от пользователя: когда он нажимает на KeyboardButton.WithRequestLocation, бот присылает ему его координаты, но я не могу их получить ни через update.Message.Location, ни через SendLocationAsync().
Код:
if (TextChat == "/start")
{
if (update.Message.Location != null)
{
await client.SendLocationAsync(
chatId: IdUser, update.Message.Location.Latitude, update.Message.Location.Longitude
);
Console.WriteLine($"lat: {update.Message.Location.Latitude}\nlon: {update.Message.Location.Longitude}");
return;
}
ReplyKeyboardMarkup replyKeyboardMarkup = new(new[] {
KeyboardButton.WithRequestLocation("получение координат")
})
{
ResizeKeyboard = true
};
Message sentMessage = await client.SendTextMessageAsync(
chatId: IdUser, text: "кнопка готова к работе!",
replyMarkup: replyKeyboardMarkup, cancellationToken: token
);
await client.SendLocationAsync(
chatId: IdUser, update.Message.Location.Latitude,
update.Message.Location.Longitude
);
Console.WriteLine($"lat: {update.Message.Location.Latitude}\nlon: {update.Message.Location.Longitude}");
Ответы (1 шт):
Автор решения: ilizzium
→ Ссылка
вопрос решился. в самом начале кода фильтровал по Message типу . а там другой тип . поэтому не приходило... 20 часов потратил не зря. на проблему))