Skip to content

Commit fba9c35

Browse files
authored
remove serializer from bot (eatmoreapple#538)
1 parent 26b8262 commit fba9c35

File tree

2 files changed

+6
-32
lines changed

2 files changed

+6
-32
lines changed

bot.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package openwechat
22

33
import (
44
"context"
5+
"encoding/json"
56
"errors"
67
"io"
78
"log"
@@ -18,7 +19,6 @@ type Bot struct {
1819
SyncCheckCallback func(resp SyncCheckResponse) // 心跳回调
1920
MessageHandler MessageHandler // 获取消息成功的handle
2021
MessageErrorHandler MessageErrorHandler // 获取消息发生错误的handle, 返回err == nil 则尝试继续监听
21-
Serializer Serializer // 序列化器, 默认为json
2222
Caller *Caller
2323
Storage *Session
2424
err error
@@ -318,7 +318,7 @@ func (b *Bot) DumpTo(writer io.Writer) error {
318318
SyncKey: b.Storage.Response.SyncKey,
319319
UUID: b.uuid,
320320
}
321-
return b.Serializer.Encode(writer, item)
321+
return json.NewEncoder(writer).Encode(item)
322322
}
323323

324324
// IsHot returns true if is hot login otherwise false
@@ -344,11 +344,10 @@ func NewBot(c context.Context) *Bot {
344344
caller.Client.SetMode(normal)
345345
ctx, cancel := context.WithCancel(c)
346346
return &Bot{
347-
Caller: caller,
348-
Storage: &Session{},
349-
Serializer: &JsonSerializer{},
350-
context: ctx,
351-
cancel: cancel,
347+
Caller: caller,
348+
Storage: &Session{},
349+
context: ctx,
350+
cancel: cancel,
352351
}
353352
}
354353

serializer.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)