Skip to content

Commit

Permalink
mod:测试发送合并消息
Browse files Browse the repository at this point in the history
  • Loading branch information
dezhishen committed Jul 16, 2022
1 parent ef9faa6 commit f2d7645
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 50 deletions.
4 changes: 2 additions & 2 deletions configs/bot.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
http:
schema: "http"
host: 192.168.31.6
host: 192.168.31.169
port: 5700
websocket:
host: 192.168.31.6
host: 192.168.31.169
port: 6700
SUPERUSERS:
- 1179551960
1 change: 0 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# examples

示例文件
21 changes: 21 additions & 0 deletions examples/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

#export CGO_ENABLED=1

export GOARCH=amd64
export GOOS=windows
go build -o ./plugin/impl/plugin-windows-amd64.exe ../plugin/impl

export GOARM=7
export GOARCH=arm64
export GOOS=linux

go build -o ./plugin/impl/plugin-linux-arm64v7 ../plugin/impl

export GOARCH=amd64
export GOOS=darwin
go build -o ./plugin/impl/plugin-linux-amd64 ../plugin/impl


export GOARCH=amd64
export GOOS=linux
go build -o ./plugin/impl/plugin-linux-amd64 ../plugin/impl
65 changes: 18 additions & 47 deletions examples/plugin/impl/impl.go
Original file line number Diff line number Diff line change
@@ -1,67 +1,38 @@
package main

import (
"time"

"github.com/dezhishen/onebot-plus/pkg/cli"
"github.com/dezhishen/onebot-plus/pkg/plugin"
"github.com/sirupsen/logrus"
"github.com/dezhishen/onebot-sdk/pkg/model"
)

func main() {
plugin.NewOnebotEventPluginBuilder().
//设置插件内容
Id("test").Name("测试插件").Description("这是测试插件").
Help("测试查询,无操作指令").
//设置生命周期函数
// Init(func(cli cli.OnebotCli) error {
// d, e := cli.GetVersionInfo()
// logrus.Info("============ version info ==========")
// logrus.Info(d, e)
// // go loop(cli)
// return nil
// }).
// BeforeExit(func(cli cli.OnebotCli) error {
// d, e := cli.GetVersionInfo()
// logrus.Info("========exit=======")
// logrus.Info(d, e)
// return nil
// }).
// //Onebot回调事件
// MessageGroup(func(req *model.EventMessageGroup, cli cli.OnebotCli) error {
// logrus.Infof("收到群组消息,UserId:[%v]", req.Sender.UserId)
// return nil
// }).
// MessagePrivate(func(req *model.EventMessagePrivate, cli cli.OnebotCli) error {
// logrus.Infof("收到私聊消息,UserId:[%v]", req.Sender.UserId)
// return nil
// }).
// MetaHeartbeat(func(req *model.EventMetaHeartbeat, cli cli.OnebotCli) error {
// logrus.Infof("收到EventMetaHeartbeat,SelfId:[%v]", req.SelfId)
// logrus.Info(cli.GetStatus())
// return nil

// }).
// MetaLifecycle(func(req *model.EventMetaLifecycle, cli cli.OnebotCli) error {
// logrus.Info("============status==========")
// logrus.Info(cli.GetStatus())
// return nil
// }).
Init(func(cli cli.OnebotCli) error {
sendGroupForwardMessage(cli)
return nil
}).
//构建插件
Build().
//启动
Start()
}

func loop(cli cli.OnebotCli) {
for {
time.Sleep(5 * time.Second)
logrus.Info("===============alive==============")
r, e := cli.GetStatus()
if e != nil {
logrus.Error("get status err :%v", e)
continue
}
logrus.Infof("Status:%v", r.Data)
func sendGroupForwardMessage(cli cli.OnebotCli) {
r, e := cli.GetLoginInfo()
if e != nil {
println(e)
return
}
cli.SendGroupForwardMessageByRawMsg(398415189, r.Data.UserId, r.Data.Nickname, []*model.MessageSegment{
{
Type: "text",
Data: &model.MessageElementText{
Text: "hello,我是合并消息",
},
},
})
}

0 comments on commit f2d7645

Please sign in to comment.