Skip to content

Commit 881b573

Browse files
authored
Merge pull request #12 from dchaofei/master
升级[email protected]
2 parents 5f65b08 + 44e2431 commit 881b573

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import (
2626
)
2727

2828
func main() {
29-
_ = wechaty.NewWechaty().
30-
OnScan(func(qrCode string, status schemas.ScanStatus, data string) {
31-
fmt.Printf("Scan QR Code to login: %s\nhttps://wechaty.github.io/qrcode/%s\n", status, qrCode)
32-
}).
33-
OnLogin(user *user.ContactSelf) { fmt.Printf("User %s logined\n", user) }).
34-
OnMessage(message *user.Message) { fmt.Printf("Message: %s\n", message) }).
35-
Start()
29+
_ = wechaty.NewWechaty().
30+
OnScan(func(ctx *wechaty.Context, qrCode string, status schemas.ScanStatus, data string) {
31+
fmt.Printf("Scan QR Code to login: %s\nhttps://wechaty.github.io/qrcode/%s\n", status, qrCode)
32+
}).
33+
OnLogin(func(ctx *wechaty.Context, user *user.ContactSelf) { fmt.Printf("User %s logined\n", user) }).
34+
OnMessage(func(ctx *wechaty.Context, message *user.Message) { fmt.Printf("Message: %s\n", message) }).
35+
Start()
3636
}
3737
```
3838

@@ -51,7 +51,7 @@ make install
5151
Get a Token for your Bot first. Learn more from our [Wechaty Developers Program](https://github.com/wechaty/wechaty/wiki/Wechaty-Developer-Program)
5252

5353
```sh
54-
export WECHATY_PUPPET_HOSTIE_TOKEN=your_token_at_here
54+
export WECHATY_PUPPET_SERVICE_TOKEN=your_token_at_here
5555

5656
make bot
5757
```

examples/ding-dong-bot.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ import (
3333
func main() {
3434
var bot = wechaty.NewWechaty()
3535

36-
bot.OnScan(func(qrCode string, status schemas.ScanStatus, data string) {
36+
bot.OnScan(func(ctx *wechaty.Context, qrCode string, status schemas.ScanStatus, data string) {
3737
fmt.Printf("Scan QR Code to login: %v\nhttps://wechaty.js.org/qrcode/%s\n", status, qrCode)
38-
}).OnLogin(func(user *user.ContactSelf) {
38+
}).OnLogin(func(ctx *wechaty.Context, user *user.ContactSelf) {
3939
fmt.Printf("User %s logined\n", user.Name())
40-
}).OnMessage(onMessage).OnLogout(func(user *user.ContactSelf, reason string) {
40+
}).OnMessage(onMessage).OnLogout(func(ctx *wechaty.Context, user *user.ContactSelf, reason string) {
4141
fmt.Printf("User %s logouted: %s\n", user, reason)
4242
})
4343

@@ -55,7 +55,7 @@ func main() {
5555
}
5656
}
5757

58-
func onMessage(message *user.Message) {
58+
func onMessage(ctx *wechaty.Context, message *user.Message) {
5959
log.Println(message)
6060

6161
if message.Self() {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/wechaty/go-wechaty-getting-started
33
go 1.14
44

55
require (
6-
github.com/wechaty/go-wechaty v0.1.2
6+
github.com/wechaty/go-wechaty v0.3.0
77
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
88
golang.org/x/tools v0.1.0 // indirect
99
)

0 commit comments

Comments
 (0)