....
This commit is contained in:
parent
88a1c7fae4
commit
deb4a8e262
@ -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()
|
||||
.uri(restUrl)
|
||||
.retrieve()
|
||||
@ -110,44 +110,40 @@ class Telegram {
|
||||
.timeout(Duration.ofSeconds(30L))
|
||||
.block()?.let { sss ->
|
||||
println("restUrl >>> ${restUrl}")
|
||||
var topResult = arrayListOf<Place>()
|
||||
sss.results.forEach {
|
||||
try {
|
||||
if (it.rating?.toDouble() ?: 0.0 > 4.0) {
|
||||
it.getDistane(lat.toDouble(),long.toDouble())
|
||||
println("${it.name} => ${Gson().toJson(it)}")
|
||||
topResult.add(it)
|
||||
}
|
||||
} catch (e : Exception) {
|
||||
try {
|
||||
var topResult = arrayListOf<Place>()
|
||||
sss.results.forEach {
|
||||
try {
|
||||
if (it.rating?.toDouble() ?: 0.0 >= 4.0) {
|
||||
it.getDistane(lat.toDouble(),long.toDouble())
|
||||
println("${it.name} => ${Gson().toJson(it)}")
|
||||
topResult.add(it)
|
||||
}
|
||||
} catch (e : Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
topResult.forEach {
|
||||
try {
|
||||
val msg = TelegramSendMsg("${msg.from!!.id!!}", it.toString())
|
||||
println("msg >>> ${Gson().toJson(msg)}")
|
||||
val fullUrl = "https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage"
|
||||
val result = WebClient.create(fullUrl)
|
||||
.post()
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.body(BodyInserters.fromValue(Gson().toJson(msg)))
|
||||
.retrieve()
|
||||
|
||||
}
|
||||
}
|
||||
topResult.sortedBy { it.rating }.forEach {
|
||||
try {
|
||||
val msg = TelegramSendMsg(
|
||||
"${msg.from!!.id!!}",
|
||||
it.toString()
|
||||
)
|
||||
println("msg >>> ${Gson().toJson(msg)}")
|
||||
// val fullUrl =
|
||||
// "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)
|
||||
// .get()
|
||||
.post()
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.body(BodyInserters.fromValue(Gson().toJson(msg)))
|
||||
.retrieve()
|
||||
|
||||
.bodyToMono(String::class.java).block() ?: "FAIL"
|
||||
println("fullUrl ${fullUrl} : result $result")
|
||||
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
.bodyToMono(String::class.java).block() ?: "FAIL"
|
||||
println("fullUrl ${fullUrl} : result $result")
|
||||
|
||||
} catch (e: Exception) {
|
||||
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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user