Allow disable sendMessage patch

This commit is contained in:
c0re100 2023-11-25 21:08:02 +08:00
parent 434963f2c9
commit 7563ce479c
No known key found for this signature in database
GPG key ID: 7C3B3004FE745AAF

View file

@ -21,6 +21,7 @@ type Client struct {
successMsgStore *sync.Map successMsgStore *sync.Map
updatesTimeout time.Duration updatesTimeout time.Duration
catchTimeout time.Duration catchTimeout time.Duration
DisablePatch bool
} }
type Option func(*Client) type Option func(*Client)
@ -43,6 +44,12 @@ func WithProxy(req *AddProxyRequest) Option {
} }
} }
func WithoutSendMessagePatch() Option {
return func(client *Client) {
client.DisablePatch = true
}
}
func SetLogLevel(level int32) { func SetLogLevel(level int32) {
_, _ = SetLogVerbosityLevel(&SetLogVerbosityLevelRequest{ _, _ = SetLogVerbosityLevel(&SetLogVerbosityLevelRequest{
NewVerbosityLevel: level, NewVerbosityLevel: level,
@ -184,7 +191,7 @@ func (client *Client) Send(req Request) (*Response, error) {
select { select {
case response := <-catcher: case response := <-catcher:
if response.Type != "error" && req.Type == "sendMessage" { if !client.DisablePatch && response.Type != "error" && req.Type == "sendMessage" {
m, err := UnmarshalMessage(response.Data) m, err := UnmarshalMessage(response.Data)
if err != nil { if err != nil {
return nil, err return nil, err