1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00

supported more group operation.

This commit is contained in:
Mrs4s 2020-07-21 06:57:53 +08:00
parent 0a8fa220ea
commit a0cac4698b
6 changed files with 1826 additions and 9 deletions

View File

@ -8,6 +8,7 @@ import (
"github.com/Mrs4s/MiraiGo/client/pb"
"github.com/Mrs4s/MiraiGo/client/pb/cmd0x352"
"github.com/Mrs4s/MiraiGo/client/pb/msg"
"github.com/Mrs4s/MiraiGo/client/pb/oidb"
"github.com/Mrs4s/MiraiGo/client/pb/structmsg"
"github.com/Mrs4s/MiraiGo/message"
"github.com/Mrs4s/MiraiGo/protocol/crypto"
@ -701,10 +702,75 @@ func (c *QQClient) buildEditGroupTagPacket(groupCode, memberUin int64, newTag st
Context: map[string]string{},
Status: map[string]string{},
}
packet := packets.BuildUniPacket(c.Uin, seq, "friendlist.ModifyGroupCardReq", 1, c.OutGoingPacketSessionId, []byte{}, c.sigInfo.d2Key, pkt.ToBytes())
packet := packets.BuildUniPacket(c.Uin, seq, "friendlist.ModifyGroupCardReq", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, pkt.ToBytes())
return seq, packet
}
// OidbSvc.0x8fc_2
func (c *QQClient) buildEditSpecialTitlePacket(groupCode, memberUin int64, newTitle string) (uint16, []byte) {
seq := c.nextSeq()
body := &oidb.D8FCReqBody{
GroupCode: groupCode,
MemLevelInfo: []*oidb.D8FCMemberInfo{
{
Uin: memberUin,
UinName: []byte(newTitle),
SpecialTitle: []byte(newTitle),
SpecialTitleExpireTime: -1,
},
},
}
b, _ := proto.Marshal(body)
req := &oidb.OIDBSSOPkg{
Command: 2300,
ServiceType: 2,
Bodybuffer: b,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x8fc_2", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
// OidbSvc.0x89a_0
func (c *QQClient) buildGroupOperationPacket(body *oidb.D89AReqBody) (uint16, []byte) {
seq := c.nextSeq()
b, _ := proto.Marshal(body)
req := &oidb.OIDBSSOPkg{
Command: 2202,
Bodybuffer: b,
}
payload, _ := proto.Marshal(req)
packet := packets.BuildUniPacket(c.Uin, seq, "OidbSvc.0x89a_0", 1, c.OutGoingPacketSessionId, EmptyBytes, c.sigInfo.d2Key, payload)
return seq, packet
}
// OidbSvc.0x89a_0
func (c *QQClient) buildGroupNameUpdatePacket(groupCode int64, newName string) (uint16, []byte) {
body := &oidb.D89AReqBody{
GroupCode: groupCode,
StGroupInfo: &oidb.D89AGroupinfo{
IngGroupName: []byte(newName),
},
}
return c.buildGroupOperationPacket(body)
}
// OidbSvc.0x89a_0
func (c *QQClient) buildGroupMuteAllPacket(groupCode int64, mute bool) (uint16, []byte) {
body := &oidb.D89AReqBody{
GroupCode: groupCode,
StGroupInfo: &oidb.D89AGroupinfo{
ShutupTime: func() int32 {
if mute {
return 1
}
return 0
}(),
},
}
return c.buildGroupOperationPacket(body)
}
/*
func (c *QQClient) buildMultiMsgDownRequestPacket() (uint16, []byte){
seq := c.nextSeq()

View File

@ -435,6 +435,10 @@ func (g *GroupInfo) SelfPermission() MemberPermission {
return g.FindMember(g.bot.Uin).Permission
}
func (g *GroupInfo) AdministratorOrOwner() bool {
return g.SelfPermission() == Administrator || g.SelfPermission() == Owner
}
func (g *GroupInfo) FindMember(uin int64) *GroupMemberInfo {
for _, m := range g.Members {
f := m
@ -445,10 +449,22 @@ func (g *GroupInfo) FindMember(uin int64) *GroupMemberInfo {
return nil
}
func (c *QQClient) EditMemberCard(groupCode, memberUin int64, card string) {
func (c *QQClient) editMemberCard(groupCode, memberUin int64, card string) {
_, _ = c.sendAndWait(c.buildEditGroupTagPacket(groupCode, memberUin, card))
}
func (c *QQClient) editMemberSpecialTitle(groupCode, memberUin int64, title string) {
_, _ = c.sendAndWait(c.buildEditSpecialTitlePacket(groupCode, memberUin, title))
}
func (c *QQClient) updateGroupName(groupCode int64, newName string) {
_, _ = c.sendAndWait(c.buildGroupNameUpdatePacket(groupCode, newName))
}
func (c *QQClient) groupMuteAll(groupCode int64, mute bool) {
_, _ = c.sendAndWait(c.buildGroupMuteAllPacket(groupCode, mute))
}
func (g *GroupInfo) removeMember(uin int64) {
if g.memLock == nil {
g.memLock = new(sync.Mutex)

View File

@ -2,6 +2,7 @@ package client
import (
"errors"
"strings"
"sync"
)
@ -174,6 +175,19 @@ const (
Member
)
func (g *GroupInfo) UpdateName(newName string) {
if g.AdministratorOrOwner() && strings.Count(newName, "") <= 20 {
g.bot.updateGroupName(g.Code, newName)
g.Name = newName
}
}
func (g *GroupInfo) MuteAll(mute bool) {
if g.AdministratorOrOwner() {
g.bot.groupMuteAll(g.Code, mute)
}
}
func (m *GroupMemberInfo) DisplayName() string {
if m.CardName == "" {
return m.Nickname
@ -182,12 +196,19 @@ func (m *GroupMemberInfo) DisplayName() string {
}
func (m *GroupMemberInfo) EditCard(card string) {
if m.Manageable() {
m.Group.bot.EditMemberCard(m.Group.Code, m.Uin, card)
if m.Manageable() && strings.Count(card, "") <= 20 {
m.Group.bot.editMemberCard(m.Group.Code, m.Uin, card)
m.CardName = card
}
}
func (m *GroupMemberInfo) EditSpecialTitle(title string) {
if m.Group.SelfPermission() == Owner && strings.Count(title, "") <= 6 {
m.Group.bot.editMemberSpecialTitle(m.Group.Code, m.Uin, title)
m.SpecialTitle = title
}
}
func (m *GroupMemberInfo) Manageable() bool {
if m.Uin == m.Group.bot.Uin {
return true

1596
client/pb/oidb/oidb.pb.go Normal file

File diff suppressed because it is too large Load Diff

123
client/pb/oidb/oidb.proto Normal file
View File

@ -0,0 +1,123 @@
syntax = "proto3";
option go_package = ".;oidb";
message OIDBSSOPkg {
int32 command = 1;
int32 serviceType = 2;
int32 result = 3;
bytes bodybuffer = 4;
string errorMsg = 5;
string clientVersion = 6;
}
message D8FCReqBody {
int64 groupCode = 1;
int32 showFlag = 2;
repeated D8FCMemberInfo memLevelInfo = 3;
repeated D8FCLevelName levelName = 4;
int32 updateTime = 5;
int32 officeMode = 6;
int32 groupOpenAppid = 7;
D8FCClientInfo msgClientInfo = 8;
bytes authKey = 9;
}
message D89AReqBody {
int64 groupCode = 1;
D89AGroupinfo stGroupInfo = 2;
int64 originalOperatorUin = 3;
int32 reqGroupOpenAppid = 4;
}
message D89AGroupinfo {
int32 groupExtAdmNum = 1;
int32 flag = 2;
bytes ingGroupName = 3;
bytes ingGroupMemo = 4;
bytes ingGroupFingerMemo = 5;
bytes ingGroupAioSkinUrl = 6;
bytes ingGroupBoardSkinUrl = 7;
bytes ingGroupCoverSkinUrl = 8;
int32 groupGrade = 9;
int32 activeMemberNum = 10;
int32 certificationType = 11;
bytes ingCertificationText = 12;
bytes ingGroupRichFingerMemo = 13;
D89AGroupNewGuidelinesInfo stGroupNewguidelines = 14;
int32 groupFace = 15;
int32 addOption = 16;
int32 shutupTime = 17;
int32 groupTypeFlag = 18;
bytes stringGroupTag = 19;
D89AGroupGeoInfo msgGroupGeoInfo = 20;
int32 groupClassExt = 21;
bytes ingGroupClassText = 22;
int32 appPrivilegeFlag = 23;
int32 appPrivilegeMask = 24;
D89AGroupExInfoOnly stGroupExInfo = 25;
int32 groupSecLevel = 26;
int32 groupSecLevelInfo = 27;
int64 subscriptionUin = 28;
int32 allowMemberInvite = 29;
bytes ingGroupQuestion = 30;
bytes ingGroupAnswer = 31;
int32 groupFlagext3 = 32;
int32 groupFlagext3Mask = 33;
int32 groupOpenAppid = 34;
int32 noFingerOpenFlag = 35;
int32 noCodeFingerOpenFlag = 36;
int64 rootId = 37;
int32 msgLimitFrequency = 38;
}
message D89AGroupNewGuidelinesInfo {
bool boolEnabled = 1;
bytes ingContent = 2;
}
message D89AGroupExInfoOnly {
int32 tribeId = 1;
int32 moneyForAddGroup = 2;
}
message D89AGroupGeoInfo {
int32 cityId = 1;
int64 longtitude = 2;
int64 latitude = 3;
bytes ingGeoContent = 4;
int64 poiId = 5;
}
message D8FCMemberInfo {
int64 uin = 1;
int32 point = 2;
int32 activeDay = 3;
int32 level = 4;
bytes specialTitle = 5;
int32 specialTitleExpireTime = 6;
bytes uinName = 7;
bytes memberCardName = 8;
bytes phone = 9;
bytes email = 10;
bytes remark = 11;
int32 gender = 12;
bytes job = 13;
int32 tribeLevel = 14;
int32 tribePoint = 15;
repeated D8FCCardNameElem richCardName = 16;
bytes commRichCardName = 17;
}
message D8FCCardNameElem {
int32 enumCardType = 1;
bytes value = 2;
}
message D8FCLevelName {
int32 level = 1;
string name = 2;
}
message D8FCClientInfo {
int32 implat = 1;
string ingClientver = 2;
}

View File

@ -91,11 +91,6 @@ func ParseIncomingPacket(payload, d2key []byte) (*IncomingPacket, error) {
}
reader.ReadString() // uin string
decrypted := func() (data []byte) {
defer func() {
if pan := recover(); pan != nil {
// TODO: bot.client.tryDecryptOrNull
}
}()
switch flag2 {
case 0:
return reader.ReadAvailable()