parent
331b7aa0ef
commit
095c36fbac
@ -1,12 +1,12 @@
|
||||
package handle
|
||||
|
||||
import (
|
||||
"WechatGateWay/global"
|
||||
"WechatGateWay/third_part"
|
||||
"WechatGateWay/utils"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func replyImage(msgContent MsgContent, timestamp, nonce string, w http.ResponseWriter) {
|
||||
third_part.SendPicMid(msgContent.FromUsername, utils.RandMapValue(global.ImageMap))
|
||||
//third_part.SendPicMid(msgContent.FromUsername, utils.RandMapValue(global.ImageMap))
|
||||
third_part.SendPicFile(msgContent.FromUsername, "/app/data/"+utils.RandomFile("/app/data"))
|
||||
}
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"log"
|
||||
"math/rand"
|
||||
"os"
|
||||
)
|
||||
|
||||
func RandomFile(dirname string) string {
|
||||
fileList, err := os.ReadDir(dirname)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return ""
|
||||
}
|
||||
return fileList[rand.Intn(len(fileList))].Name()
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRandomFile(tt *testing.T) {
|
||||
dirname := "D:\\SynologyDrive\\SynologyDrive\\Pictures\\照片\\gg\\2022"
|
||||
fmt.Println(RandomFile(dirname))
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue