From 7731289fab12ac3ae920f3c3296d6563d4c1ddb1 Mon Sep 17 00:00:00 2001 From: cdle <798731886@qq.com> Date: Thu, 16 Sep 2021 21:33:22 +0800 Subject: [PATCH] update --- core/push.go | 9 +++++++++ im/qq/main.go | 3 +++ im/tg/tg.go | 3 +++ 3 files changed, 15 insertions(+) create mode 100644 core/push.go diff --git a/core/push.go b/core/push.go new file mode 100644 index 0000000..a111fce --- /dev/null +++ b/core/push.go @@ -0,0 +1,9 @@ +package core + +var Pushs = map[string]func(int, string){} + +func Push(class string, uid int, content string) { + if push, ok := Pushs[class]; ok { + push(uid, content) + } +} diff --git a/im/qq/main.go b/im/qq/main.go index 333cb1b..87d6891 100644 --- a/im/qq/main.go +++ b/im/qq/main.go @@ -215,4 +215,7 @@ func init() { bot.Client.OnSelfPrivateMessage(onPrivateMessage) bot.Client.OnGroupMessage(OnGroupMessage) bot.Client.OnSelfGroupMessage(OnGroupMessage) + core.Pushs["qq"] = func(i int, s string) { + bot.SendPrivateMessage(int64(i), int64(qq.GetInt("groupCode")), &message.SendingMessage{Elements: []message.IMessageElement{&message.TextElement{Content: s}}}) + } } diff --git a/im/tg/tg.go b/im/tg/tg.go index 65a8b78..af0d254 100644 --- a/im/tg/tg.go +++ b/im/tg/tg.go @@ -43,6 +43,9 @@ func init() { b.Handle(tb.OnText, Handler) logs.Info("监听telegram机器人") b.Start() + core.Pushs["qq"] = func(i int, s string) { + b.Send(&tb.User{ID: i}, s) + } } func (sender *Sender) GetContent() string {