From 4c638e2c2db2fc18d405719867ddba4dff24cf39 Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Tue, 26 Oct 2021 06:56:08 +0800 Subject: [PATCH] update --- core/init.go | 5 +++++ im/wx/init.go | 15 ++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/core/init.go b/core/init.go index 46543d0..127ef2a 100644 --- a/core/init.go +++ b/core/init.go @@ -42,4 +42,9 @@ func init() { initSys() Duration = time.Duration(sillyGirl.GetInt("duration", 5)) * time.Second sillyGirl.Set("started_at", time.Now().Format("2006-01-02 15:04:05")) + api_key := sillyGirl.Get("api_key") + if api_key == "" { + api_key := time.Now().UnixNano() + sillyGirl.Set("api_key", api_key) + } } diff --git a/im/wx/init.go b/im/wx/init.go index 40c63c6..c631fa0 100644 --- a/im/wx/init.go +++ b/im/wx/init.go @@ -9,6 +9,7 @@ import ( "os" "regexp" "strings" + "sync" "github.com/axgle/mahonia" "github.com/beego/beego/v2/adapter/httplib" @@ -169,6 +170,8 @@ func init() { }) } +var wxbase sync.Map + var myip = "" var relaier = wx.Get("relaier") @@ -259,12 +262,14 @@ func (sender *Sender) Reply(msgs ...interface{}) (int, error) { switch item.(type) { case string: pmsg.Msg = item.(string) - // images := []string{} - // for _, v := range regexp.MustCompile(`\[CQ:image,file=base64://([^\[\]]+)\]`).FindAllStringSubmatch(pmsg.Msg, -1) { - // images = append(images, v[1]) - // message = strings.Replace(message, fmt.Sprintf(`[CQ:image,file=base64://%s]`, v[1]), "", -1) + images := []string{} + for _, v := range regexp.MustCompile(`\[CQ:image,file=base64://([^\[\]]+)\]`).FindAllStringSubmatch(pmsg.Msg, -1) { + images = append(images, v[1]) + pmsg.Msg = strings.Replace(pmsg.Msg, fmt.Sprintf(`[CQ:image,file=base64://%s]`, v[1]), "", -1) + } + // for _, image := range images { + // wxbase // } - // if case []byte: pmsg.Msg = string(item.([]byte)) case core.ImageUrl: