github.com/LagrangeDev/LagrangeGo@v0.0.0-20240512064304-ad4a85e10cb4/client/event/friend.go (about)

     1  package event
     2  
     3  import (
     4  	"github.com/LagrangeDev/LagrangeGo/client/packets/pb/message"
     5  )
     6  
     7  type (
     8  	FriendRequest struct {
     9  		SourceUin uint32
    10  		SourceUid string
    11  		Msg       string
    12  		Source    string
    13  	}
    14  
    15  	FriendRecall struct {
    16  		FromUid  string
    17  		Sequence uint64
    18  		Time     uint32
    19  		Random   uint32
    20  	}
    21  
    22  	Rename struct {
    23  		SubType  uint32 // self 0 friend 1
    24  		Uin      uint32
    25  		Nickname string
    26  	}
    27  )
    28  
    29  func ParseFriendRequestNotice(event *message.FriendRequest, msg *message.PushMsg) *FriendRequest {
    30  	info := event.Info
    31  	return &FriendRequest{
    32  		SourceUin: msg.Message.ResponseHead.FromUin,
    33  		SourceUid: info.SourceUid,
    34  		Msg:       info.Message,
    35  		Source:    info.Source,
    36  	}
    37  }
    38  
    39  func ParseFriendRecallEvent(event *message.FriendRecall) *FriendRecall {
    40  	info := event.Info
    41  	return &FriendRecall{
    42  		FromUid:  info.FromUid,
    43  		Sequence: uint64(info.Sequence),
    44  		Time:     info.Time,
    45  		Random:   info.Random,
    46  	}
    47  }
    48  
    49  func ParseFriendRenameEvent(event *message.FriendRenameMsg, uin uint32) *Rename {
    50  	return &Rename{
    51  		SubType:  1,
    52  		Uin:      uin,
    53  		Nickname: event.Body.Data.RenameData.NickName,
    54  	}
    55  }