mirror of
https://github.com/Mrs4s/MiraiGo.git
synced 2025-05-04 19:17:38 +08:00
feat: MemberSpecialTitleUpdatedEvent.
This commit is contained in:
parent
1d900b302d
commit
afa6db17ab
@ -33,6 +33,7 @@ type eventHandlers struct {
|
|||||||
serverUpdatedHandlers []func(*QQClient, *ServerUpdatedEvent) bool
|
serverUpdatedHandlers []func(*QQClient, *ServerUpdatedEvent) bool
|
||||||
groupNotifyHandlers []func(*QQClient, INotifyEvent)
|
groupNotifyHandlers []func(*QQClient, INotifyEvent)
|
||||||
friendNotifyHandlers []func(*QQClient, INotifyEvent)
|
friendNotifyHandlers []func(*QQClient, INotifyEvent)
|
||||||
|
memberTitleUpdatedHandlers []func(*QQClient, *MemberSpecialTitleUpdatedEvent)
|
||||||
offlineFileHandlers []func(*QQClient, *OfflineFileEvent)
|
offlineFileHandlers []func(*QQClient, *OfflineFileEvent)
|
||||||
otherClientStatusChangedHandlers []func(*QQClient, *OtherClientStatusChangedEvent)
|
otherClientStatusChangedHandlers []func(*QQClient, *OtherClientStatusChangedEvent)
|
||||||
groupDigestHandlers []func(*QQClient, *GroupDigestEvent)
|
groupDigestHandlers []func(*QQClient, *GroupDigestEvent)
|
||||||
@ -151,6 +152,10 @@ func (c *QQClient) OnFriendNotify(f func(*QQClient, INotifyEvent)) {
|
|||||||
c.eventHandlers.friendNotifyHandlers = append(c.eventHandlers.friendNotifyHandlers, f)
|
c.eventHandlers.friendNotifyHandlers = append(c.eventHandlers.friendNotifyHandlers, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *QQClient) OnMemberSpecialTitleUpdated(f func(*QQClient, *MemberSpecialTitleUpdatedEvent)) {
|
||||||
|
c.eventHandlers.memberTitleUpdatedHandlers = append(c.eventHandlers.memberTitleUpdatedHandlers, f)
|
||||||
|
}
|
||||||
|
|
||||||
// OnGroupDigest 群精华消息事件注册
|
// OnGroupDigest 群精华消息事件注册
|
||||||
func (c *QQClient) OnGroupDigest(f func(*QQClient, *GroupDigestEvent)) {
|
func (c *QQClient) OnGroupDigest(f func(*QQClient, *GroupDigestEvent)) {
|
||||||
c.eventHandlers.groupDigestHandlers = append(c.eventHandlers.groupDigestHandlers, f)
|
c.eventHandlers.groupDigestHandlers = append(c.eventHandlers.groupDigestHandlers, f)
|
||||||
@ -408,6 +413,17 @@ func (c *QQClient) dispatchFriendNotifyEvent(e INotifyEvent) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *QQClient) dispatchMemberSpecialTitleUpdateEvent(e *MemberSpecialTitleUpdatedEvent) {
|
||||||
|
if e == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, f := range c.eventHandlers.memberTitleUpdatedHandlers {
|
||||||
|
cover(func() {
|
||||||
|
f(c, e)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *QQClient) dispatchDisconnectEvent(e *ClientDisconnectedEvent) {
|
func (c *QQClient) dispatchDisconnectEvent(e *ClientDisconnectedEvent) {
|
||||||
if e == nil {
|
if e == nil {
|
||||||
return
|
return
|
||||||
|
@ -105,7 +105,7 @@ func (c *QQClient) sendGroupMessage(groupCode int64, forward bool, m *message.Se
|
|||||||
})
|
})
|
||||||
defer c.onGroupMessageReceipt(eid)
|
defer c.onGroupMessageReceipt(eid)
|
||||||
imgCount := 0
|
imgCount := 0
|
||||||
frag := true
|
serviceFlag := true
|
||||||
for _, e := range m.Elements {
|
for _, e := range m.Elements {
|
||||||
switch e.Type() {
|
switch e.Type() {
|
||||||
case message.Image:
|
case message.Image:
|
||||||
@ -114,10 +114,10 @@ func (c *QQClient) sendGroupMessage(groupCode int64, forward bool, m *message.Se
|
|||||||
forward = true
|
forward = true
|
||||||
fallthrough
|
fallthrough
|
||||||
case message.Reply, message.Voice, message.Service:
|
case message.Reply, message.Voice, message.Service:
|
||||||
frag = false
|
serviceFlag = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !forward && frag && (imgCount > 1 || message.EstimateLength(m.Elements) > 100) {
|
if !forward && serviceFlag && (imgCount > 1 || message.EstimateLength(m.Elements) > 100) {
|
||||||
div := int32(rand.Uint32())
|
div := int32(rand.Uint32())
|
||||||
fragmented := m.ToFragmented()
|
fragmented := m.ToFragmented()
|
||||||
for i, elems := range fragmented {
|
for i, elems := range fragmented {
|
||||||
|
@ -2,7 +2,9 @@ package client
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/Mrs4s/MiraiGo/utils"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/Mrs4s/MiraiGo/client/pb/notify"
|
"github.com/Mrs4s/MiraiGo/client/pb/notify"
|
||||||
)
|
)
|
||||||
@ -30,6 +32,13 @@ type (
|
|||||||
Nick string
|
Nick string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MemberSpecialTitleUpdatedEvent 群成员头衔更新事件
|
||||||
|
MemberSpecialTitleUpdatedEvent struct {
|
||||||
|
GroupCode int64
|
||||||
|
Uin int64
|
||||||
|
NewTitle string
|
||||||
|
}
|
||||||
|
|
||||||
// FriendPokeNotifyEvent 好友戳一戳提示事件
|
// FriendPokeNotifyEvent 好友戳一戳提示事件
|
||||||
FriendPokeNotifyEvent struct {
|
FriendPokeNotifyEvent struct {
|
||||||
Sender int64
|
Sender int64
|
||||||
@ -38,7 +47,7 @@ type (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// grayTipProcessor 提取出来专门用于处理群内 notify tips
|
// grayTipProcessor 提取出来专门用于处理群内 notify tips
|
||||||
func (c *QQClient) grayTipProcessor(groupID int64, tipInfo *notify.GeneralGrayTipInfo) {
|
func (c *QQClient) grayTipProcessor(groupCode int64, tipInfo *notify.GeneralGrayTipInfo) {
|
||||||
if tipInfo.BusiType == 12 && tipInfo.BusiId == 1061 {
|
if tipInfo.BusiType == 12 && tipInfo.BusiId == 1061 {
|
||||||
sender := int64(0)
|
sender := int64(0)
|
||||||
receiver := c.Uin
|
receiver := c.Uin
|
||||||
@ -52,7 +61,7 @@ func (c *QQClient) grayTipProcessor(groupID int64, tipInfo *notify.GeneralGrayTi
|
|||||||
}
|
}
|
||||||
if sender != 0 {
|
if sender != 0 {
|
||||||
c.dispatchGroupNotifyEvent(&GroupPokeNotifyEvent{
|
c.dispatchGroupNotifyEvent(&GroupPokeNotifyEvent{
|
||||||
GroupCode: groupID,
|
GroupCode: groupCode,
|
||||||
Sender: sender,
|
Sender: sender,
|
||||||
Receiver: receiver,
|
Receiver: receiver,
|
||||||
})
|
})
|
||||||
@ -71,7 +80,7 @@ func (c *QQClient) grayTipProcessor(groupID int64, tipInfo *notify.GeneralGrayTi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.dispatchGroupNotifyEvent(&MemberHonorChangedNotifyEvent{
|
c.dispatchGroupNotifyEvent(&MemberHonorChangedNotifyEvent{
|
||||||
GroupCode: groupID,
|
GroupCode: groupCode,
|
||||||
Honor: func() HonorType {
|
Honor: func() HonorType {
|
||||||
switch tipInfo.TemplId {
|
switch tipInfo.TemplId {
|
||||||
case 1052:
|
case 1052:
|
||||||
@ -90,6 +99,51 @@ func (c *QQClient) grayTipProcessor(groupID int64, tipInfo *notify.GeneralGrayTi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// msgGrayTipProcessor 用于处理群内 aio notify tips
|
||||||
|
func (c *QQClient) msgGrayTipProcessor(groupCode int64, tipInfo *notify.AIOGrayTipsInfo) {
|
||||||
|
if len(tipInfo.Content) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
type tipCommand struct {
|
||||||
|
Command int `json:"cmd"`
|
||||||
|
Data string `json:"data"`
|
||||||
|
Text string `json:"text"`
|
||||||
|
}
|
||||||
|
content := utils.B2S(tipInfo.Content)
|
||||||
|
var tipCmds []*tipCommand
|
||||||
|
start := -1
|
||||||
|
for i := 0; i < len(content); i++ {
|
||||||
|
if content[i] == '<' && len(content) > i+1 && content[i+1] == '{' {
|
||||||
|
start = i + 1
|
||||||
|
}
|
||||||
|
if content[i] == '>' && content[i-1] == '}' && start != -1 {
|
||||||
|
tip := &tipCommand{}
|
||||||
|
if err := json.Unmarshal(utils.S2B(content[start:i]), tip); err == nil {
|
||||||
|
tipCmds = append(tipCmds, tip)
|
||||||
|
}
|
||||||
|
start = -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 好像只能这么判断
|
||||||
|
switch {
|
||||||
|
case strings.Contains(content, "头衔"):
|
||||||
|
event := &MemberSpecialTitleUpdatedEvent{GroupCode: groupCode}
|
||||||
|
for _, cmd := range tipCmds {
|
||||||
|
if cmd.Command == 5 {
|
||||||
|
event.Uin, _ = strconv.ParseInt(cmd.Data, 10, 64)
|
||||||
|
}
|
||||||
|
if cmd.Command == 1 {
|
||||||
|
event.NewTitle = cmd.Text
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if event.Uin == 0 {
|
||||||
|
c.Error("process special title updated tips error: missing cmd")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.dispatchMemberSpecialTitleUpdateEvent(event)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (e *GroupPokeNotifyEvent) From() int64 {
|
func (e *GroupPokeNotifyEvent) From() int64 {
|
||||||
return e.GroupCode
|
return e.GroupCode
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ func decodeOnlinePushReqPacket(c *QQClient, info *incomingPacketInfo, payload []
|
|||||||
// 0x2dc
|
// 0x2dc
|
||||||
if m.MsgType == 732 {
|
if m.MsgType == 732 {
|
||||||
r := binary.NewReader(m.VMsg)
|
r := binary.NewReader(m.VMsg)
|
||||||
groupID := int64(uint32(r.ReadInt32()))
|
groupCode := int64(uint32(r.ReadInt32()))
|
||||||
iType := r.ReadByte()
|
iType := r.ReadByte()
|
||||||
r.ReadByte()
|
r.ReadByte()
|
||||||
switch iType {
|
switch iType {
|
||||||
@ -55,7 +55,7 @@ func decodeOnlinePushReqPacket(c *QQClient, info *incomingPacketInfo, payload []
|
|||||||
target := int64(uint32(r.ReadInt32()))
|
target := int64(uint32(r.ReadInt32()))
|
||||||
t := r.ReadInt32()
|
t := r.ReadInt32()
|
||||||
c.dispatchGroupMuteEvent(&GroupMuteEvent{
|
c.dispatchGroupMuteEvent(&GroupMuteEvent{
|
||||||
GroupCode: groupID,
|
GroupCode: groupCode,
|
||||||
OperatorUin: operator,
|
OperatorUin: operator,
|
||||||
TargetUin: target,
|
TargetUin: target,
|
||||||
Time: t,
|
Time: t,
|
||||||
@ -70,7 +70,7 @@ func decodeOnlinePushReqPacket(c *QQClient, info *incomingPacketInfo, payload []
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
c.dispatchGroupMessageRecalledEvent(&GroupMessageRecalledEvent{
|
c.dispatchGroupMessageRecalledEvent(&GroupMessageRecalledEvent{
|
||||||
GroupCode: groupID,
|
GroupCode: groupCode,
|
||||||
OperatorUin: b.OptMsgRecall.Uin,
|
OperatorUin: b.OptMsgRecall.Uin,
|
||||||
AuthorUin: rm.AuthorUin,
|
AuthorUin: rm.AuthorUin,
|
||||||
MessageId: rm.Seq,
|
MessageId: rm.Seq,
|
||||||
@ -79,12 +79,12 @@ func decodeOnlinePushReqPacket(c *QQClient, info *incomingPacketInfo, payload []
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if b.OptGeneralGrayTip != nil {
|
if b.OptGeneralGrayTip != nil {
|
||||||
c.grayTipProcessor(groupID, b.OptGeneralGrayTip)
|
c.grayTipProcessor(groupCode, b.OptGeneralGrayTip)
|
||||||
}
|
}
|
||||||
if b.OptMsgRedTips != nil {
|
if b.OptMsgRedTips != nil {
|
||||||
if b.OptMsgRedTips.LuckyFlag == 1 { // 运气王提示
|
if b.OptMsgRedTips.LuckyFlag == 1 { // 运气王提示
|
||||||
c.dispatchGroupNotifyEvent(&GroupRedBagLuckyKingNotifyEvent{
|
c.dispatchGroupNotifyEvent(&GroupRedBagLuckyKingNotifyEvent{
|
||||||
GroupCode: groupID,
|
GroupCode: groupCode,
|
||||||
Sender: int64(b.OptMsgRedTips.SenderUin),
|
Sender: int64(b.OptMsgRedTips.SenderUin),
|
||||||
LuckyKing: int64(b.OptMsgRedTips.LuckyUin),
|
LuckyKing: int64(b.OptMsgRedTips.LuckyUin),
|
||||||
})
|
})
|
||||||
@ -104,6 +104,9 @@ func decodeOnlinePushReqPacket(c *QQClient, info *incomingPacketInfo, payload []
|
|||||||
OperatorNick: string(digest.OperNick),
|
OperatorNick: string(digest.OperNick),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
if b.OptMsgGrayTips != nil {
|
||||||
|
c.msgGrayTipProcessor(groupCode, b.OptMsgGrayTips)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 0x210
|
// 0x210
|
||||||
|
Loading…
x
Reference in New Issue
Block a user