...
This commit is contained in:
parent
e4d4d41f05
commit
7f465d9916
@ -117,59 +117,101 @@ class Telegram {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (msg.text?.contains(" ") == true) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
val req = BumlamaReq(msg.text)
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
|
||||||
val fullUrl =
|
|
||||||
"https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage?chat_id=${globalEvv.telegramMyId}&text=lama 에게 전송 => ${req.reqMsg}"
|
|
||||||
logService.log("fullUrl >>> ${fullUrl}")
|
|
||||||
WebClient.create().get()
|
|
||||||
.uri(fullUrl)
|
|
||||||
.retrieve()
|
|
||||||
.bodyToMono(String::class.java).block()
|
|
||||||
}
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
|
||||||
try {
|
|
||||||
if (req.reqMsg?.contains("검색") == true) {
|
|
||||||
val gSearch = "https://www.googleapis.com/customsearch/v1?key=AIzaSyARLXyvmr_554tOy3UCh3naFlZQS3-qQQM&cx=207f328d3ad7242f2&q=${req.reqMsg}&num=5&lr=kr"
|
|
||||||
WebClient.create().post()
|
|
||||||
.uri(gSearch)
|
|
||||||
.body(BodyInserters.fromValue(Gson().toJson(req)))
|
|
||||||
.retrieve()
|
|
||||||
.bodyToMono(String::class.java).timeout(Duration.ofSeconds(6000L)).block()?.let { result ->
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
val client = WebClient.create()
|
|
||||||
client.post()
|
|
||||||
.uri("https://lama.lunaticbum.kr/api/generate")
|
|
||||||
.body(BodyInserters.fromValue(Gson().toJson(req)))
|
|
||||||
.retrieve()
|
|
||||||
.bodyToMono(String::class.java).timeout(Duration.ofSeconds(6000L)).block()?.let { result ->
|
|
||||||
Gson().fromJson(result, BumlamaResp::class.java)?.let { sss ->
|
|
||||||
println(Gson().toJson(sss))
|
|
||||||
val fullUrl = "https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage?chat_id=${globalEvv.telegramMyId}&text=${req.reqMsg}의 대답이 도착했어요.\n\n${sss.response}"
|
|
||||||
logService.log("fullUrl >>> ${fullUrl}")
|
|
||||||
WebClient.create().get()
|
|
||||||
.uri(fullUrl)
|
|
||||||
.retrieve()
|
|
||||||
.bodyToMono(String::class.java).block() ?: "FAIL"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (msg.text?.contains("어디") == true) {
|
} else if (msg.text?.contains("어디") == true) {
|
||||||
msg.from?.id?.let { sendMsg(it.toString()) }
|
msg.from?.id?.let { sendMsg(it.toString()) }
|
||||||
} else {
|
} else {
|
||||||
|
println(msg.text)
|
||||||
|
val req = BumlamaReq(msg.text)
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
val fullUrl =
|
||||||
|
"https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage?chat_id=${globalEvv.telegramMyId}&text=lama 에게 전송 => ${req.reqMsg}"
|
||||||
|
logService.log("fullUrl >>> ${fullUrl}")
|
||||||
|
WebClient.create().get()
|
||||||
|
.uri(fullUrl)
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(String::class.java).block()
|
||||||
|
}
|
||||||
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
|
try {
|
||||||
|
if (req.reqMsg?.contains("주변") == true) {
|
||||||
|
val gSearch = "https://www.googleapis.com/customsearch/v1?key=AIzaSyARLXyvmr_554tOy3UCh3naFlZQS3-qQQM&cx=207f328d3ad7242f2&q=${req.reqMsg}&num=5&lr=kr"
|
||||||
|
println("gSearch >>> ${gSearch}")
|
||||||
|
WebClient.create().get()
|
||||||
|
.uri(gSearch)
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(GoogleSearchResult::class.java).timeout(Duration.ofMinutes(20L)).block()?.let { result ->
|
||||||
|
println("gsearch result ==> ${Gson().toJson(result)}")
|
||||||
|
req.reqMsg = req.reqMsg + "\n\n" + result.items?.map { it.snippet +"\nurl:"+it.link }?.joinToString { "\n" }
|
||||||
|
val client = WebClient.create()
|
||||||
|
client.post()
|
||||||
|
.uri("https://lama.lunaticbum.kr/api/generate")
|
||||||
|
.body(BodyInserters.fromValue(Gson().toJson(req)))
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(String::class.java).timeout(Duration.ofMinutes(20L)).block()?.let { result ->
|
||||||
|
println("generate Result ==> ${result}")
|
||||||
|
Gson().fromJson(result, BumlamaResp::class.java)?.let { sss ->
|
||||||
|
println(Gson().toJson(sss))
|
||||||
|
val fullUrl = "https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage?chat_id=${globalEvv.telegramMyId}&text=${req.reqMsg}의 대답이 도착했어요.\n\n${sss.response}"
|
||||||
|
logService.log("fullUrl >>> ${fullUrl}")
|
||||||
|
WebClient.create().get()
|
||||||
|
.uri(fullUrl)
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(String::class.java).block() ?: "FAIL"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (req.reqMsg?.contains("검색") == true) {
|
||||||
|
val gSearch = "https://www.googleapis.com/customsearch/v1?key=AIzaSyARLXyvmr_554tOy3UCh3naFlZQS3-qQQM&cx=207f328d3ad7242f2&q=${req.reqMsg}&num=5&lr=kr"
|
||||||
|
println("gSearch >>> ${gSearch}")
|
||||||
|
WebClient.create().get()
|
||||||
|
.uri(gSearch)
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(GoogleSearchResult::class.java).timeout(Duration.ofMinutes(20L)).block()?.let { result ->
|
||||||
|
println("gsearch result ==> ${Gson().toJson(result)}")
|
||||||
|
req.reqMsg = req.reqMsg + "\n\n" + result.items?.map { it.snippet +"\nurl:"+it.link }?.joinToString { "\n" }
|
||||||
|
val client = WebClient.create()
|
||||||
|
client.post()
|
||||||
|
.uri("https://lama.lunaticbum.kr/api/generate")
|
||||||
|
.body(BodyInserters.fromValue(Gson().toJson(req)))
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(String::class.java).timeout(Duration.ofMinutes(20L)).block()?.let { result ->
|
||||||
|
println("generate Result ==> ${result}")
|
||||||
|
Gson().fromJson(result, BumlamaResp::class.java)?.let { sss ->
|
||||||
|
println(Gson().toJson(sss))
|
||||||
|
val fullUrl = "https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage?chat_id=${globalEvv.telegramMyId}&text=${req.reqMsg}의 대답이 도착했어요.\n\n${sss.response}"
|
||||||
|
logService.log("fullUrl >>> ${fullUrl}")
|
||||||
|
WebClient.create().get()
|
||||||
|
.uri(fullUrl)
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(String::class.java).block() ?: "FAIL"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
val client = WebClient.create()
|
||||||
|
client.post()
|
||||||
|
.uri("https://lama.lunaticbum.kr/api/generate")
|
||||||
|
.body(BodyInserters.fromValue(Gson().toJson(req)))
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(String::class.java).timeout(Duration.ofMinutes(20L)).block()?.let { result ->
|
||||||
|
Gson().fromJson(result, BumlamaResp::class.java)?.let { sss ->
|
||||||
|
println(Gson().toJson(sss))
|
||||||
|
val fullUrl = "https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage?chat_id=${globalEvv.telegramMyId}&text=${req.reqMsg}의 대답이 도착했어요.\n\n${sss.response}"
|
||||||
|
logService.log("fullUrl >>> ${fullUrl}")
|
||||||
|
WebClient.create().get()
|
||||||
|
.uri(fullUrl)
|
||||||
|
.retrieve()
|
||||||
|
.bodyToMono(String::class.java).block() ?: "FAIL"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logService.log("test $httpServletRequest.requestURI")
|
logService.log("test $httpServletRequest.requestURI")
|
||||||
|
|||||||
@ -58,7 +58,8 @@ class Message {
|
|||||||
var text: String? = null
|
var text: String? = null
|
||||||
@BsonIgnore
|
@BsonIgnore
|
||||||
var entities: ArrayList<Entity>? = null
|
var entities: ArrayList<Entity>? = null
|
||||||
var location : String? = null
|
|
||||||
|
// var location : Map<String,String>? = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -114,4 +115,30 @@ class TelegramMsgService : MsgService {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GoogleSearchResult {
|
||||||
|
|
||||||
|
var items : ArrayList<GSRItem>? = null
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias GSRMeta = Map<String,String>
|
||||||
|
|
||||||
|
class GSRItem{
|
||||||
|
var kind : String? = null //": "customsearch#result",
|
||||||
|
var title : String? = null //": "전국 현재 날씨",
|
||||||
|
var htmlTitle : String? = null //": "전국 현재 <b>날씨</b>",
|
||||||
|
var link : String? = null //": "https://www.accuweather.com/ko/us/united-states-weather",
|
||||||
|
var displayLink : String? = null //": "www.accuweather.com",
|
||||||
|
var snippet : String? = null //": "개인정보 보호정책과 쿠키 사용 정책이 업데이트되었습니다. 이해합니다. ComScore.",
|
||||||
|
var htmlSnippet : String? = null //": "개인정보 보호정책과 쿠키 사용 정책이 업데이트되었습니다. 이해합니다. ComScore.",
|
||||||
|
var formattedUrl : String? = null //": "https://www.accuweather.com/ko/us/united-states-weather",
|
||||||
|
var htmlFormattedUrl : String? = null //": "https://www.accuweather.com/ko/us/united-states-weather",
|
||||||
|
var pagemap : GSRItemPageMap? = null
|
||||||
|
}
|
||||||
|
class GSRItemPageMap {
|
||||||
|
var cse_thumbnail : ArrayList<Map<String,String>>? = null
|
||||||
|
var metatags : ArrayList<Map<String,String>>? = null
|
||||||
|
var cse_image : ArrayList<Map<String,String>>? = null
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user