This commit is contained in:
lunaticbum 2024-10-05 17:14:07 +09:00
parent 2ae91ebd66
commit b945a0d677
3 changed files with 42 additions and 8 deletions

View File

@ -16,6 +16,14 @@ import java.util.*
@EnableScheduling // 추가
@SpringBootApplication
class LunApplication {
init {
val client = WebClient.create()
client.get()
.uri("https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/sendMessage?chat_id=71476436&text=SERVER_START")
.retrieve()
.bodyToMono(String::class.java).block() ?: "FAIL"
}
@Scheduled(cron = "0 0 0/4 * * *") //
fun runJob() {
try {

View File

@ -13,15 +13,36 @@ class Telegram {
}
@ResponseBody
@GetMapping("webhook")
fun test(@PathVariable path : String) {
println("path >>> $path")
val client = WebClient.create()
client.get()
.uri("https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/getUpdates")
.retrieve()
.bodyToMono(String::class.java).block() ?: "FAIL"
@PostMapping("webhook")
fun test(httpServletRequest: HttpServletRequest, @RequestBody update : TelegramUpdate?) {
try {
logger.log("test strat ${update}")
logger.log("test strat ${httpServletRequest.requestURI}")
// val client0 = WebClient.create()
// client0.get()
// .uri("https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/getUpdates")
// .retrieve()
// .bodyToMono(String::class.java).subscribe { result ->
logger.log("test $httpServletRequest.requestURI")
// var sss = Gson().fromJson<TelegramUpdate>(jsonString, TelegramUpdate::class.java)
// if (sss.ok) {
// var doSend = false
// sss.result?.forEach {
// if (!doSend) doSend = it.message?.text?.contains("어디") ?: false
// }
// if (doSend) {
// val client = WebClient.create()
// client.get()
// .uri("https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/sendMessage?chat_id=71476436&text=OK")
// .retrieve()
// .bodyToMono(String::class.java).block() ?: "FAIL"
// }
// logger.log("test OK")
// }
// }
} catch (e : Exception) {
}
}
// @ResponseBody

View File

@ -8,6 +8,11 @@ spring.data.mongodb.host=nas.lunaticbum.kr
#spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=lun_db
#SSL
server.ssl.key-store=classpath:prv.p12
server.ssl.key-store-type=PKCS12
server.ssl.key-store-password=VioPup*383
server.http2.enabled=true
#spring.main.web-application-type=SERVLET
#logging.level.org.springframework.boot.autoconfigure=ERROR
#spring.mvc.view.prefix=/templates