Git Product home page Git Product logo

mirai-go's Introduction

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开源许可证,使用时请遵守相关规则

mirai-go's People

Contributors

wangnengjie avatar

Stargazers

Ms avatar DizzyK avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.