onebot协议机器人库(已停止开发)
-
send_private_msg
-
send_group_msg
-
Text
-
Face
-
Image
-
Record
-
Video
-
At
-
Reply
-
message
服务端实现推荐使用 go-cqhttp
,使用HTTP/HTTP POST方式连接
package main
import (
"errors"
"fmt"
"github.com/kzw200015/onebot-go"
"github.com/sirupsen/logrus"
)
func main() {
bot := onebot.New(onebot.BotConfig{
SelfId: 12345678, //QQ号
ApiConfig: onebot.ApiConfig{ //与HTTP API配置要一致
Token: "token", //API token
Address: "http://localhost:5700", //API地址
},
ServerConfig: onebot.ServerConfig{ //与HTTP POST配置要一致
Secret: "secret", //验证用secret
Address: ":8080", //监听地址
Path: "/event", //监听Path
},
})
bot.OnPrivateMessage("", func(bot *onebot.Bot, event onebot.Event) {
bot.SendPrivateMsg(event.UserId, onebot.MessageBuilder().Text("hello").Text("world").Build()...)
})
bot.Start()
}