....
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()
|
WebClient.create().get()
|
||||||
.uri(restUrl)
|
.uri(restUrl)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
@ -110,44 +110,40 @@ class Telegram {
|
|||||||
.timeout(Duration.ofSeconds(30L))
|
.timeout(Duration.ofSeconds(30L))
|
||||||
.block()?.let { sss ->
|
.block()?.let { sss ->
|
||||||
println("restUrl >>> ${restUrl}")
|
println("restUrl >>> ${restUrl}")
|
||||||
var topResult = arrayListOf<Place>()
|
try {
|
||||||
sss.results.forEach {
|
var topResult = arrayListOf<Place>()
|
||||||
try {
|
sss.results.forEach {
|
||||||
if (it.rating?.toDouble() ?: 0.0 > 4.0) {
|
try {
|
||||||
it.getDistane(lat.toDouble(),long.toDouble())
|
if (it.rating?.toDouble() ?: 0.0 >= 4.0) {
|
||||||
println("${it.name} => ${Gson().toJson(it)}")
|
it.getDistane(lat.toDouble(),long.toDouble())
|
||||||
topResult.add(it)
|
println("${it.name} => ${Gson().toJson(it)}")
|
||||||
}
|
topResult.add(it)
|
||||||
} catch (e : Exception) {
|
}
|
||||||
|
} 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()
|
||||||
|
|
||||||
}
|
.bodyToMono(String::class.java).block() ?: "FAIL"
|
||||||
}
|
println("fullUrl ${fullUrl} : result $result")
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
} 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"
|
// "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