From c701f1ddd40a6c8ff03d41cb36658677868984f1 Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Sat, 9 Oct 2021 18:26:10 +0800 Subject: [PATCH] update --- core/push.go | 4 ++-- core/store.go | 9 +++++++-- im/qq/main.go | 8 ++++---- im/tg/tg.go | 8 ++++---- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/core/push.go b/core/push.go index 508a006..1aa07b5 100644 --- a/core/push.go +++ b/core/push.go @@ -7,8 +7,8 @@ import ( "github.com/beego/beego/v2/adapter/httplib" ) -var Pushs = map[string]func(int, string){} -var GroupPushs = map[string]func(int, int, string){} +var Pushs = map[string]func(interface{}, string){} +var GroupPushs = map[string]func(interface{}, interface{}, string){} func Push(class string, uid int, content string) { if push, ok := Pushs[class]; ok { diff --git a/core/store.go b/core/store.go index b4c300f..1310057 100644 --- a/core/store.go +++ b/core/store.go @@ -116,11 +116,16 @@ func (bucket Bucket) Foreach(f func(k, v []byte) error) { }) } -var Int = func(s string) int { - i, _ := strconv.Atoi(s) +var Int = func(s interface{}) int { + i, _ := strconv.Atoi(fmt.Sprint(s)) return i } +var Int64 = func(s interface{}) int64 { + i, _ := strconv.Atoi(fmt.Sprint(s)) + return int64(i) +} + func (bucket Bucket) Create(i interface{}) error { s := reflect.ValueOf(i).Elem() id := s.FieldByName("ID") diff --git a/im/qq/main.go b/im/qq/main.go index 0a9abfb..9ed06c9 100644 --- a/im/qq/main.go +++ b/im/qq/main.go @@ -271,10 +271,10 @@ func start() { core.NotifyMasters(fmt.Sprintf("QQ已同意%v的好友申请,验证信息为:%v", request.RequesterUin, request.Message)) } }) - core.Pushs["qq"] = func(i int, s string) { - bot.SendPrivateMessage(int64(i), int64(qq.GetInt("tempMessageGroupCode")), &message.SendingMessage{Elements: bot.ConvertStringMessage(s, false)}) + core.Pushs["qq"] = func(i interface{}, s string) { + bot.SendPrivateMessage(core.Int64(i), int64(qq.GetInt("tempMessageGroupCode")), &message.SendingMessage{Elements: bot.ConvertStringMessage(s, false)}) } - core.GroupPushs["qq"] = func(i, j int, s string) { + core.GroupPushs["qq"] = func(i, _ interface{}, s string) { paths := []string{} for _, v := range regexp.MustCompile(`\[TG:image,file=([^\[\]]+)\]`).FindAllStringSubmatch(s, -1) { paths = append(paths, core.ExecPath+"/data/images/"+v[1]) @@ -285,6 +285,6 @@ func start() { imgs = append(imgs, &coolq.LocalImageElement{File: path}) } // - bot.SendGroupMessage(int64(i), &message.SendingMessage{Elements: append(bot.ConvertStringMessage(s, true), imgs...)}) //&message.AtElement{Target: int64(j)} + bot.SendGroupMessage(core.Int64(i), &message.SendingMessage{Elements: append(bot.ConvertStringMessage(s, true), imgs...)}) //&message.AtElement{Target: int64(j)} } } diff --git a/im/tg/tg.go b/im/tg/tg.go index 054171a..4991ef8 100644 --- a/im/tg/tg.go +++ b/im/tg/tg.go @@ -54,12 +54,12 @@ func init() { logs.Warn("监听telegram机器人失败:%v", err) return } - core.Pushs["tg"] = func(i int, s string) { - b.Send(&tb.User{ID: i}, s) + core.Pushs["tg"] = func(i interface{}, s string) { + b.Send(&tb.User{ID: core.Int(i)}, s) } - core.GroupPushs["tg"] = func(i, j int, s string) { + core.GroupPushs["tg"] = func(i, _ interface{}, s string) { paths := []string{} - ct := &tb.Chat{ID: int64(i)} + ct := &tb.Chat{ID: core.Int64(i)} for _, v := range regexp.MustCompile(`\[CQ:image,file=([^\[\]]+)\]`).FindAllStringSubmatch(s, -1) { paths = append(paths, core.ExecPath+"/data/images/"+v[1]) s = strings.Replace(s, fmt.Sprintf(`[CQ:image,file=%s]`, v[1]), "", -1)