1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 19:17:38 +08:00

Merge pull request #65 from wdvxdr1123/master

support friend poke
This commit is contained in:
Mrs4s 2020-11-14 18:56:00 +08:00 committed by GitHub
commit 231b2d89db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 74 additions and 7 deletions

View File

@ -1019,6 +1019,24 @@ func (c *QQClient) buildGroupPokePacket(groupCode, target int64) (uint16, []byte
return seq, packet return seq, packet
} }
// OidbSvc.0xed3
func (c *QQClient) buildFriendPokePacket(target int64) (uint16, []byte) {
seq := c.nextSeq()
body := &oidb.DED3ReqBody{
ToUin: target,
AioUin: target,
}
b, _ := proto.Marshal(body)
req := &oidb.OIDBSSOPkg{
Command: 3795,
ServiceType: 1,
Bodybuffer: b,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0xed3", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
// OidbSvc.0x55c_1 // OidbSvc.0x55c_1
func (c *QQClient) buildGroupAdminSetPacket(groupCode, member int64, flag bool) (uint16, []byte) { func (c *QQClient) buildGroupAdminSetPacket(groupCode, member int64, flag bool) (uint16, []byte) {
seq := c.nextSeq() seq := c.nextSeq()

View File

@ -618,6 +618,10 @@ func (c *QQClient) sendGroupPoke(groupCode, target int64) {
_, _ = c.sendAndWait(c.buildGroupPokePacket(groupCode, target)) _, _ = c.sendAndWait(c.buildGroupPokePacket(groupCode, target))
} }
func (c *QQClient) SendFriendPoke(target int64) {
_, _ = c.sendAndWait(c.buildFriendPokePacket(target))
}
func (c *QQClient) UploadGroupImage(groupCode int64, img []byte) (*message.GroupImageElement, error) { func (c *QQClient) UploadGroupImage(groupCode int64, img []byte) (*message.GroupImageElement, error) {
h := md5.Sum(img) h := md5.Sum(img)
seq, pkt := c.buildGroupImageStorePacket(groupCode, h[:], int32(len(img))) seq, pkt := c.buildGroupImageStorePacket(groupCode, h[:], int32(len(img)))

View File

@ -776,6 +776,22 @@ func decodeOnlinePushReqPacket(c *QQClient, seq uint16, payload []byte) (interfa
c.dispatchLeaveGroupEvent(&GroupLeaveEvent{Group: g}) c.dispatchLeaveGroupEvent(&GroupLeaveEvent{Group: g})
} }
groupLeaveLock.Unlock() groupLeaveLock.Unlock()
case 290:
t := &notify.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: case 0x44:
s44 := pb.Sub44{} s44 := pb.Sub44{}
if err := proto.Unmarshal(probuf, &s44); err != nil { if err := proto.Unmarshal(probuf, &s44); err != nil {

View File

@ -44,7 +44,6 @@ type (
Nickname string Nickname string
Remark string Remark string
FaceId int16 FaceId int16
//msgSeqList *utils.Cache //msgSeqList *utils.Cache
} }
@ -130,7 +129,7 @@ type (
Member *GroupMemberInfo Member *GroupMemberInfo
} }
IGroupNotifyEvent interface { INotifyEvent interface {
From() int64 From() int64
Content() string Content() string
} }

View File

@ -26,7 +26,8 @@ type eventHandlers struct {
disconnectHandlers []func(*QQClient, *ClientDisconnectedEvent) disconnectHandlers []func(*QQClient, *ClientDisconnectedEvent)
logHandlers []func(*QQClient, *LogEvent) logHandlers []func(*QQClient, *LogEvent)
serverUpdatedHandlers []func(*QQClient, *ServerUpdatedEvent) bool serverUpdatedHandlers []func(*QQClient, *ServerUpdatedEvent) bool
notifyHandlers []func(*QQClient, IGroupNotifyEvent) groupNotifyHandlers []func(*QQClient, INotifyEvent)
friendNotifyHandlers []func(*QQClient, INotifyEvent)
offlineFileHandlers []func(*QQClient, *OfflineFileEvent) offlineFileHandlers []func(*QQClient, *OfflineFileEvent)
groupMessageReceiptHandlers sync.Map groupMessageReceiptHandlers sync.Map
} }
@ -119,8 +120,12 @@ func (c *QQClient) OnLog(f func(*QQClient, *LogEvent)) {
c.eventHandlers.logHandlers = append(c.eventHandlers.logHandlers, f) c.eventHandlers.logHandlers = append(c.eventHandlers.logHandlers, f)
} }
func (c *QQClient) OnGroupNotify(f func(*QQClient, IGroupNotifyEvent)) { func (c *QQClient) OnGroupNotify(f func(*QQClient, INotifyEvent)) {
c.eventHandlers.notifyHandlers = append(c.eventHandlers.notifyHandlers, f) 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 { 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 { if e == nil {
return 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() { cover(func() {
f(c, e) f(c, e)
}) })

View File

@ -28,6 +28,12 @@ type (
Uin int64 Uin int64
Nick string Nick string
} }
// FriendPokeNotifyEvent 好友戳一戳提示事件
FriendPokeNotifyEvent struct {
Sender int64
Receiver int64
}
) )
// grayTipProcessor 提取出来专门用于处理群内 notify tips // grayTipProcessor 提取出来专门用于处理群内 notify tips
@ -88,6 +94,14 @@ func (e *GroupPokeNotifyEvent) Content() string {
return fmt.Sprintf("%d戳了戳%d", e.Sender, e.Receiver) 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 { func (e *GroupRedBagLuckyKingNotifyEvent) From() int64 {
return e.GroupCode return e.GroupCode
} }