-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |