...
This commit is contained in:
parent
e909df301d
commit
1cfb379ecc
@ -44,7 +44,7 @@ class BumsInterceptor : HandlerInterceptor {
|
||||
handler: Any,
|
||||
@Nullable modelAndView: ModelAndView?
|
||||
) {
|
||||
var skippResourcesExtension = arrayListOf(".ajax",".js",".css","/tlg/").filter { request.requestURI.contains(it)}.size > 0
|
||||
var skippResourcesExtension = arrayListOf(".ajax",".js",".css","/tlg/",".api").filter { request.requestURI.contains(it)}.size > 0
|
||||
if (!skippResourcesExtension) {
|
||||
if (request.requestURI.contains("logout") == false && !request.cookies.isNullOrEmpty() && request.cookies.filter {
|
||||
it.name.equals(
|
||||
|
||||
@ -144,6 +144,9 @@ class Telegram {
|
||||
try {
|
||||
var pref = Preferences.userNodeForPackage(Telegram::class.java)
|
||||
var prefKey = pref.get("GAPI_KEY".plus("_").plus(msg.from!!.id.toString()),"")
|
||||
if (prefKey?.length ?: 0 < 4) {
|
||||
prefKey = globalEvv.gapiKey
|
||||
}
|
||||
println("prefKey >> ${prefKey}")
|
||||
if (prefKey != null && prefKey.length > 0) {
|
||||
println("test strat ${msg.location}")
|
||||
@ -222,113 +225,60 @@ class Telegram {
|
||||
}
|
||||
}
|
||||
} else if(msg.text?.startsWith("/") == true) {
|
||||
msg.text?.split(" ")?.let { cmds ->
|
||||
cmds[0].let { cmd ->
|
||||
when(cmd.trim()) {
|
||||
"/reqGapiKeys" -> {
|
||||
sendSimpleMsg(globalEvv.telegramBotKey!!,globalEvv.telegramMyId!!,"${msg.from!!.id.toString()}님이 서비스 키를 요첨항./setGaipKeys {key}")
|
||||
}
|
||||
"/setGaipKeys" -> {
|
||||
var pref = Preferences.userNodeForPackage(Telegram::class.java)
|
||||
pref.put("GAPI_KEY".plus("_").plus(msg.from!!.id.toString()), cmds[1])
|
||||
pref.sync()
|
||||
println("test prefKey ${"GAPI_KEY".plus("_").plus(msg.from!!.id.toString())}")
|
||||
println("test prefKey ${cmds[1]}")
|
||||
println("test prefKey ${pref.get("GAPI_KEY".plus("_").plus(msg.from!!.id.toString()),"")}")
|
||||
|
||||
}
|
||||
"/get" ->{}
|
||||
"/jf" ->{
|
||||
// CoroutineScope(Dispatchers.IO).launch {
|
||||
// logService.log("${cmd} Start ${cmds[1]}")
|
||||
// String.format(String(Base64.getMimeDecoder().decode("aHR0cHM6Ly9qYXZtb3N0LnRvL3NlYXJjaC9tb3ZpZS8lcw==".toByteArray())),cmds[1]).getJ().let { doc -> FeedParseManager.parse(doc,rssDataService) }
|
||||
// logService.log("${cmd} END ${cmds[1]}")
|
||||
// msg.text?.split(" ")?.let { cmds ->
|
||||
// cmds[0].let { cmd ->
|
||||
// when(cmd.trim()) {
|
||||
// "/reqGapiKeys" -> {
|
||||
// sendSimpleMsg(globalEvv.telegramBotKey!!,globalEvv.telegramMyId!!,"${msg.from!!.id.toString()}님이 서비스 키를 요첨항./setGaipKeys {key}")
|
||||
// }
|
||||
// CoroutineScope(Dispatchers.IO).launch {
|
||||
// logService.log("on Cmd JF with SO")
|
||||
// logService.log("${cmd} Start ${cmds[1]}")
|
||||
// String.format(String(Base64.getMimeDecoder().decode("aHR0cHM6Ly9rcjcwLnNvZ2lybC5zby8/cz0lcw==".toByteArray())),cmds[1]).getJ().let { doc -> FeedParseManager.parse(doc,rssDataService)}
|
||||
// logService.log("${cmd} END ${cmds[1]}")
|
||||
// "/setGaipKeys" -> {
|
||||
// var pref = Preferences.userNodeForPackage(Telegram::class.java)
|
||||
// pref.put("GAPI_KEY".plus("_").plus(msg.from!!.id.toString()), cmds[1])
|
||||
// pref.sync()
|
||||
// println("test prefKey ${"GAPI_KEY".plus("_").plus(msg.from!!.id.toString())}")
|
||||
// println("test prefKey ${cmds[1]}")
|
||||
// println("test prefKey ${pref.get("GAPI_KEY".plus("_").plus(msg.from!!.id.toString()),"")}")
|
||||
//
|
||||
// }
|
||||
}
|
||||
"/lama" -> {
|
||||
val req = BumlamaReq(msg.text!!.replace(cmd,""))
|
||||
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 {
|
||||
logService.log("${cmd} Start ${cmds[1]}")
|
||||
// msg.chat?.id
|
||||
try {
|
||||
val client = WebClient.create()
|
||||
client.post()
|
||||
.uri(lamaGenerated)
|
||||
.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=${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("${cmd[0]} END ${cmd[1]}")
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (msg.text?.contains("어디") == true) {
|
||||
msg.from?.id?.let { sendMsg(it.toString()) }
|
||||
} 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}")
|
||||
// "/get" ->{}
|
||||
// "/jf" ->{
|
||||
//// CoroutineScope(Dispatchers.IO).launch {
|
||||
//// logService.log("${cmd} Start ${cmds[1]}")
|
||||
//// String.format(String(Base64.getMimeDecoder().decode("aHR0cHM6Ly9qYXZtb3N0LnRvL3NlYXJjaC9tb3ZpZS8lcw==".toByteArray())),cmds[1]).getJ().let { doc -> FeedParseManager.parse(doc,rssDataService) }
|
||||
//// logService.log("${cmd} END ${cmds[1]}")
|
||||
//// }
|
||||
//// CoroutineScope(Dispatchers.IO).launch {
|
||||
//// logService.log("on Cmd JF with SO")
|
||||
//// logService.log("${cmd} Start ${cmds[1]}")
|
||||
//// String.format(String(Base64.getMimeDecoder().decode("aHR0cHM6Ly9rcjcwLnNvZ2lybC5zby8/cz0lcw==".toByteArray())),cmds[1]).getJ().let { doc -> FeedParseManager.parse(doc,rssDataService)}
|
||||
//// logService.log("${cmd} END ${cmds[1]}")
|
||||
//// }
|
||||
// }
|
||||
// "/lama" -> {
|
||||
// val req = BumlamaReq(msg.text!!.replace(cmd,""))
|
||||
// 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(gSearch)
|
||||
// .uri(fullUrl)
|
||||
// .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" }
|
||||
// .bodyToMono(String::class.java).block()
|
||||
// }
|
||||
// CoroutineScope(Dispatchers.IO).launch {
|
||||
// logService.log("${cmd} Start ${cmds[1]}")
|
||||
//// msg.chat?.id
|
||||
// try {
|
||||
// val client = WebClient.create()
|
||||
// client.post()
|
||||
// .uri("https://lama.lunaticbum.kr/api/generate")
|
||||
// .uri(lamaGenerated)
|
||||
// .body(BodyInserters.fromValue(Gson().toJson(req)))
|
||||
// .retrieve()
|
||||
// .bodyToMono(String::class.java).timeout(Duration.ofMinutes(20L)).block()?.let { result ->
|
||||
// println("generate Result ==> ${result}")
|
||||
// .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}"
|
||||
// val fullUrl = "https://api.telegram.org/${globalEvv.telegramBotKey}/sendMessage?chat_id=${globalEvv.telegramMyId}&text=${sss.response}"
|
||||
// logService.log("fullUrl >>> ${fullUrl}")
|
||||
// WebClient.create().get()
|
||||
// .uri(fullUrl)
|
||||
@ -336,36 +286,38 @@ class Telegram {
|
||||
// .bodyToMono(String::class.java).block() ?: "FAIL"
|
||||
// }
|
||||
// }
|
||||
// } catch (e: Exception) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
|
||||
} else if (req.reqMsg?.contains("검색") == true) {
|
||||
var originalQuery = req.reqMsg
|
||||
lama.generateResponse(originalQuery,msg.from?.id.toString())
|
||||
//
|
||||
// logService.log("${cmd[0]} END ${cmd[1]}")
|
||||
// }
|
||||
// }
|
||||
// else -> {}
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
} else if (msg.text?.contains("어디") == true) {
|
||||
msg.from?.id?.let { sendMsg(it.toString()) }
|
||||
} else {
|
||||
val client = WebClient.create()
|
||||
client.post()
|
||||
.uri(lamaGenerated)
|
||||
.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}"
|
||||
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=blama 일시키겠=> '${req.reqMsg}'"
|
||||
logService.log("fullUrl >>> ${fullUrl}")
|
||||
WebClient.create().get()
|
||||
.uri(fullUrl)
|
||||
.retrieve()
|
||||
.bodyToMono(String::class.java).block() ?: "FAIL"
|
||||
.bodyToMono(String::class.java).block()
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
var originalQuery = msg.text
|
||||
lama.generateResponse(originalQuery?.replace("오늘","오늘(${SimpleDateFormat("yyyy-MM-dd").format(Date())})"),msg.from?.id.toString())
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
logService.log("test $httpServletRequest.requestURI")
|
||||
} catch (e : Exception) {
|
||||
}
|
||||
|
||||
@ -147,7 +147,13 @@ class Lama {
|
||||
refinedQuery?.keywords?.let { querys.add(it.joinToString { " " })}
|
||||
val readedUrls = ArrayList<String>()
|
||||
querys.forEach { refinedQuery ->
|
||||
val gSearch = "https://psn.lunaticbum.kr/search?q=${refinedQuery?.replace("오늘", SimpleDateFormat("yyyMMdd").format(Date()))}&language=ko&time_range=month&safesearch=0&categories=general&format=json"
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val gSearch = "https://psn.lunaticbum.kr/search?q=${
|
||||
refinedQuery?.replace(
|
||||
"오늘",
|
||||
SimpleDateFormat("yyyMMdd").format(Date())
|
||||
)
|
||||
}&language=ko&time_range=month&safesearch=0&categories=general&format=json"
|
||||
println("gSearch >>> ${gSearch}")
|
||||
WebClient.create().get()
|
||||
.uri(gSearch)
|
||||
@ -165,7 +171,10 @@ class Lama {
|
||||
it.originHtml = text
|
||||
webPageSummarize(it, text)
|
||||
}
|
||||
}catch(e:Exception){e.printStackTrace()}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@
|
||||
<div class="box highlight">
|
||||
<i class="icon solid major fa-pencil-alt"></i>
|
||||
<h3>글쓰기[Writing]</h3>
|
||||
<br>오직 주인장 만의 권한 임요. 그냥 내가 쓰기 편하게 여기 놔둔 메뉴임. 님들은 못씀요.<br>[Only the owner has the authority. This is just a menu that I put here for my convenience. You can't use it.]</p>
|
||||
<p>오직 주인장 만의 권한 임요. 그냥 내가 쓰기 편하게 여기 놔둔 메뉴임. 님들은 못씀요.<br>[Only the owner has the authority. This is just a menu that I put here for my convenience. You can't use it.]</p>
|
||||
</div>
|
||||
</section>
|
||||
<section class="col-4 col-12-narrower">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user