Categorygithub.com/wangnengjie/mirai-go
modulepackage
0.2.0
Repository: https://github.com/wangnengjie/mirai-go.git
Documentation: pkg.go.dev

# README

mirai-go

基于mirai-api-http的golang sdk

项目目前仍在开发中,所有功能尚未经过测试且可能出现break change,非常不建议在生产环境中使用

只是个玩具啦

获取

go get github.com/wangnengjie/mirai-go

Quick Start

package main

import (
	"github.com/wangnengjie/mirai-go"
	"github.com/wangnengjie/mirai-go/model"
)

func main() {
	bot := mirai.NewBot(mirai.BotConfig{
		Host:      "127.0.0.1:8080",
		AuthKey:   "12345678",
		Id:        123456789,
		Websocket: true,
		RecvMode:  mirai.RecvAll,
		Debug:     true,
	})
	err := bot.Connect()
	if err != nil {
		bot.Log.Error(err)
	}
	bot.On(model.GroupMessage, repeat)
	bot.Loop()
}

func repeat(ctx *mirai.Context) { // 复读群消息
	m, _ := ctx.Message.(*model.GroupMsg)
	// 0 代表不回复消息,msgId是发出的消息的id
	// chain中第一位为source
	msgId, err := ctx.Bot.SendGroupMessage(m.Sender.Group.Id, m.MessageChain[1:], 0)
	// msgId 是刚刚发送的这条消息的id
	if err != nil {
		ctx.Bot.Log.Error(err)
	} else {
		ctx.Bot.Log.Info(msgId)
	}
}

Todos

  • 添加更多example
  • 添加更多调试信息(不清楚需要添加哪些,欢迎提建议)
  • 完善文档
  • 中间件功能
  • command接口
  • 测试
  • 性能优化?

go语言刚入门菜鸡,项目可能会出现各种问题,欢迎提issue

依赖

  • resty: Simple HTTP and REST client library for Go
  • websocket: A fast, well-tested and widely used WebSocket implementation for Go
  • jsoniter: A high-performance 100% compatible drop-in replacement of "encoding/json"
  • logrus: Structured, pluggable logging for Go
  • nested-logrus-formatter: Formatter for logrus

鸣谢

特别感谢mirai项目组mamoe

  • mirai:全开源 高效率 QQ机器人/Android QQ协议支持库 for JVM / Android
  • mirai-console:mirai 的高效率 QQ 机器人控制台
  • mirai-api-http:Mirai HTTP API (console) plugin

许可证

GNU AGPLv3,基于mirai的一系列项目均使用GNU AGPLv3开源许可证,使用时请遵守相关规则

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author