+2
-2
@@ -30,7 +30,7 @@ func (n *Node) AttrGetter() *AttrUtility {
|
||||
}
|
||||
|
||||
func (au *AttrUtility) GetJID(key string, require bool) (jidVal types.JID, ok bool) {
|
||||
var val interface{}
|
||||
var val any
|
||||
if val, ok = au.Attrs[key]; !ok {
|
||||
if require {
|
||||
au.Errors = append(au.Errors, fmt.Errorf("didn't find required JID attribute '%s'", key))
|
||||
@@ -69,7 +69,7 @@ func (au *AttrUtility) JID(key string) types.JID {
|
||||
}
|
||||
|
||||
func (au *AttrUtility) GetString(key string, require bool) (strVal string, ok bool) {
|
||||
var val interface{}
|
||||
var val any
|
||||
if val, ok = au.Attrs[key]; !ok {
|
||||
if require {
|
||||
au.Errors = append(au.Errors, fmt.Errorf("didn't find required attribute '%s'", key))
|
||||
|
||||
+6
-6
@@ -165,7 +165,7 @@ func (r *binaryDecoder) readListSize(tag int) (int, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *binaryDecoder) read(string bool) (interface{}, error) {
|
||||
func (r *binaryDecoder) read(string bool) (any, error) {
|
||||
tagByte, err := r.readByte()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -222,7 +222,7 @@ func (r *binaryDecoder) read(string bool) (interface{}, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *binaryDecoder) readJIDPair() (interface{}, error) {
|
||||
func (r *binaryDecoder) readJIDPair() (any, error) {
|
||||
user, err := r.read(true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -238,7 +238,7 @@ func (r *binaryDecoder) readJIDPair() (interface{}, error) {
|
||||
return types.NewJID(user.(string), server.(string)), nil
|
||||
}
|
||||
|
||||
func (r *binaryDecoder) readInteropJID() (interface{}, error) {
|
||||
func (r *binaryDecoder) readInteropJID() (any, error) {
|
||||
user, err := r.read(true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -265,7 +265,7 @@ func (r *binaryDecoder) readInteropJID() (interface{}, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *binaryDecoder) readFBJID() (interface{}, error) {
|
||||
func (r *binaryDecoder) readFBJID() (any, error) {
|
||||
user, err := r.read(true)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -287,7 +287,7 @@ func (r *binaryDecoder) readFBJID() (interface{}, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *binaryDecoder) readADJID() (interface{}, error) {
|
||||
func (r *binaryDecoder) readADJID() (any, error) {
|
||||
agent, err := r.readByte()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -383,7 +383,7 @@ func (r *binaryDecoder) readNode() (*Node, error) {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func (r *binaryDecoder) readBytesOrString(length int, asString bool) (interface{}, error) {
|
||||
func (r *binaryDecoder) readBytesOrString(length int, asString bool) (any, error) {
|
||||
data, err := r.readRaw(length)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
+1
-1
@@ -98,7 +98,7 @@ func (w *binaryEncoder) writeNode(n Node) {
|
||||
}
|
||||
}
|
||||
|
||||
func (w *binaryEncoder) write(data interface{}) {
|
||||
func (w *binaryEncoder) write(data any) {
|
||||
switch typedData := data.(type) {
|
||||
case nil:
|
||||
w.pushByte(token.ListEmpty)
|
||||
|
||||
+3
-3
@@ -19,9 +19,9 @@ type Attrs = map[string]any
|
||||
|
||||
// Node represents an XML element.
|
||||
type Node struct {
|
||||
Tag string // The tag of the element.
|
||||
Attrs Attrs // The attributes of the element.
|
||||
Content interface{} // The content inside the element. Can be nil, a list of Nodes, or a byte array.
|
||||
Tag string // The tag of the element.
|
||||
Attrs Attrs // The attributes of the element.
|
||||
Content any // The content inside the element. Can be nil, a list of Nodes, or a byte array.
|
||||
}
|
||||
|
||||
type marshalableNode struct {
|
||||
|
||||
@@ -736,7 +736,7 @@ func (cli *Client) Logout(ctx context.Context) error {
|
||||
// All registered event handlers will receive all events. You should use a type switch statement to
|
||||
// filter the events you want:
|
||||
//
|
||||
// func myEventHandler(evt interface{}) {
|
||||
// func myEventHandler(evt any) {
|
||||
// switch v := evt.(type) {
|
||||
// case *events.Message:
|
||||
// fmt.Println("Received a message!")
|
||||
@@ -757,7 +757,7 @@ func (cli *Client) Logout(ctx context.Context) error {
|
||||
// mycli.eventHandlerID = mycli.WAClient.AddEventHandler(mycli.myEventHandler)
|
||||
// }
|
||||
//
|
||||
// func (mycli *MyClient) myEventHandler(evt interface{}) {
|
||||
// func (mycli *MyClient) myEventHandler(evt any) {
|
||||
// // Handle event and access mycli.WAClient
|
||||
// }
|
||||
func (cli *Client) AddEventHandler(handler EventHandler) uint32 {
|
||||
@@ -782,7 +782,7 @@ func (cli *Client) AddEventHandlerWithSuccessStatus(handler EventHandlerWithSucc
|
||||
// event dispatcher holds a read lock on the event handler list, and this method wants a write lock
|
||||
// on the same list. Instead run it in a goroutine:
|
||||
//
|
||||
// func (mycli *MyClient) myEventHandler(evt interface{}) {
|
||||
// func (mycli *MyClient) myEventHandler(evt any) {
|
||||
// if noLongerWantEvents {
|
||||
// go mycli.WAClient.RemoveEventHandler(mycli.eventHandlerID)
|
||||
// }
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import (
|
||||
waLog "go.mau.fi/whatsmeow/util/log"
|
||||
)
|
||||
|
||||
func eventHandler(evt interface{}) {
|
||||
func eventHandler(evt any) {
|
||||
switch v := evt.(type) {
|
||||
case *events.Message:
|
||||
fmt.Println("Received a message!", v.Message.GetConversation())
|
||||
|
||||
@@ -290,7 +290,7 @@ func (cli *Client) UpdateGroupRequestParticipants(ctx context.Context, jid types
|
||||
// The avatar should be a JPEG photo, other formats may be rejected with ErrInvalidImageFormat.
|
||||
// The bytes can be nil to remove the photo. Returns the new picture ID.
|
||||
func (cli *Client) SetGroupPhoto(ctx context.Context, jid types.JID, avatar []byte) (string, error) {
|
||||
var content interface{}
|
||||
var content any
|
||||
if avatar != nil {
|
||||
content = []waBinary.Node{{
|
||||
Tag: "picture",
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ func encryptMediaRetryReceipt(messageID types.MessageID, mediaKey []byte) (ciphe
|
||||
// using DecryptMediaRetryNotification and the same media key passed here. If the media retry was successful,
|
||||
// the decrypted notification should contain an updated DirectPath, which can be used to download the file.
|
||||
//
|
||||
// func eventHandler(rawEvt interface{}) {
|
||||
// func eventHandler(rawEvt any) {
|
||||
// switch evt := rawEvt.(type) {
|
||||
// case *events.MediaRetry:
|
||||
// imageMsg := mediaRetryCache[evt.MessageID]
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ type infoQuery struct {
|
||||
Target types.JID
|
||||
ID string
|
||||
SMaxID string
|
||||
Content interface{}
|
||||
Content any
|
||||
|
||||
Timeout time.Duration
|
||||
NoRetry bool
|
||||
|
||||
+1
-1
@@ -248,7 +248,7 @@ func (jid JID) IsEmpty() bool {
|
||||
var _ sql.Scanner = (*JID)(nil)
|
||||
|
||||
// Scan scans the given SQL value into this JID.
|
||||
func (jid *JID) Scan(src interface{}) error {
|
||||
func (jid *JID) Scan(src any) error {
|
||||
if src == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
+14
-14
@@ -15,20 +15,20 @@ import (
|
||||
|
||||
// Logger is a simple logger interface that can have subloggers for specific areas.
|
||||
type Logger interface {
|
||||
Warnf(msg string, args ...interface{})
|
||||
Errorf(msg string, args ...interface{})
|
||||
Infof(msg string, args ...interface{})
|
||||
Debugf(msg string, args ...interface{})
|
||||
Warnf(msg string, args ...any)
|
||||
Errorf(msg string, args ...any)
|
||||
Infof(msg string, args ...any)
|
||||
Debugf(msg string, args ...any)
|
||||
Sub(module string) Logger
|
||||
}
|
||||
|
||||
type noopLogger struct{}
|
||||
|
||||
func (n *noopLogger) Errorf(_ string, _ ...interface{}) {}
|
||||
func (n *noopLogger) Warnf(_ string, _ ...interface{}) {}
|
||||
func (n *noopLogger) Infof(_ string, _ ...interface{}) {}
|
||||
func (n *noopLogger) Debugf(_ string, _ ...interface{}) {}
|
||||
func (n *noopLogger) Sub(_ string) Logger { return n }
|
||||
func (n *noopLogger) Errorf(_ string, _ ...any) {}
|
||||
func (n *noopLogger) Warnf(_ string, _ ...any) {}
|
||||
func (n *noopLogger) Infof(_ string, _ ...any) {}
|
||||
func (n *noopLogger) Debugf(_ string, _ ...any) {}
|
||||
func (n *noopLogger) Sub(_ string) Logger { return n }
|
||||
|
||||
// Noop is a no-op Logger implementation that silently drops everything.
|
||||
var Noop Logger = &noopLogger{}
|
||||
@@ -53,7 +53,7 @@ var levelToInt = map[string]int{
|
||||
"ERROR": 3,
|
||||
}
|
||||
|
||||
func (s *stdoutLogger) outputf(level, msg string, args ...interface{}) {
|
||||
func (s *stdoutLogger) outputf(level, msg string, args ...any) {
|
||||
if levelToInt[level] < s.min {
|
||||
return
|
||||
}
|
||||
@@ -65,10 +65,10 @@ func (s *stdoutLogger) outputf(level, msg string, args ...interface{}) {
|
||||
fmt.Printf("%s%s [%s %s] %s%s\n", time.Now().Format("15:04:05.000"), colorStart, s.mod, level, fmt.Sprintf(msg, args...), colorReset)
|
||||
}
|
||||
|
||||
func (s *stdoutLogger) Errorf(msg string, args ...interface{}) { s.outputf("ERROR", msg, args...) }
|
||||
func (s *stdoutLogger) Warnf(msg string, args ...interface{}) { s.outputf("WARN", msg, args...) }
|
||||
func (s *stdoutLogger) Infof(msg string, args ...interface{}) { s.outputf("INFO", msg, args...) }
|
||||
func (s *stdoutLogger) Debugf(msg string, args ...interface{}) { s.outputf("DEBUG", msg, args...) }
|
||||
func (s *stdoutLogger) Errorf(msg string, args ...any) { s.outputf("ERROR", msg, args...) }
|
||||
func (s *stdoutLogger) Warnf(msg string, args ...any) { s.outputf("WARN", msg, args...) }
|
||||
func (s *stdoutLogger) Infof(msg string, args ...any) { s.outputf("INFO", msg, args...) }
|
||||
func (s *stdoutLogger) Debugf(msg string, args ...any) { s.outputf("DEBUG", msg, args...) }
|
||||
func (s *stdoutLogger) Sub(mod string) Logger {
|
||||
return &stdoutLogger{mod: fmt.Sprintf("%s/%s", s.mod, mod), color: s.color, min: s.min}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user