Skip to content

Commit

Permalink
✏️ 变更项目名
Browse files Browse the repository at this point in the history
  • Loading branch information
kanrichan committed Oct 17, 2023
1 parent 2030bb2 commit d356cb8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# zerobot-adapter-satori
# satori-go
[satori](https://satori.js.org/zh-CN/) protocol in golang

## Usage
```go
client := NewClient("12345678", "i am token")

client.Listen(func(event *Event) {
fmt.Println(event)
})

client.CreateMessage("87654321", "hello world!")
```

## Thanks
- [chronocat](https://github.com/chrononeko/chronocat) - 神秘猫猫
- [zerobot](https://github.com/wdvxdr1123/ZeroBot) - 一个基于onebot协议的机器人Go开发框架
2 changes: 0 additions & 2 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"net/http"
)

type GuildList List[Channel]

func (cli *Client) call(endpoint string, request any, response any) (err error) {
var buf *bytes.Buffer
if request != nil {
Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Client struct {

// NewClient 创建一个 satori 客户端.
func NewClient(api, token string) *Client {
return &Client{api: api, token: token}
return &Client{api: api, token: token, cancel: make(chan bool)}
}

// Platform 获取当前 satori platform.
Expand Down
4 changes: 2 additions & 2 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (cli *Client) connect() {
break
ERROR:
log.Warnf("failed to connect to satori: %s %v", cli.api, err)
time.Sleep(5 * time.Second) // 等待两秒后重新连接
time.Sleep(5 * time.Second)
}
}

Expand All @@ -79,7 +79,7 @@ func (cli *Client) Listen(handler func(*Event)) {
if err != nil { // reconnect
log.Warnf("lost connection to satori: %s %v", cli.api, err)
cli.cancel <- true
time.Sleep(time.Millisecond * time.Duration(3))
time.Sleep(time.Second * time.Duration(2))
cli.connect()
continue
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/kanrichan/zerobot-adapter-satori
module github.com/kanrichan/satori-go

go 1.19

Expand Down

0 comments on commit d356cb8

Please sign in to comment.