mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
support friend poke
This commit is contained in:
parent
5e9e9b843b
commit
bf90674375
@ -776,6 +776,22 @@ func decodeOnlinePushReqPacket(c *QQClient, seq uint16, payload []byte) (interfa
|
||||
c.dispatchLeaveGroupEvent(&GroupLeaveEvent{Group: g})
|
||||
}
|
||||
groupLeaveLock.Unlock()
|
||||
case 290:
|
||||
t := ¬ify.GeneralGrayTipInfo{}
|
||||
_ = proto.Unmarshal(probuf, t)
|
||||
var sender int64
|
||||
for _, templ := range t.MsgTemplParam {
|
||||
if templ.Name == "uin_str1" {
|
||||
sender, _ = strconv.ParseInt(templ.Value, 10, 64)
|
||||
}
|
||||
}
|
||||
if sender == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
c.dispatchFriendNotifyEvent(&FriendPokeNotifyEvent{
|
||||
Sender: sender,
|
||||
Receiver: c.Uin,
|
||||
})
|
||||
case 0x44:
|
||||
s44 := pb.Sub44{}
|
||||
if err := proto.Unmarshal(probuf, &s44); err != nil {
|
||||
|
@ -44,7 +44,6 @@ type (
|
||||
Nickname string
|
||||
Remark string
|
||||
FaceId int16
|
||||
|
||||
//msgSeqList *utils.Cache
|
||||
}
|
||||
|
||||
@ -130,7 +129,7 @@ type (
|
||||
Member *GroupMemberInfo
|
||||
}
|
||||
|
||||
IGroupNotifyEvent interface {
|
||||
INotifyEvent interface {
|
||||
From() int64
|
||||
Content() string
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ type eventHandlers struct {
|
||||
disconnectHandlers []func(*QQClient, *ClientDisconnectedEvent)
|
||||
logHandlers []func(*QQClient, *LogEvent)
|
||||
serverUpdatedHandlers []func(*QQClient, *ServerUpdatedEvent) bool
|
||||
notifyHandlers []func(*QQClient, IGroupNotifyEvent)
|
||||
groupNotifyHandlers []func(*QQClient, INotifyEvent)
|
||||
friendNotifyHandlers []func(*QQClient, INotifyEvent)
|
||||
offlineFileHandlers []func(*QQClient, *OfflineFileEvent)
|
||||
groupMessageReceiptHandlers sync.Map
|
||||
}
|
||||
@ -119,8 +120,12 @@ func (c *QQClient) OnLog(f func(*QQClient, *LogEvent)) {
|
||||
c.eventHandlers.logHandlers = append(c.eventHandlers.logHandlers, f)
|
||||
}
|
||||
|
||||
func (c *QQClient) OnGroupNotify(f func(*QQClient, IGroupNotifyEvent)) {
|
||||
c.eventHandlers.notifyHandlers = append(c.eventHandlers.notifyHandlers, f)
|
||||
func (c *QQClient) OnGroupNotify(f func(*QQClient, INotifyEvent)) {
|
||||
c.eventHandlers.groupNotifyHandlers = append(c.eventHandlers.groupNotifyHandlers, f)
|
||||
}
|
||||
|
||||
func (c *QQClient) OnFriendNotify(f func(*QQClient, INotifyEvent)) {
|
||||
c.eventHandlers.friendNotifyHandlers = append(c.eventHandlers.friendNotifyHandlers, f)
|
||||
}
|
||||
|
||||
func NewUinFilterPrivate(uin int64) func(*message.PrivateMessage) bool {
|
||||
@ -320,11 +325,22 @@ func (c *QQClient) dispatchNewFriendEvent(e *NewFriendEvent) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *QQClient) dispatchGroupNotifyEvent(e IGroupNotifyEvent) {
|
||||
func (c *QQClient) dispatchGroupNotifyEvent(e INotifyEvent) {
|
||||
if e == nil {
|
||||
return
|
||||
}
|
||||
for _, f := range c.eventHandlers.notifyHandlers {
|
||||
for _, f := range c.eventHandlers.groupNotifyHandlers {
|
||||
cover(func() {
|
||||
f(c, e)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (c *QQClient) dispatchFriendNotifyEvent(e INotifyEvent) {
|
||||
if e == nil {
|
||||
return
|
||||
}
|
||||
for _, f := range c.eventHandlers.friendNotifyHandlers {
|
||||
cover(func() {
|
||||
f(c, e)
|
||||
})
|
||||
|
@ -28,6 +28,12 @@ type (
|
||||
Uin int64
|
||||
Nick string
|
||||
}
|
||||
|
||||
// FriendPokeNotifyEvent 好友戳一戳提示事件
|
||||
FriendPokeNotifyEvent struct {
|
||||
Sender int64
|
||||
Receiver int64
|
||||
}
|
||||
)
|
||||
|
||||
// grayTipProcessor 提取出来专门用于处理群内 notify tips
|
||||
@ -88,6 +94,14 @@ func (e *GroupPokeNotifyEvent) Content() string {
|
||||
return fmt.Sprintf("%d戳了戳%d", e.Sender, e.Receiver)
|
||||
}
|
||||
|
||||
func (e *FriendPokeNotifyEvent) From() int64 {
|
||||
return e.Sender
|
||||
}
|
||||
|
||||
func (e *FriendPokeNotifyEvent) Content() string {
|
||||
return fmt.Sprintf("%d戳了戳%d", e.Sender, e.Receiver)
|
||||
}
|
||||
|
||||
func (e *GroupRedBagLuckyKingNotifyEvent) From() int64 {
|
||||
return e.GroupCode
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user