package routers import ( "fmt" "github.com/gin-gonic/gin" "github.com/xuri/excelize/v2" "log" "net/url" "strings" "wechathook/models" ) func QQ(c *gin.Context) { name := c.Query("name") name, _ = url.QueryUnescape(name) log.Println("收到QQ信息:", name) f, err := excelize.OpenFile("database.xlsx") if err != nil { log.Println(err) return } reply := "" // 获取 Sheet1 上所有单元格 rows, err := f.GetRows("Sheet1") for _, row := range rows { if strings.Contains(row[0], name) { reply += row[1] + "\n" } } reply = strings.Trim(reply, "\n") result := "" replyTemplate := models.FindSetting("replyTemplate").Value if replyTemplate != "" { result = fmt.Sprintf(replyTemplate, reply) } c.String(200, result) }