Skip to content

Commit

Permalink
docs: 📝 add readme doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Aimerny committed Jul 10, 2024
1 parent 80cf541 commit 271a2c7
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[简体中文](README_ZH.md) | English
# KookGo

A kook robot development sdk based on websocket protocol

## QuickStart

### Import module

```shell
go get github.com/aimerny/kook-go
```

### Simple Implement
```go
func main() {

common.InitLogger()
globalSession, err := session.CreateSession("你的KookToken", true)
if err != nil {
log.Errorf("%s", err)
}
globalSession.RegisterEventHandler(&MyEventHandler{})
globalSession.Start()
}

type MyEventHandler struct {
event.BaseEventHandler
}

// DoKMarkDown 一个简单的Kook机器人实现,接受到新消息时会发送回对应频道/私聊
func (h *MyEventHandler) DoKMarkDown(event *model.Event) {
content := event.Content
log.Infof("event:%v", event)
extra := event.GetUserExtra()
if extra.Author.Bot {
log.Warnf("Bot message, skip")
return
}
req := &model.MessageCreateReq{
Type: 9,
Content: "Repeat by kook bot:" + content,
TargetId: event.TargetId,
}
action.MessageSend(req)
}
```

## [CHANGELOG](./app/CHANGELOG.md)
51 changes: 51 additions & 0 deletions README_ZH.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
简体中文 | [English](README_ZH.md)
# KookGo


基于websocket协议的kook机器人开发sdk

## 快速启动

### 导入模块

```shell
go get github.com/aimerny/kook-go
```

### 简单实现

```go
func main() {

common.InitLogger()
globalSession, err := session.CreateSession("你的KookToken", true)
if err != nil {
log.Errorf("%s", err)
}
globalSession.RegisterEventHandler(&MyEventHandler{})
globalSession.Start()
}

type MyEventHandler struct {
event.BaseEventHandler
}

// DoKMarkDown 一个简单的Kook机器人实现,接受到新消息时会发送回对应频道/私聊
func (h *MyEventHandler) DoKMarkDown(event *model.Event) {
content := event.Content
log.Infof("event:%v", event)
extra := event.GetUserExtra()
if extra.Author.Bot {
log.Warnf("Bot message, skip")
return
}
req := &model.MessageCreateReq{
Type: 9,
Content: "Repeat by kook bot:" + content,
TargetId: event.TargetId,
}
action.MessageSend(req)
}
```

### [CHANGELOG](./app/CHANGELOG.md)

0 comments on commit 271a2c7

Please sign in to comment.