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 {