This commit is contained in:
lunaticbum 2026-05-06 15:54:23 +09:00
parent 86d8cfeda4
commit 2215e97deb
6 changed files with 69 additions and 24 deletions

View File

@ -42,6 +42,7 @@ class AppConfig : WebMvcConfigurer {
"/bums/where.bs",
"/user/info", // "내 정보" 페이지도 추가하면 좋습니다.
"/tlg/repotToMe.bjx",
"/tlg/sendToMe.bjx",
"/user/login.bs", "/user/signup.bs", "/user/login.bjx","/bookmarks/**",
"/blog/viewer/**", "/blog/posts", "/blog/rankOfViews.bjx", "/blog/recentOfPost.bjx"
)

View File

@ -184,7 +184,11 @@ class SecurityConfig(
.csrf { csrf ->
csrf.ignoringRequestMatchers(
"/api/**", // <-- 이 줄을 추가하세요!
"/user/login.bjx", "/user/joinUser.bjx", "/tlg/repotToMe.bjx",
"/user/login.bjx",
"/user/joinUser.bjx",
"/tlg/repotToMe.bjx",
"/tlg/sendToMe.bjx",
"/tlg/webhook",
"/api/ranks/submit",
"/bums/save/loc.api",
"/puzzle/**",
@ -213,6 +217,7 @@ class SecurityConfig(
"/bums/face.bs", // [추가] 사이트 소개 페이지
"/bookmarks/**", // [추가] 북마크 목록 페이지
"/ads.txt",
"/tlg/webhook",
"/slideshow"
).permitAll()
@ -224,6 +229,8 @@ class SecurityConfig(
"/bums/save/loc.api",
"/puzzle/**",
"/tlg/repotToMe.bjx",
"/tlg/webhook",
"/tlg/sendToMe.bjx",
"/blog/post/*/like.bjx",
"/blog/post/*/unlike.bjx",
"/bookmarks/*/like", // [추가] 북마크 좋아요

View File

@ -1,8 +1,10 @@
package kr.lunaticbum.back.lun.controllers
import com.google.gson.Gson
import kr.lunaticbum.back.lun.model.Result
// [중요] 서비스 클래스 import 추가
import kr.lunaticbum.back.lun.services.TelegramBotService
import kr.lunaticbum.back.lun.utils.extractModelData
import org.springframework.web.bind.annotation.*
@RestController
@ -26,4 +28,38 @@ class Telegram(
telegramBotService.processWebhookUpdate(update)
return "Success"
}
}
@ResponseBody
@PostMapping("repotToMe.bjx")
fun repotToMe(@RequestBody jsonString: String) {
jsonString.extractModelData { exception, originDataString ->
println("jsonString $jsonString $originDataString")
if (exception == null) {
Gson().fromJson<ReportModel>(originDataString, ReportModel::class.java)?.let { msg ->
telegramBotService.sendTelegramMessage(null,"${msg.name}:${msg.email}\n${msg.message}")
}
}
}
}
@ResponseBody
@PostMapping("sendToMe.bjx")
fun sendToMe(@RequestBody jsonString: String) {
println("jsonString $jsonString")
Gson().fromJson<SendToMeModel>(jsonString, SendToMeModel::class.java)?.let { msg ->
telegramBotService.sendTelegramMessage(msg.id,msg.message)
}
}
}
data class SendToMeModel(var id : String, var message : String)
data class ReportModel(
var name : String? = null,
var email : String? = null,
var message : String? = null,
)

View File

@ -87,4 +87,6 @@ class BumsPrivate {
})
return responce
}
}

View File

@ -4,7 +4,6 @@ package kr.lunaticbum.back.lun.service
import jakarta.annotation.PostConstruct
import kotlinx.coroutines.reactor.awaitSingle
import kotlinx.coroutines.runBlocking
import kr.lunaticbum.back.lun.configs.core.GlobalEnvironment
import kr.lunaticbum.back.lun.model.AutoTradeEntity
import kr.lunaticbum.back.lun.model.KisAuthSession
@ -14,7 +13,6 @@ import kr.lunaticbum.back.lun.repository.AutoTradeRepository
import kr.lunaticbum.back.lun.repository.TradeHistoryRepository
import kr.lunaticbum.back.lun.services.TelegramBotService
import kr.lunaticbum.back.lun.utils.MarketTimeManager
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Service
import java.util.concurrent.CopyOnWriteArrayList

View File

@ -92,7 +92,7 @@ class TelegramBotService(
private fun fetchAndSendWeather(chatId: String, lat: BigDecimal, long: BigDecimal) {
WebClient.create().get()
.uri("http://api.weatherapi.com/v1/current.json?key=${globalEvv.weatherApiKey}&q=${lat},${long}&aqi=no")
.uri("https://api.weatherapi.com/v1/current.json?key=${globalEvv.weatherApiKey}&q=${lat},${long}&aqi=no")
.retrieve()
.bodyToMono(CurrentWeather::class.java)
.timeout(Duration.ofSeconds(30L))
@ -136,23 +136,23 @@ class TelegramBotService(
val chatId = msg.from?.id?.toString() ?: return
val text = msg.text ?: return
val req = BumlamaReq(text)
CoroutineScope(Dispatchers.IO).launch {
val feedbackUrl = "$telegramApiBaseUrl/${globalEvv.telegramBotKey}/sendMessage?chat_id=${globalEvv.telegramMyId}&text=blama 일시키겠=> '${req.reqMsg}'"
logService.log("AI Req: $feedbackUrl")
WebClient.create().get()
.uri(feedbackUrl)
.retrieve()
.bodyToMono(String::class.java).block()
}
CoroutineScope(Dispatchers.IO).launch {
val dateContext = SimpleDateFormat("yyyy-MM-dd").format(Date())
val modifiedQuery = text.replace("오늘", "오늘($dateContext)")
// [수정] 서비스 객체 이름 변경 (lama -> lamaService)
lamaService.generateResponse(modifiedQuery, chatId)
}
// val req = BumlamaReq(text)
// CoroutineScope(Dispatchers.IO).launch {
// val feedbackUrl = "$telegramApiBaseUrl/${globalEvv.telegramBotKey}/sendMessage?chat_id=${globalEvv.telegramMyId}&text=blama 일시키겠=> '${req.reqMsg}'"
// logService.log("AI Req: $feedbackUrl")
// WebClient.create().get()
// .uri(feedbackUrl)
// .retrieve()
// .bodyToMono(String::class.java).block()
// }
//
// CoroutineScope(Dispatchers.IO).launch {
// val dateContext = SimpleDateFormat("yyyy-MM-dd").format(Date())
// val modifiedQuery = text.replace("오늘", "오늘($dateContext)")
//
// // [수정] 서비스 객체 이름 변경 (lama -> lamaService)
// lamaService.generateResponse(modifiedQuery, chatId)
// }
}
private fun sendCurrentLocation(targetChatId: String) {
@ -167,9 +167,10 @@ class TelegramBotService(
}
}
fun sendTelegramMessage(chatId: String, text: String) {
fun sendTelegramMessage(chatId: String?, text: String) {
val id = chatId ?: globalEvv.telegramMyId ?: return
val fullUrl = "$telegramApiBaseUrl/${globalEvv.telegramBotKey}/sendMessage"
val msgObj = TelegramSendMsg(chatId, text)
val msgObj = TelegramSendMsg(id, text)
try {
WebClient.create(fullUrl)