modulepackage
0.0.0-20240530161035-7805c1b7056b
Repository: https://github.com/2mf8/gonebot.git
Documentation: pkg.go.dev
# README
GoneBot
使用方法
package main
import (
"fmt"
"github.com/2mf8/GoneBot"
"github.com/2mf8/GoneBot/onebot"
"github.com/gin-gonic/gin"
)
func main() {
gonebot.HandleConnect = func(bot *gonebot.Bot) {
fmt.Printf("新机器人已连接:%d\n", bot.BotId)
fmt.Println("所有机器人列表:")
for botId, _ := range gonebot.Bots {
println(botId)
}
}
gonebot.HandleGroupMessage = func(bot *gonebot.Bot, event *onebot.GroupMsgEvent) {
rawMsg := event.RawMessage
groupId := event.GroupId
userId := event.UserId
display := event.Sender.Card
replyMsg := gonebot.NewMsg().Text("hello world").At(userId, display).Text("你发送了:" + rawMsg)
_, _ = bot.SendGroupMessage(groupId, replyMsg, false)
}
router := gin.Default()
router.GET("/", func(c *gin.Context) {
if err := gonebot.UpgradeWebsocket(c.Writer, c.Request); err != nil {
fmt.Println("创建机器人失败")
}
})
if err := router.Run(":8081"); err != nil {
panic(err)
}
select {}
}
# Functions
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
HandleConnect 机器人连接.
HandleDisconnect 机器人断开.
HandleFriendAddNotice 新好友添加.
HandleFriendRecallNotice 好友消息撤回.
HandleFriendRequest 收到好友请求.
HandleGroupAdminNotice 群管理员变动.
HandleGroupBanNotice 有人被禁言.
HandleGroupDecreaseNotice 群人数减少 有人退群或被踢.
HandleGroupIncreaseNotice 群人数增加.
No description provided by the author
HandleGroupNotify 收到群通知.
HandleGroupMessage 收到群聊消息.
No description provided by the author
HandleGroupRecallNotice 群消息撤回.
HandleGroupRequest 收到加群请求.
HandleGroupUploadNotice 有人上传群文件.
HandleHeartBeat 收到机器人心跳.
HandleLifeTime 收到生命周期.
HandlePrivateMessage 收到私聊消息.
# Structs
No description provided by the author
No description provided by the author
safe websocket.
No description provided by the author