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
updatesTimeout time.Duration
catchTimeout time.Duration
DisablePatch bool
}
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) {
_, _ = SetLogVerbosityLevel(&SetLogVerbosityLevelRequest{
NewVerbosityLevel: level,
@ -184,7 +191,7 @@ func (client *Client) Send(req Request) (*Response, error) {
select {
case response := <-catcher:
if response.Type != "error" && req.Type == "sendMessage" {
if !client.DisablePatch && response.Type != "error" && req.Type == "sendMessage" {
m, err := UnmarshalMessage(response.Data)
if err != nil {
return nil, err