github.com/LagrangeDev/LagrangeGo@v0.0.0-20240512064304-ad4a85e10cb4/client/internal/network/packet.go (about)

     1  package network
     2  
     3  // from https://github.com/Mrs4s/MiraiGo/blob/master/client/internal/network/packet.go
     4  
     5  type Packet struct {
     6  	SequenceId  uint32
     7  	CommandName string
     8  	Payload     []byte
     9  	Params      RequestParams
    10  }
    11  
    12  type RequestParams map[string]any
    13  
    14  func (p RequestParams) Bool(k string) bool {
    15  	if p == nil {
    16  		return false
    17  	}
    18  	i, ok := p[k]
    19  	if !ok {
    20  		return false
    21  	}
    22  	return i.(bool)
    23  }
    24  
    25  func (p RequestParams) Int32(k string) int32 {
    26  	if p == nil {
    27  		return 0
    28  	}
    29  	i, ok := p[k]
    30  	if !ok {
    31  		return 0
    32  	}
    33  	return i.(int32)
    34  }