Categorygithub.com/LainNetWork/ranni
modulepackage
0.0.9
Repository: https://github.com/lainnetwork/ranni.git
Documentation: pkg.go.dev

# README

ranni,一款简单的go-cqhttp的go sdk

实现了部分oneBot协议,支持主流消息类型,够用就行。jpg,其余类型绝赞摸鱼中!(可发issue,能接的我都会接)

特色功能

  • 大概也许可能较为方便的消息链处理api
  • 集成了corn表达式,支持定时任务(如推送消息等)
  • 实现了正向ws接收消息,以及http响应消息
  • 实现了一个对外消息API接口,可用于外部项目调用,主动推送消息

eg:

开始使用:

import (
	hd "handler"
	"github.com/LainNetWork/ranni" // 引入包
)

func main() {
  //注册消息处理器,可连续调用注册若干个
	ranni.Register(hd.DailyJapanese{})
  ranni.Register(hd.HolidayHandler{})
  //需要的话注册定时任务
	ranni.RegisterCron("0 9 * * *", hd.DailyNewsJob)
  //传入bot基本配置即可
	ranni.Start(&ranni.Config{
		WsAddr:        "", // ws地址
		CallBackAddr:  "", // 响应接口地址
		AccessToken:   "", // 鉴权token
		ApiAddr: ":8080"   // API接口端口
	})
}

一个handler例子

实现EventHandler接口即可

package handler

import (
	"fmt"
	engine "github.com/LainNetWork/ranni"
	"strings"
)

const code = "repeat "

type RepeatHandler struct {
}
// 功能帮助信息
func (RepeatHandler) Help() string {
	return "repeat 文字:朴实无华の复读机"
}
//处理消息
func (RepeatHandler) Do(ctx *engine.EventContext) {
	_, err := ctx.Send(engine.InitMsgChain(engine.TextMessage{Text: strings.TrimPrefix(ctx.MessageChain.String(), code)}))
	if err != nil {
		fmt.Println(err.Error())
	}
}
// 判断该消息是否能被本handler处理
func (RepeatHandler) Filter(ctx *engine.EventContext) bool {
	return strings.HasPrefix(ctx.MessageChain.String(), code)
}

# 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
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
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
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

# Structs

Anonymous 匿名.
ApiMessageVO 只支持Text、Image、At三种格式.
AtMessage At消息.
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
GroupMessageEvent 群聊消息事件.
ImageMessage 图片消息.
No description provided by the author
MessageChain 消息链.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PrivacyMessageEvent 私聊消息事件.
RecordMessage 语音消息.
No description provided by the author
No description provided by the author
No description provided by the author
Sender 发送者信息.
No description provided by the author
TextMessage 文本消息.
VideoMessage 视频消息.

# Interfaces

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