kefu/wechathook/routers/search.go

23 lines
515 B
Go
Raw Normal View History

2024-12-10 02:50:12 +00:00
package routers
import (
"fmt"
"github.com/gin-gonic/gin"
"wechathook/models"
"wechathook/service"
)
func GetSearch(c *gin.Context) {
message := c.Query("message")
result := service.SearchKeywordReplys(models.FindSetting("keywords").Value, message)
finalReply := models.FindSetting("finalReply").Value
replyTemplate := models.FindSetting("replyTemplate").Value
if result == "" {
result = finalReply
}
if replyTemplate != "" {
result = fmt.Sprintf(replyTemplate, result)
}
c.String(200, result)
}