This commit is contained in:
lunaticbum 2025-02-24 18:38:45 +09:00
parent 88a1c7fae4
commit deb4a8e262

View File

@ -102,7 +102,7 @@ class Telegram {
} }
} }
} }
var restUrl = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${lat}%2c${long}&radius=5000&type=restaurant&key=AIzaSyARLXyvmr_554tOy3UCh3naFlZQS3-qQQM" var restUrl = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${lat}%2c${long}&radius=2000&type=restaurant&key=AIzaSyARLXyvmr_554tOy3UCh3naFlZQS3-qQQM&rankby=prominence"
WebClient.create().get() WebClient.create().get()
.uri(restUrl) .uri(restUrl)
.retrieve() .retrieve()
@ -110,31 +110,25 @@ class Telegram {
.timeout(Duration.ofSeconds(30L)) .timeout(Duration.ofSeconds(30L))
.block()?.let { sss -> .block()?.let { sss ->
println("restUrl >>> ${restUrl}") println("restUrl >>> ${restUrl}")
try {
var topResult = arrayListOf<Place>() var topResult = arrayListOf<Place>()
sss.results.forEach { sss.results.forEach {
try { try {
if (it.rating?.toDouble() ?: 0.0 > 4.0) { if (it.rating?.toDouble() ?: 0.0 >= 4.0) {
it.getDistane(lat.toDouble(),long.toDouble()) it.getDistane(lat.toDouble(),long.toDouble())
println("${it.name} => ${Gson().toJson(it)}") println("${it.name} => ${Gson().toJson(it)}")
topResult.add(it) topResult.add(it)
} }
} catch (e : Exception) { } catch (e : Exception) {
e.printStackTrace()
} }
} }
topResult.sortedBy { it.rating }.forEach { topResult.forEach {
try { try {
val msg = TelegramSendMsg( val msg = TelegramSendMsg("${msg.from!!.id!!}", it.toString())
"${msg.from!!.id!!}",
it.toString()
)
println("msg >>> ${Gson().toJson(msg)}") println("msg >>> ${Gson().toJson(msg)}")
// val fullUrl = val fullUrl = "https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage"
// "https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage?chat_id=${msg.userId}&text=${msg.msg}"
val fullUrl =
"https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage"
val result = WebClient.create(fullUrl) val result = WebClient.create(fullUrl)
// .get()
.post() .post()
.contentType(MediaType.APPLICATION_JSON) .contentType(MediaType.APPLICATION_JSON)
.body(BodyInserters.fromValue(Gson().toJson(msg))) .body(BodyInserters.fromValue(Gson().toJson(msg)))
@ -147,7 +141,9 @@ class Telegram {
e.printStackTrace() e.printStackTrace()
} }
} }
} catch (e: Exception) {
e.printStackTrace()
}
} }
// "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${lat},${long}&radius=5000&type=cafe&key=AIzaSyARLXyvmr_554tOy3UCh3naFlZQS3-qQQM" // "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=${lat},${long}&radius=5000&type=cafe&key=AIzaSyARLXyvmr_554tOy3UCh3naFlZQS3-qQQM"