diff --git a/QQ.Framework/Domains/Commands/ReceiveCommands/Message/ReceiveGroupSystemMessagesCommand.cs b/QQ.Framework/Domains/Commands/ReceiveCommands/Message/ReceiveGroupSystemMessagesCommand.cs index 9831958..24fd652 100644 --- a/QQ.Framework/Domains/Commands/ReceiveCommands/Message/ReceiveGroupSystemMessagesCommand.cs +++ b/QQ.Framework/Domains/Commands/ReceiveCommands/Message/ReceiveGroupSystemMessagesCommand.cs @@ -24,7 +24,7 @@ public override void Process() { Response(); //除了自己消息以外的消息进行转发 - if (!_user.GroupSendMessages.Where(c => c.Sequence == _packet.Sequence).Any()) + if (_user.GroupSendMessages.All(c => c.Sequence != _packet.Sequence)) { // 将收到的群/系统消息转发给所有机器人 _transponder.ReceiveGroupMessage(_packet.Group, _packet.FromQQ, _packet.Message); diff --git a/QQ.Framework/Domains/Commands/ResponseCommands/Message/ResponseGroupOrSystemMessageCommand.cs b/QQ.Framework/Domains/Commands/ResponseCommands/Message/ResponseGroupOrSystemMessageCommand.cs index 4131285..28fb587 100644 --- a/QQ.Framework/Domains/Commands/ResponseCommands/Message/ResponseGroupOrSystemMessageCommand.cs +++ b/QQ.Framework/Domains/Commands/ResponseCommands/Message/ResponseGroupOrSystemMessageCommand.cs @@ -18,9 +18,10 @@ public override void Process() if (!string.IsNullOrEmpty(_packet.Message)) { //当收到消息包序为自己发送的消息包序时更新消息Id - if (_user.GroupSendMessages.Where(c => c.Sequence == _packet.Sequence).Any()) + if (_user.GroupSendMessages.Any(c => c.Sequence == _packet.Sequence)) { - var messageSend = _user.GroupSendMessages.Where(c => c.Sequence == _packet.Sequence).FirstOrDefault(); + var messageSend = _user.GroupSendMessages + .FirstOrDefault(c => c.Sequence == _packet.Sequence); if (messageSend != null) { messageSend.MessageId = _packet.MessageId; @@ -29,7 +30,7 @@ public override void Process() } else { - if (!_user.GroupReceiveMessages.Where(c => c.Sequence == _packet.Sequence).Any()) + if (_user.GroupReceiveMessages.All(c => c.Sequence != _packet.Sequence)) { if (!QQGlobal.DebugLog && _packet.Message.ToString().Count(c => c == '\0') > 5) { @@ -40,9 +41,8 @@ public override void Process() //添加到已处理消息列表 _user.GroupReceiveMessages.Add(_packet); - - } + //查看群消息确认 if (_packet.ReceiveTime != null) { @@ -50,16 +50,11 @@ public override void Process() } } } - else - { - //_service.MessageLog($"收到群{_packet.Group}的{_packet.FromQQ}的空消息。"); - } //提取数据 var dataReader = new BinaryReader(new MemoryStream(_packet.BodyDecrypted)); _service.Send(new Send_0X0017(_user, dataReader.ReadBytes(0x10), _packet.Sequence)); - } } } \ No newline at end of file diff --git a/QQ.Framework/Domains/Commands/ResponseCommands/Message/ResponseReceiveFriendMessageCommand.cs b/QQ.Framework/Domains/Commands/ResponseCommands/Message/ResponseReceiveFriendMessageCommand.cs index 96f6585..d77a80f 100644 --- a/QQ.Framework/Domains/Commands/ResponseCommands/Message/ResponseReceiveFriendMessageCommand.cs +++ b/QQ.Framework/Domains/Commands/ResponseCommands/Message/ResponseReceiveFriendMessageCommand.cs @@ -21,7 +21,7 @@ public override void Process() if (!string.IsNullOrEmpty(_packet.Message.ToString())) { //只处理没有处理过的消息 - if (!_user.FriendReceiveMessages.Where(c => c.Sequence == _packet.Sequence).Any()) + if (_user.FriendReceiveMessages.All(c => c.Sequence != _packet.Sequence)) { if (!QQGlobal.DebugLog && _packet.Message.ToString().Count(c => c == '\0') > 5) { diff --git a/QQ.Framework/Packets/PCTLV/TLV_0102.cs b/QQ.Framework/Packets/PCTLV/TLV_0102.cs index d178837..6e1d017 100644 --- a/QQ.Framework/Packets/PCTLV/TLV_0102.cs +++ b/QQ.Framework/Packets/PCTLV/TLV_0102.cs @@ -22,7 +22,7 @@ public byte[] Get_Tlv(QQUser user) data.BeWrite(WSubVer); //OfficialKey data.Write(new byte[] - {0x9e, 0x9b, 0x03, 0x23, 0x6d, 0x7f, 0xa8, 0x81, 0xa8, 0x10, 0x72, 0xec, 0x50, 0x97, 0x96, 0x8e}); + { 0x9e, 0x9b, 0x03, 0x23, 0x6d, 0x7f, 0xa8, 0x81, 0xa8, 0x10, 0x72, 0xec, 0x50, 0x97, 0x96, 0x8e }); var bufSigPic = user.TXProtocol.BufSigPic ?? Util.RandomKey(56); data.WriteKey(bufSigPic); //Official diff --git a/QQ.Framework/Packets/PCTLV/TLV_0104.cs b/QQ.Framework/Packets/PCTLV/TLV_0104.cs index 4202eca..a588ddd 100644 --- a/QQ.Framework/Packets/PCTLV/TLV_0104.cs +++ b/QQ.Framework/Packets/PCTLV/TLV_0104.cs @@ -24,8 +24,8 @@ public void Parser_Tlv(QQUser user, BinaryReader buf) { var type = buf.BeReadUInt16(); //type var length = buf.BeReadUInt16(); //length - var Data = buf.ReadBytes(length); - var bufData = new BinaryReader(new MemoryStream(Data)); + var data = buf.ReadBytes(length); + var bufData = new BinaryReader(new MemoryStream(data)); WSubVer = bufData.BeReadUInt16(); //wSubVer if (WSubVer == 0x0001) { diff --git a/QQ.Framework/Packets/PCTLV/TLV_0109.cs b/QQ.Framework/Packets/PCTLV/TLV_0109.cs index b328317..b5e87f7 100644 --- a/QQ.Framework/Packets/PCTLV/TLV_0109.cs +++ b/QQ.Framework/Packets/PCTLV/TLV_0109.cs @@ -17,8 +17,8 @@ public void Parser_Tlv(QQUser user, BinaryReader buf) { var type = buf.BeReadUInt16(); //type var length = buf.BeReadUInt16(); //length - var Data = buf.ReadBytes(length); - var bufData = new BinaryReader(new MemoryStream(Data)); + var data = buf.ReadBytes(length); + var bufData = new BinaryReader(new MemoryStream(data)); WSubVer = bufData.BeReadUInt16(); //wSubVer if (WSubVer == 0x0001) { diff --git a/QQ.Framework/Packets/PCTLV/TLV_050C.cs b/QQ.Framework/Packets/PCTLV/TLV_050C.cs index 85cc984..d964aeb 100644 --- a/QQ.Framework/Packets/PCTLV/TLV_050C.cs +++ b/QQ.Framework/Packets/PCTLV/TLV_050C.cs @@ -15,34 +15,35 @@ public TLV050C() public byte[] Get_Tlv(QQUser user) { - var Buf = new BinaryWriter(new MemoryStream()); - var _dataTime = DateTime.Now; - Buf.BeWrite(0); - Buf.BeWrite(user.QQ); - Buf.Write(new byte[] {0x76, 0x71, 0x01, 0x9d}); - Buf.BeWrite(Util.GetTimeMillis(_dataTime)); - Buf.BeWrite(user.TXProtocol.DwServiceId); - Buf.Write(new byte[] {0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x00, 0x04, 0x5f, 0x80, 0x33, 0x01, 0x01}); - Buf.BeWrite(user.TXProtocol.DwClientVer); - Buf.Write(new byte[] - {0x66, 0x35, 0x4d, 0xf1, 0xab, 0xdc, 0x98, 0xf0, 0x70, 0x69, 0xfc, 0x2a, 0x2b, 0x86, 0x06, 0x1b}); - Buf.BeWrite(user.TXProtocol.SubVer); + var buf = new BinaryWriter(new MemoryStream()); + var dataTime = DateTime.Now; + buf.BeWrite(0); + buf.BeWrite(user.QQ); + buf.Write(new byte[] { 0x76, 0x71, 0x01, 0x9d }); + buf.BeWrite(Util.GetTimeMillis(dataTime)); + buf.BeWrite(user.TXProtocol.DwServiceId); + buf.Write(new byte[] + { 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x00, 0x04, 0x5f, 0x80, 0x33, 0x01, 0x01 }); + buf.BeWrite(user.TXProtocol.DwClientVer); + buf.Write(new byte[] + { 0x66, 0x35, 0x4d, 0xf1, 0xab, 0xdc, 0x98, 0xf0, 0x70, 0x69, 0xfc, 0x2a, 0x2b, 0x86, 0x06, 0x1b }); + buf.BeWrite(user.TXProtocol.SubVer); - var Data = new BinaryWriter(new MemoryStream()); - Data.BeWrite(0); - Data.BeWrite(user.QQ); - Data.Write(new byte[] {0x76, 0x71, 0x01, 0x9d}); - Data.BeWrite(Util.GetTimeMillis(_dataTime)); - Data.Write(user.TXProtocol.DwPubNo); + var data = new BinaryWriter(new MemoryStream()); + data.BeWrite(0); + data.BeWrite(user.QQ); + data.Write(new byte[] { 0x76, 0x71, 0x01, 0x9d }); + data.BeWrite(Util.GetTimeMillis(dataTime)); + data.Write(user.TXProtocol.DwPubNo); - Buf.Write((byte) Data.BaseStream.Length * 3); - Buf.Write(Data.BaseStream.ToBytesArray()); - Buf.Write(Data.BaseStream.ToBytesArray()); - Buf.Write(Data.BaseStream.ToBytesArray()); + buf.Write((byte) data.BaseStream.Length * 3); + buf.Write(data.BaseStream.ToBytesArray()); + buf.Write(data.BaseStream.ToBytesArray()); + buf.Write(data.BaseStream.ToBytesArray()); FillHead(Command); - FillBody(Buf.BaseStream.ToBytesArray(), Buf.BaseStream.Length); + FillBody(buf.BaseStream.ToBytesArray(), buf.BaseStream.Length); SetLength(); return GetBuffer(); } diff --git a/QQ.Framework/Packets/Receive/Data/Receive_0x00D8.cs b/QQ.Framework/Packets/Receive/Data/Receive_0x00D8.cs index 0933651..95e4103 100644 --- a/QQ.Framework/Packets/Receive/Data/Receive_0x00D8.cs +++ b/QQ.Framework/Packets/Receive/Data/Receive_0x00D8.cs @@ -2,8 +2,8 @@ namespace QQ.Framework.Packets.Receive.Data { public class Receive_0X00D8 : ReceivePacket { - public Receive_0X00D8(byte[] byteBuffer, QQUser User) - : base(byteBuffer, User, User.TXProtocol.SessionKey) + public Receive_0X00D8(byte[] byteBuffer, QQUser user) + : base(byteBuffer, user, user.TXProtocol.SessionKey) { } diff --git a/QQ.Framework/Packets/Receive/Data/Receive_0x0126.cs b/QQ.Framework/Packets/Receive/Data/Receive_0x0126.cs index ff0dfd8..cccca25 100644 --- a/QQ.Framework/Packets/Receive/Data/Receive_0x0126.cs +++ b/QQ.Framework/Packets/Receive/Data/Receive_0x0126.cs @@ -2,8 +2,8 @@ namespace QQ.Framework.Packets.Receive.Data { public class Receive_0X0126 : ReceivePacket { - public Receive_0X0126(byte[] byteBuffer, QQUser User) - : base(byteBuffer, User, User.TXProtocol.SessionKey) + public Receive_0X0126(byte[] byteBuffer, QQUser user) + : base(byteBuffer, user, user.TXProtocol.SessionKey) { } diff --git a/QQ.Framework/Packets/Receive/Data/Receive_0x0134.cs b/QQ.Framework/Packets/Receive/Data/Receive_0x0134.cs index 9ce11cc..d282612 100644 --- a/QQ.Framework/Packets/Receive/Data/Receive_0x0134.cs +++ b/QQ.Framework/Packets/Receive/Data/Receive_0x0134.cs @@ -2,8 +2,8 @@ namespace QQ.Framework.Packets.Receive.Data { public class Receive_0X0134 : ReceivePacket { - public Receive_0X0134(byte[] byteBuffer, QQUser User) - : base(byteBuffer, User, User.TXProtocol.SessionKey) + public Receive_0X0134(byte[] byteBuffer, QQUser user) + : base(byteBuffer, user, user.TXProtocol.SessionKey) { } diff --git a/QQ.Framework/Packets/Receive/Data/Receive_0x0195.cs b/QQ.Framework/Packets/Receive/Data/Receive_0x0195.cs index 5af0b93..563f799 100644 --- a/QQ.Framework/Packets/Receive/Data/Receive_0x0195.cs +++ b/QQ.Framework/Packets/Receive/Data/Receive_0x0195.cs @@ -14,8 +14,8 @@ public class Receive_0X0195 : ReceivePacket /// /// 群分组信息查询 /// - public Receive_0X0195(byte[] byteBuffer, QQUser User) - : base(byteBuffer, User, User.TXProtocol.SessionKey) + public Receive_0X0195(byte[] byteBuffer, QQUser user) + : base(byteBuffer, user, user.TXProtocol.SessionKey) { } @@ -23,7 +23,7 @@ protected override void ParseBody() { Decrypt(User.TXProtocol.SessionKey); Reader.BeReadUInt16(); - var GroupCategoryLength = Reader.BeReadUInt16(); + var groupCategoryLength = Reader.BeReadUInt16(); Reader.ReadBytes(3); Reader.ReadByte(); Reader.BeReadUInt16(); @@ -34,12 +34,12 @@ protected override void ParseBody() { var item = Reader.ReadBytes(itemLength); - var ItemReader = new BinaryReader(new MemoryStream(item)); - ItemReader.ReadByte(); - var Indnex = ItemReader.ReadByte(); - var CateName = Util.GetString(ItemReader.ReadBytes(ItemReader.ReadByte())); - GroupCategory.Add(CateName); - User.MessageLog($"群分组{Indnex}:{CateName}"); + var itemReader = new BinaryReader(new MemoryStream(item)); + itemReader.ReadByte(); + var indnex = itemReader.ReadByte(); + var cateName = Util.GetString(itemReader.ReadBytes(itemReader.ReadByte())); + GroupCategory.Add(cateName); + User.MessageLog($"群分组{indnex}:{cateName}"); itemLength = Reader.BeReadUInt16(); } diff --git a/QQ.Framework/Packets/Receive/Data/Receive_0x019B.cs b/QQ.Framework/Packets/Receive/Data/Receive_0x019B.cs index 9c7ceab..16ad20b 100644 --- a/QQ.Framework/Packets/Receive/Data/Receive_0x019B.cs +++ b/QQ.Framework/Packets/Receive/Data/Receive_0x019B.cs @@ -2,8 +2,8 @@ namespace QQ.Framework.Packets.Receive.Data { public class Receive_0X019B : ReceivePacket { - public Receive_0X019B(byte[] byteBuffer, QQUser User) - : base(byteBuffer, User, User.TXProtocol.SessionKey) + public Receive_0X019B(byte[] byteBuffer, QQUser user) + : base(byteBuffer, user, user.TXProtocol.SessionKey) { } diff --git a/QQ.Framework/Packets/Receive/Data/Receive_0x01A5.cs b/QQ.Framework/Packets/Receive/Data/Receive_0x01A5.cs index cb0070f..df6b7e6 100644 --- a/QQ.Framework/Packets/Receive/Data/Receive_0x01A5.cs +++ b/QQ.Framework/Packets/Receive/Data/Receive_0x01A5.cs @@ -2,8 +2,8 @@ namespace QQ.Framework.Packets.Receive.Data { public class Receive_0X01A5 : ReceivePacket { - public Receive_0X01A5(byte[] byteBuffer, QQUser User) - : base(byteBuffer, User, User.TXProtocol.SessionKey) + public Receive_0X01A5(byte[] byteBuffer, QQUser user) + : base(byteBuffer, user, user.TXProtocol.SessionKey) { } diff --git a/QQ.Framework/Packets/Receive/Data/Receive_0x01C4.cs b/QQ.Framework/Packets/Receive/Data/Receive_0x01C4.cs index 2f93cbc..0f393a5 100644 --- a/QQ.Framework/Packets/Receive/Data/Receive_0x01C4.cs +++ b/QQ.Framework/Packets/Receive/Data/Receive_0x01C4.cs @@ -2,8 +2,8 @@ namespace QQ.Framework.Packets.Receive.Data { public class Receive_0X01C4 : ReceivePacket { - public Receive_0X01C4(byte[] byteBuffer, QQUser User) - : base(byteBuffer, User, User.TXProtocol.SessionKey) + public Receive_0X01C4(byte[] byteBuffer, QQUser user) + : base(byteBuffer, user, user.TXProtocol.SessionKey) { } diff --git a/QQ.Framework/Packets/Receive/Data/Receive_0x01C5.cs b/QQ.Framework/Packets/Receive/Data/Receive_0x01C5.cs index f27f0b3..1999861 100644 --- a/QQ.Framework/Packets/Receive/Data/Receive_0x01C5.cs +++ b/QQ.Framework/Packets/Receive/Data/Receive_0x01C5.cs @@ -2,8 +2,8 @@ namespace QQ.Framework.Packets.Receive.Data { public class Receive_0X01C5 : ReceivePacket { - public Receive_0X01C5(byte[] byteBuffer, QQUser User) - : base(byteBuffer, User, User.TXProtocol.SessionKey) + public Receive_0X01C5(byte[] byteBuffer, QQUser user) + : base(byteBuffer, user, user.TXProtocol.SessionKey) { } diff --git a/QQ.Framework/Packets/Receive/Login/Receive_0x0839.cs b/QQ.Framework/Packets/Receive/Login/Receive_0x0839.cs index cfee6a6..bf2c731 100644 --- a/QQ.Framework/Packets/Receive/Login/Receive_0x0839.cs +++ b/QQ.Framework/Packets/Receive/Login/Receive_0x0839.cs @@ -2,8 +2,8 @@ namespace QQ.Framework.Packets.Receive.Login { public class Receive_0X0839 : ReceivePacket { - public Receive_0X0839(byte[] byteBuffer, QQUser User) - : base(byteBuffer, User, User.TXProtocol.SessionKey) + public Receive_0X0839(byte[] byteBuffer, QQUser user) + : base(byteBuffer, user, user.TXProtocol.SessionKey) { } diff --git a/QQ.Framework/Packets/Receive/Message/Receive_0x0017.cs b/QQ.Framework/Packets/Receive/Message/Receive_0x0017.cs index 697e3c9..a63e2ee 100644 --- a/QQ.Framework/Packets/Receive/Message/Receive_0x0017.cs +++ b/QQ.Framework/Packets/Receive/Message/Receive_0x0017.cs @@ -22,11 +22,6 @@ public Receive_0X0017(byte[] byteBuffer, QQUser user) /// public long Group { get; set; } - /// - /// 消息类型 - /// - public byte MessageType { get; set; } - /// /// 消息 /// @@ -66,11 +61,11 @@ protected override void ParseBody() Reader.BeReadChar(); Reader.ReadBytes(2); Reader.ReadBytes(Reader.BeReadChar()); - Group = (long)Util.GetQQNumRetUint(Util.ToHex(Reader.ReadBytes(4))); //群号 + Group = (long) Util.GetQQNumRetUint(Util.ToHex(Reader.ReadBytes(4))); //群号 if (Reader.ReadByte() == 0x01) { - FromQQ = (long)Util.GetQQNumRetUint(Util.ToHex(Reader.ReadBytes(4))); //发消息人的QQ - MessageIndex = Reader.ReadBytes(4);//姑且叫消息索引吧 + FromQQ = (long) Util.GetQQNumRetUint(Util.ToHex(Reader.ReadBytes(4))); //发消息人的QQ + MessageIndex = Reader.ReadBytes(4); //姑且叫消息索引吧 ReceiveTime = Reader.ReadBytes(4); //接收时间 Reader.ReadBytes(24); SendTime = Reader.ReadBytes(4); //发送时间 @@ -79,8 +74,7 @@ protected override void ParseBody() Font = Reader.ReadBytes(Reader.BeReadChar()); //字体 Reader.ReadByte(); Reader.ReadByte(); - MessageType = Reader.ReadByte();//消息类型 - Reader.ReadRichtext(MessageType, Message); + Message = Reader.ReadRichtext(); } } } diff --git a/QQ.Framework/Packets/Receive/Message/Receive_0x00CE.cs b/QQ.Framework/Packets/Receive/Message/Receive_0x00CE.cs index f8102a7..4d424fa 100644 --- a/QQ.Framework/Packets/Receive/Message/Receive_0x00CE.cs +++ b/QQ.Framework/Packets/Receive/Message/Receive_0x00CE.cs @@ -44,10 +44,12 @@ public Receive_0X00Ce(byte[] byteBuffer, QQUser user) /// 消息内容 /// public Richtext Message { get; set; } = new Richtext(); + /// /// 消息id /// public byte[] MessageId { get; set; } + public string Key1 { get; set; } public string Key2 { get; set; } public string RedId { get; set; } @@ -55,7 +57,7 @@ public Receive_0X00Ce(byte[] byteBuffer, QQUser user) protected override void ParseBody() { Decrypt(User.TXProtocol.SessionKey); - FromQQ = (long)Util.GetQQNumRetUint(Util.ToHex(Reader.ReadBytes(4))); + FromQQ = (long) Util.GetQQNumRetUint(Util.ToHex(Reader.ReadBytes(4))); Reader.ReadBytes(4); //自己的QQ Reader.ReadBytes(10); Reader.ReadBytes(2); @@ -77,8 +79,7 @@ protected override void ParseBody() FontStyle = Reader.ReadBytes(Reader.BeReadChar()); Reader.ReadByte(); Reader.ReadByte(); - MessageType = Reader.ReadByte();//消息类型 - Reader.ReadRichtext(MessageType, Message); + Message = Reader.ReadRichtext(); } } } \ No newline at end of file diff --git a/QQ.Framework/Packets/ReceivePacket.cs b/QQ.Framework/Packets/ReceivePacket.cs index c4b0f24..1893561 100644 --- a/QQ.Framework/Packets/ReceivePacket.cs +++ b/QQ.Framework/Packets/ReceivePacket.cs @@ -118,30 +118,23 @@ public void GetImage(string fileName) internal void TlvExecutionProcessing(ICollection tlvs) { var types = Assembly.GetExecutingAssembly().GetTypes(); - foreach (var tlv in tlvs) + foreach (var type in types) { - foreach (var type in types) + var attributes = type.GetCustomAttributes(); + if (!attributes.Any(attr => attr is TlvTagAttribute)) { - try - { - var attributes = type.GetCustomAttributes(); - if (!attributes.Any(attr => attr is TlvTagAttribute)) - { - continue; - } - - var attribute = attributes.First(attr => attr is TlvTagAttribute) as TlvTagAttribute; - if ((int) attribute.Tag == tlv.Tag) - { - var tlvClass = Assembly.GetExecutingAssembly().CreateInstance(type.FullName, true); - - var methodinfo = type.GetMethod("Parser_Tlv"); - methodinfo.Invoke(tlvClass, new object[] {User, Reader}); - } - } - catch (Exception ex) + continue; + } + + foreach (var tlv in tlvs) + { + var attribute = attributes.First(attr => attr is TlvTagAttribute) as TlvTagAttribute; + if ((int) attribute.Tag == tlv.Tag) { - throw ex; + var tlvClass = Assembly.GetExecutingAssembly().CreateInstance(type.FullName, true); + + var methodinfo = type.GetMethod("Parser_Tlv"); + methodinfo.Invoke(tlvClass, new object[] { User, Reader }); } } } diff --git a/QQ.Framework/Packets/Send/Data/Send_0x0126.cs b/QQ.Framework/Packets/Send/Data/Send_0x0126.cs index cf31639..3fe9265 100644 --- a/QQ.Framework/Packets/Send/Data/Send_0x0126.cs +++ b/QQ.Framework/Packets/Send/Data/Send_0x0126.cs @@ -30,9 +30,9 @@ protected override void PutHeader() /// protected override void PutBody() { - BodyWriter.Write(new byte[] {0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03}); + BodyWriter.Write(new byte[] { 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03 }); BodyWriter.BeWrite(ToQQ); - BodyWriter.Write(new byte[] {0x69, 0x8e, 0x7e, 0x44, 0x3c, 0x11, 0xea, 0x7c}); + BodyWriter.Write(new byte[] { 0x69, 0x8e, 0x7e, 0x44, 0x3c, 0x11, 0xea, 0x7c }); } } } \ No newline at end of file diff --git a/QQ.Framework/Packets/Send/Data/Send_0x0134.cs b/QQ.Framework/Packets/Send/Data/Send_0x0134.cs index cd1176c..cfcefcf 100644 --- a/QQ.Framework/Packets/Send/Data/Send_0x0134.cs +++ b/QQ.Framework/Packets/Send/Data/Send_0x0134.cs @@ -32,7 +32,7 @@ protected override void PutBody() BodyWriter.BeWrite(Util.GetTimeSeconds(DateTime.Now)); BodyWriter.BeWrite(0x000003E8); BodyWriter.WriteKey(new byte[] - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); } } } \ No newline at end of file diff --git a/QQ.Framework/Packets/Send/Data/Send_0x0195.cs b/QQ.Framework/Packets/Send/Data/Send_0x0195.cs index 58854ab..4b59c93 100644 --- a/QQ.Framework/Packets/Send/Data/Send_0x0195.cs +++ b/QQ.Framework/Packets/Send/Data/Send_0x0195.cs @@ -25,7 +25,7 @@ protected override void PutHeader() /// protected override void PutBody() { - BodyWriter.Write(new byte[] {0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00}); + BodyWriter.Write(new byte[] { 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 }); } } } \ No newline at end of file diff --git a/QQ.Framework/Packets/Send/Data/Send_0x019B.cs b/QQ.Framework/Packets/Send/Data/Send_0x019B.cs index eca49f8..facde4f 100644 --- a/QQ.Framework/Packets/Send/Data/Send_0x019B.cs +++ b/QQ.Framework/Packets/Send/Data/Send_0x019B.cs @@ -25,7 +25,7 @@ protected override void PutHeader() /// protected override void PutBody() { - BodyWriter.Write(new byte[] {0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00}); + BodyWriter.Write(new byte[] { 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00 }); } } } \ No newline at end of file diff --git a/QQ.Framework/Packets/Send/Data/Send_0x01A5.cs b/QQ.Framework/Packets/Send/Data/Send_0x01A5.cs index 57b27b1..896ce14 100644 --- a/QQ.Framework/Packets/Send/Data/Send_0x01A5.cs +++ b/QQ.Framework/Packets/Send/Data/Send_0x01A5.cs @@ -25,7 +25,7 @@ protected override void PutHeader() /// protected override void PutBody() { - BodyWriter.Write(new byte[] {0x01, 0x00, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x00}); + BodyWriter.Write(new byte[] { 0x01, 0x00, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x00 }); } } } \ No newline at end of file diff --git a/QQ.Framework/Packets/Send/Data/Send_0x01C4.cs b/QQ.Framework/Packets/Send/Data/Send_0x01C4.cs index 6ff4903..42043a0 100644 --- a/QQ.Framework/Packets/Send/Data/Send_0x01C4.cs +++ b/QQ.Framework/Packets/Send/Data/Send_0x01C4.cs @@ -27,7 +27,7 @@ protected override void PutHeader() /// protected override void PutBody() { - BodyWriter.Write(new byte[] {0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00}); + BodyWriter.Write(new byte[] { 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00 }); var data = "{\"t1\":" + Util.GetTimeSeconds(DateTime.Now) + "}"; BodyWriter.WriteKey(Util.GetBytes(data)); } diff --git a/QQ.Framework/Packets/Send/Data/Send_0x01C5.cs b/QQ.Framework/Packets/Send/Data/Send_0x01C5.cs index a2c6a71..72d49eb 100644 --- a/QQ.Framework/Packets/Send/Data/Send_0x01C5.cs +++ b/QQ.Framework/Packets/Send/Data/Send_0x01C5.cs @@ -24,7 +24,7 @@ protected override void PutHeader() /// protected override void PutBody() { - BodyWriter.Write(new byte[] {0x00, 0x01, 0x00}); + BodyWriter.Write(new byte[] { 0x00, 0x01, 0x00 }); } } } \ No newline at end of file diff --git a/QQ.Framework/Packets/Send/Interactive/Send_0x00A8.cs b/QQ.Framework/Packets/Send/Interactive/Send_0x00A8.cs index ddf0d56..ebfcaf6 100644 --- a/QQ.Framework/Packets/Send/Interactive/Send_0x00A8.cs +++ b/QQ.Framework/Packets/Send/Interactive/Send_0x00A8.cs @@ -55,7 +55,7 @@ protected override void PutBody() BodyWriter.Write(User.AddFriend0020Value); } - BodyWriter.Write(new byte[] {0x10, 0x00}); + BodyWriter.Write(new byte[] { 0x10, 0x00 }); } else { @@ -70,7 +70,7 @@ protected override void PutBody() }); BodyWriter.BeWrite((ushort) User.AddFriend0020Value.Length); BodyWriter.Write(User.AddFriend0020Value); - BodyWriter.Write(new byte[] {0x10, 0x00}); + BodyWriter.Write(new byte[] { 0x10, 0x00 }); BodyWriter.BeWrite((ushort) Message.Length); BodyWriter.Write(Message); } diff --git a/QQ.Framework/Packets/Send/Login/Send_0x00BA.cs b/QQ.Framework/Packets/Send/Login/Send_0x00BA.cs index 50e1f0c..f9a0450 100644 --- a/QQ.Framework/Packets/Send/Login/Send_0x00BA.cs +++ b/QQ.Framework/Packets/Send/Login/Send_0x00BA.cs @@ -33,17 +33,17 @@ protected override void PutHeader() /// protected override void PutBody() { - BodyWriter.Write(new byte[] {0x00, 0x02, 0x00, 0x00, 0x08, 0x04, 0x01, 0xE0}); + BodyWriter.Write(new byte[] { 0x00, 0x02, 0x00, 0x00, 0x08, 0x04, 0x01, 0xE0 }); BodyWriter.BeWrite(User.TXProtocol.DwSsoVersion); BodyWriter.BeWrite(User.TXProtocol.DwServiceId); BodyWriter.BeWrite(User.TXProtocol.DwClientVer); BodyWriter.Write((byte) 0x00); BodyWriter.WriteKey(User.TXProtocol.BufSigClientAddr); - BodyWriter.Write(new byte[] {0x01, 0x02}); + BodyWriter.Write(new byte[] { 0x01, 0x02 }); BodyWriter.WriteKey(User.TXProtocol.BufDhPublicKey); if (string.IsNullOrEmpty(VerifyCode)) { - BodyWriter.Write(new byte[] {0x13, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00}); + BodyWriter.Write(new byte[] { 0x13, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.Write(User.QQPacket00BaSequence); if (User.TXProtocol.PngToken == null || User.TXProtocol.PngToken?.Length == 0) { @@ -57,7 +57,7 @@ protected override void PutBody() else { var verifyCodeBytes = Util.HexStringToByteArray(Util.ConvertStringToHex(VerifyCode)); - BodyWriter.Write(new byte[] {0x14, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00}); + BodyWriter.Write(new byte[] { 0x14, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00 }); BodyWriter.BeWrite((ushort) verifyCodeBytes.Length); BodyWriter.Write(verifyCodeBytes); BodyWriter.WriteKey(User.TXProtocol.BufSigPic); diff --git a/QQ.Framework/Packets/Send/Login/Send_0x00EC.cs b/QQ.Framework/Packets/Send/Login/Send_0x00EC.cs index b6c9337..2b94255 100644 --- a/QQ.Framework/Packets/Send/Login/Send_0x00EC.cs +++ b/QQ.Framework/Packets/Send/Login/Send_0x00EC.cs @@ -30,9 +30,9 @@ protected override void PutHeader() /// protected override void PutBody() { - BodyWriter.Write(new byte[] {0x01, 0x00}); + BodyWriter.Write(new byte[] { 0x01, 0x00 }); BodyWriter.Write(_loginStatus); - BodyWriter.Write(new byte[] {0x00, 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}); + BodyWriter.Write(new byte[] { 0x00, 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 }); } } } \ No newline at end of file diff --git a/QQ.Framework/Packets/Send/Login/Send_0x0828.cs b/QQ.Framework/Packets/Send/Login/Send_0x0828.cs index cb7d199..363aaaf 100644 --- a/QQ.Framework/Packets/Send/Login/Send_0x0828.cs +++ b/QQ.Framework/Packets/Send/Login/Send_0x0828.cs @@ -20,10 +20,10 @@ public Send_0X0828(QQUser user) protected override void PutHeader() { base.PutHeader(); - Writer.Write(new byte[] {0x02, 0x00, 0x00}); + Writer.Write(new byte[] { 0x02, 0x00, 0x00 }); Writer.Write(User.TXProtocol.DwClientType); Writer.Write(User.TXProtocol.DwPubNo); - Writer.Write(new byte[] {0x00, 0x30, 0x00, 0x3a}); + Writer.Write(new byte[] { 0x00, 0x30, 0x00, 0x3a }); Writer.WriteKey(User.TXProtocol.BufSigSession); } diff --git a/QQ.Framework/Packets/Send/Login/Send_0x0836.cs b/QQ.Framework/Packets/Send/Login/Send_0x0836.cs index ec55a0e..c913706 100644 --- a/QQ.Framework/Packets/Send/Login/Send_0x0836.cs +++ b/QQ.Framework/Packets/Send/Login/Send_0x0836.cs @@ -35,7 +35,7 @@ protected override void PutHeader() Writer.BeWrite(User.TXProtocol.EcdhVer); Writer.BeWrite((ushort) 0x19); Writer.Write(User.TXProtocol.BufDhPublicKey); - Writer.Write(new byte[] {0x00, 0x00, 0x00, 0x10}); + Writer.Write(new byte[] { 0x00, 0x00, 0x00, 0x10 }); Writer.Write(User.QQPacket0836Key1); } diff --git a/QQ.Framework/Packets/Send/Login/Send_0x0839.cs b/QQ.Framework/Packets/Send/Login/Send_0x0839.cs index 2acfe71..9f67a40 100644 --- a/QQ.Framework/Packets/Send/Login/Send_0x0839.cs +++ b/QQ.Framework/Packets/Send/Login/Send_0x0839.cs @@ -22,11 +22,11 @@ public Send_0X0839(QQUser user) protected override void PutHeader() { base.PutHeader(); - Writer.Write(new byte[] {0x03, 0x00, 0x00}); + Writer.Write(new byte[] { 0x03, 0x00, 0x00 }); Writer.Write(User.TXProtocol.DwClientType); Writer.Write(User.TXProtocol.DwPubNo); Writer.BeWrite(0); - Writer.Write(new byte[] {0x00, 0x30, 0x00, 0x3a}); + Writer.Write(new byte[] { 0x00, 0x30, 0x00, 0x3a }); Writer.WriteKey(User.TXProtocol.BufSigSession); } diff --git a/QQ.Framework/Packets/Send/Message/Send_0x0002.cs b/QQ.Framework/Packets/Send/Message/Send_0x0002.cs index e001b9a..eb419bf 100644 --- a/QQ.Framework/Packets/Send/Message/Send_0x0002.cs +++ b/QQ.Framework/Packets/Send/Message/Send_0x0002.cs @@ -93,11 +93,11 @@ protected override void PutBody() }); BodyWriter.BeWrite(dateTime); BodyWriter.Write(Util.RandomKey(4)); - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00}); - BodyWriter.Write(new byte[] {0x00, 0x0C}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 }); + BodyWriter.Write(new byte[] { 0x00, 0x0C }); BodyWriter.Write(new byte[] - {0xE5, 0xBE, 0xAE, 0xE8, 0xBD, 0xAF, 0xE9, 0x9B, 0x85, 0xE9, 0xBB, 0x91}); - BodyWriter.Write(new byte[] {0x00, 0x00}); + { 0xE5, 0xBE, 0xAE, 0xE8, 0xBD, 0xAF, 0xE9, 0x9B, 0x85, 0xE9, 0xBB, 0x91 }); + BodyWriter.Write(new byte[] { 0x00, 0x00 }); BodyWriter.Write(_data); break; } @@ -131,13 +131,13 @@ protected override void PutBody() }); BodyWriter.BeWrite(dateTime); BodyWriter.Write(Util.RandomKey(4)); - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 }); BodyWriter.Write(new byte[] - {0xE5, 0xBE, 0xAE, 0xE8, 0xBD, 0xAF, 0xE9, 0x9B, 0x85, 0xE9, 0xBB, 0x91}); - BodyWriter.Write(new byte[] {0x00, 0x00, 0x03, 0x00, 0xCB, 0x02}); - BodyWriter.Write(new byte[] {0x00, 0x2A}); + { 0xE5, 0xBE, 0xAE, 0xE8, 0xBD, 0xAF, 0xE9, 0x9B, 0x85, 0xE9, 0xBB, 0x91 }); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x03, 0x00, 0xCB, 0x02 }); + BodyWriter.Write(new byte[] { 0x00, 0x2A }); BodyWriter.Write(guid); - BodyWriter.Write(new byte[] {0x04, 0x00, 0x04}); + BodyWriter.Write(new byte[] { 0x04, 0x00, 0x04 }); BodyWriter.Write(new byte[] { 0x9B, 0x53, 0xB0, 0x08, 0x05, 0x00, 0x04, 0xD9, 0x8A, 0x5A, 0x70, 0x06, 0x00, @@ -166,28 +166,28 @@ protected override void PutBody() } case MessageType.AddGroup: { - BodyWriter.Write(new byte[] {0x08}); + BodyWriter.Write(new byte[] { 0x08 }); BodyWriter.BeWrite(group); - BodyWriter.Write(new byte[] {0x01}); + BodyWriter.Write(new byte[] { 0x01 }); BodyWriter.BeWrite((ushort) User.AddFriend0020Value.Length); BodyWriter.Write(User.AddFriend0020Value); - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00 }); //备注信息 var messageData = Encoding.UTF8.GetBytes(Message.Snippets[0].Content); Writer.BeWrite((ushort) messageData.Length); Writer.Write(messageData); - BodyWriter.Write(new byte[] {0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x09}); + BodyWriter.Write(new byte[] { 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x09 }); break; } case MessageType.GetGroupImformation: { - BodyWriter.Write(new byte[] {0x72}); + BodyWriter.Write(new byte[] { 0x72 }); BodyWriter.BeWrite(group); break; } case MessageType.ExitGroup: { - BodyWriter.Write(new byte[] {0x09}); + BodyWriter.Write(new byte[] { 0x09 }); BodyWriter.BeWrite(group); break; } diff --git a/QQ.Framework/Packets/Send/Message/Send_0x00CD.cs b/QQ.Framework/Packets/Send/Message/Send_0x00CD.cs index 6792d4e..ea0d88d 100644 --- a/QQ.Framework/Packets/Send/Message/Send_0x00CD.cs +++ b/QQ.Framework/Packets/Send/Message/Send_0x00CD.cs @@ -90,7 +90,7 @@ protected override void PutBody() BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(md5); - BodyWriter.Write(new byte[] {0x00, 0x0B}); + BodyWriter.Write(new byte[] { 0x00, 0x0B }); BodyWriter.Write(Util.RandomKey(2)); BodyWriter.BeWrite(dateTime); BodyWriter.Write(new byte[] @@ -102,10 +102,10 @@ protected override void PutBody() BodyWriter.BeWrite(dateTime); MessageId = Util.RandomKey(4); BodyWriter.Write(MessageId); - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00}); - BodyWriter.Write(new byte[] {0x00, 0x06}); - BodyWriter.Write(new byte[] {0xE5, 0xAE, 0x8B, 0xE4, 0xBD, 0x93}); - BodyWriter.Write(new byte[] {0x00, 0x00}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 }); + BodyWriter.Write(new byte[] { 0x00, 0x06 }); + BodyWriter.Write(new byte[] { 0xE5, 0xAE, 0x8B, 0xE4, 0xBD, 0x93 }); + BodyWriter.Write(new byte[] { 0x00, 0x00 }); BodyWriter.Write(_data); break; } @@ -113,13 +113,13 @@ protected override void PutBody() { BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x04}); - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00, 0x00}); - BodyWriter.Write(new byte[] {0x37, 0x0F}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x04 }); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00 }); + BodyWriter.Write(new byte[] { 0x37, 0x0F }); BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(md5); - BodyWriter.Write(new byte[] {0x00, 0x0B}); + BodyWriter.Write(new byte[] { 0x00, 0x0B }); BodyWriter.Write(Util.RandomKey(2)); BodyWriter.BeWrite(dateTime); BodyWriter.Write(new byte[] @@ -136,18 +136,18 @@ protected override void PutBody() { BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00, 0x00}); - BodyWriter.Write(new byte[] {0x37, 0x0F}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00 }); + BodyWriter.Write(new byte[] { 0x37, 0x0F }); BodyWriter.BeWrite(User.QQ); BodyWriter.BeWrite(_toQQ); BodyWriter.Write(Util.RandomKey()); - BodyWriter.Write(new byte[] {0x00, 0xAF}); + BodyWriter.Write(new byte[] { 0x00, 0xAF }); BodyWriter.Write(Util.RandomKey(2)); BodyWriter.BeWrite(dateTime); - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); MessageId = Util.RandomKey(4); BodyWriter.Write(MessageId); - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00, 0x00}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x00 }); break; } default: diff --git a/QQ.Framework/Packets/Send/Message/Send_0x0319.cs b/QQ.Framework/Packets/Send/Message/Send_0x0319.cs index 10b3c74..2bc0cd7 100644 --- a/QQ.Framework/Packets/Send/Message/Send_0x0319.cs +++ b/QQ.Framework/Packets/Send/Message/Send_0x0319.cs @@ -38,18 +38,18 @@ protected override void PutHeader() /// protected override void PutBody() { - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00, 0x07}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07 }); var data = new BinaryWriter(new MemoryStream()); - data.Write(new byte[] {0x0A, 0x0C, 0x08}); + data.Write(new byte[] { 0x0A, 0x0C, 0x08 }); data.Write(Util.HexStringToByteArray(Util.PB_toLength(_recvQQ))); data.Write((byte) 0x10); data.Write( Util.HexStringToByteArray( Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageTime).Replace(" ", ""), 16)))); - data.Write(new byte[] {0x20, 0x00}); + data.Write(new byte[] { 0x20, 0x00 }); //数据长度 BodyWriter.BeWrite(data.BaseStream.Length); - BodyWriter.Write(new byte[] {0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00}); + BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00 }); //数据 BodyWriter.Write(data.BaseStream.ToBytesArray()); } diff --git a/QQ.Framework/Packets/Send/Message/Send_0x0360.cs b/QQ.Framework/Packets/Send/Message/Send_0x0360.cs index 9cf0918..7405b8d 100644 --- a/QQ.Framework/Packets/Send/Message/Send_0x0360.cs +++ b/QQ.Framework/Packets/Send/Message/Send_0x0360.cs @@ -38,18 +38,18 @@ protected override void PutHeader() /// protected override void PutBody() { - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00, 0x07}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07 }); var data = new BinaryWriter(new MemoryStream()); - data.Write(new byte[] {0x03, 0x08, 0x03, 0x22, 0x46, 0x08}); + data.Write(new byte[] { 0x03, 0x08, 0x03, 0x22, 0x46, 0x08 }); data.Write(Util.HexStringToByteArray(Util.PB_toLength(_recvGroupQQ))); data.Write((byte) 0x10); data.Write( Util.HexStringToByteArray( Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageTime).Replace(" ", ""), 16)))); - data.Write(new byte[] {0x20, 0x00}); + data.Write(new byte[] { 0x20, 0x00 }); //数据长度 BodyWriter.BeWrite(data.BaseStream.Length); - BodyWriter.Write(new byte[] {0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00}); + BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00 }); //数据 BodyWriter.Write(data.BaseStream.ToBytesArray()); } diff --git a/QQ.Framework/Packets/Send/Message/Send_0x0391.cs b/QQ.Framework/Packets/Send/Message/Send_0x0391.cs index 52cc8b5..36bbd9d 100644 --- a/QQ.Framework/Packets/Send/Message/Send_0x0391.cs +++ b/QQ.Framework/Packets/Send/Message/Send_0x0391.cs @@ -6,20 +6,20 @@ namespace QQ.Framework.Packets.Send.Message { public class Send_0X0391 : SendPacket { - private long _groupQQ { get; set; } - private byte[] _messageIndex { get; set; } + private long GroupQQ { get; } + private byte[] MessageIndex { get; } /// /// /// - public Send_0X0391(QQUser user, long groupQQ, byte[] MessageIndex) + public Send_0X0391(QQUser user, long groupQQ, byte[] messageIndex) : base(user) { Sequence = GetNextSeq(); SecretKey = user.TXProtocol.SessionKey; Command = QQCommand.Message0X0391; - _groupQQ = groupQQ; - _messageIndex = MessageIndex; + GroupQQ = groupQQ; + this.MessageIndex = messageIndex; } protected override void PutHeader() @@ -39,18 +39,20 @@ protected override void PutBody() BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x0D }); var data = new BinaryWriter(new MemoryStream()); data.Write(new byte[] { 0x0A, 0x12, 0x08 }); - data.Write(Util.HexStringToByteArray(Util.PB_toLength(_groupQQ))); + data.Write(Util.HexStringToByteArray(Util.PB_toLength(GroupQQ))); data.Write(new byte[] { 0x12, 0x0a, 0x38, 0x00, 0x40, 0x00, 0x4a, 0x04, 0x08, 0x00, 0x10, 0x00 }); //数据长度 BodyWriter.BeWrite(data.BaseStream.Length); BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x09 }); - var data_12 = new BinaryWriter(new MemoryStream()); - data_12.Write(Util.HexStringToByteArray(Util.PB_toLength(Convert.ToInt64(Util.ToHex(_messageIndex).Replace(" ", ""), 16)))); - data_12.Write(new byte[] { 0x88, 0x01, 0x04, 0x98, 0x01, 0x00 }); + var data12 = new BinaryWriter(new MemoryStream()); + data12.Write( + Util.HexStringToByteArray( + Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageIndex).Replace(" ", ""), 16)))); + data12.Write(new byte[] { 0x88, 0x01, 0x04, 0x98, 0x01, 0x00 }); - BodyWriter.Write((byte)data_12.BaseStream.Length); - BodyWriter.Write(data_12.BaseStream.ToBytesArray()); + BodyWriter.Write((byte) data12.BaseStream.Length); + BodyWriter.Write(data12.BaseStream.ToBytesArray()); //数据 BodyWriter.Write(data.BaseStream.ToBytesArray()); diff --git a/QQ.Framework/Packets/Send/Message/Send_0x03E3.cs b/QQ.Framework/Packets/Send/Message/Send_0x03E3.cs index 470d338..22050e1 100644 --- a/QQ.Framework/Packets/Send/Message/Send_0x03E3.cs +++ b/QQ.Framework/Packets/Send/Message/Send_0x03E3.cs @@ -40,24 +40,24 @@ protected override void PutBody() { var myid = Util.HexStringToByteArray(Util.PB_toLength(User.QQ)); var id = Util.HexStringToByteArray(Util.PB_toLength(_toQQ)); - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(myid.Length + 11); - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00 }); BodyWriter.BeWrite(myid.Length + id.Length + 8); - BodyWriter.Write(new byte[] {0x08, 0x01}); - BodyWriter.Write(new byte[] {0x12}); + BodyWriter.Write(new byte[] { 0x08, 0x01 }); + BodyWriter.Write(new byte[] { 0x12 }); BodyWriter.BeWrite(myid.Length + 7); - BodyWriter.Write(new byte[] {0x08}); + BodyWriter.Write(new byte[] { 0x08 }); BodyWriter.Write(myid); - BodyWriter.Write(new byte[] {0x10, 0xE3, 0x07, 0x98, 0x01, 0x00}); - BodyWriter.Write(new byte[] {0x08, 0xE5, 0x0F}); - BodyWriter.Write(new byte[] {0x10, 0x01}); - BodyWriter.Write(new byte[] {0x22}); + BodyWriter.Write(new byte[] { 0x10, 0xE3, 0x07, 0x98, 0x01, 0x00 }); + BodyWriter.Write(new byte[] { 0x08, 0xE5, 0x0F }); + BodyWriter.Write(new byte[] { 0x10, 0x01 }); + BodyWriter.Write(new byte[] { 0x22 }); BodyWriter.BeWrite(id.Length + 6); - BodyWriter.Write(new byte[] {0x58}); + BodyWriter.Write(new byte[] { 0x58 }); BodyWriter.Write(id); - BodyWriter.Write(new byte[] {0x60, 0x92, 0x4E}); - BodyWriter.Write(new byte[] {0x68, 0x01}); + BodyWriter.Write(new byte[] { 0x60, 0x92, 0x4E }); + BodyWriter.Write(new byte[] { 0x68, 0x01 }); } } } \ No newline at end of file diff --git a/QQ.Framework/Packets/Send/Message/Send_0x03F7.cs b/QQ.Framework/Packets/Send/Message/Send_0x03F7.cs index 150964f..ab19dae 100644 --- a/QQ.Framework/Packets/Send/Message/Send_0x03F7.cs +++ b/QQ.Framework/Packets/Send/Message/Send_0x03F7.cs @@ -6,7 +6,7 @@ namespace QQ.Framework.Packets.Send.Message { public class Send_0X03F7 : SendPacket { - private readonly long _GroupId; + private readonly long _groupId; private readonly char _msgSequence; private readonly byte[] _messageId; private readonly byte[] _messageIndex; @@ -15,24 +15,24 @@ public class Send_0X03F7 : SendPacket /// 撤回群消息 /// /// - public Send_0X03F7(QQUser user, long GroupId, byte[] MessageId, byte[] MessageIndex) + public Send_0X03F7(QQUser user, long groupId, byte[] messageId, byte[] messageIndex) : base(user) { Sequence = GetNextSeq(); SecretKey = user.TXProtocol.SessionKey; Command = QQCommand.Message0X03F7; - _GroupId = GroupId; - _messageId = MessageId; - _messageIndex = MessageIndex; + _groupId = groupId; + _messageId = messageId; + _messageIndex = messageIndex; } protected override void PutHeader() { base.PutHeader(); - Writer.Write(new byte[] {0x04, 0x00, 0x00}); + Writer.Write(new byte[] { 0x04, 0x00, 0x00 }); Writer.Write(User.TXProtocol.DwClientType); Writer.Write(User.TXProtocol.DwPubNo); - Writer.Write(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); + Writer.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); } /// @@ -40,37 +40,37 @@ protected override void PutHeader() /// protected override void PutBody() { - var PbGroupId = Util.HexStringToByteArray(Util.PB_toLength(_GroupId)); - var PbMessageId = + var pbGroupId = Util.HexStringToByteArray(Util.PB_toLength(_groupId)); + var pbMessageId = Util.HexStringToByteArray( Util.PB_toLength(Convert.ToInt64(Util.ToHex(_messageId).Replace(" ", ""), 16))); - var PbMessageIndex = + var pbMessageIndex = Util.HexStringToByteArray( Util.PB_toLength(Convert.ToInt64(Util.ToHex(_messageIndex).Replace(" ", ""), 16))); - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00, 0x07}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07 }); var data = new BinaryWriter(new MemoryStream()); - data.Write(new byte[] {0x08, 0x01, 0x10, 0x00, 0x18}); - data.Write(PbGroupId); - data.Write(new byte[] {0x22, 0x09, 0x08}); - data.Write(PbMessageIndex); //消息索引 + data.Write(new byte[] { 0x08, 0x01, 0x10, 0x00, 0x18 }); + data.Write(pbGroupId); + data.Write(new byte[] { 0x22, 0x09, 0x08 }); + data.Write(pbMessageIndex); //消息索引 data.Write((byte) 0x10); - data.Write(PbMessageId); //消息Id - var data_2a = new BinaryWriter(new MemoryStream()); - data_2a.Write(new byte[] {0x08, 0x00}); - var data_12 = new BinaryWriter(new MemoryStream()); - data_12.Write((byte) 0x08); - data_12.Write(PbMessageIndex); //消息索引 - data_12.Write((byte) 0x10); - data_12.Write(new byte[] {0x00, 0x18, 0x01, 0x20, 0x00}); - data_2a.Write((byte) 0x12); - data_2a.Write((byte) data_12.BaseStream.Length); - data_2a.Write(data_12.BaseStream.ToBytesArray()); + data.Write(pbMessageId); //消息Id + var data_2A = new BinaryWriter(new MemoryStream()); + data_2A.Write(new byte[] { 0x08, 0x00 }); + var data12 = new BinaryWriter(new MemoryStream()); + data12.Write((byte) 0x08); + data12.Write(pbMessageIndex); //消息索引 + data12.Write((byte) 0x10); + data12.Write(new byte[] { 0x00, 0x18, 0x01, 0x20, 0x00 }); + data_2A.Write((byte) 0x12); + data_2A.Write((byte) data12.BaseStream.Length); + data_2A.Write(data12.BaseStream.ToBytesArray()); data.Write((byte) 0x2a); - data.Write((byte) data_2a.BaseStream.Length); - data.Write(data_2a.BaseStream.ToBytesArray()); + data.Write((byte) data_2A.BaseStream.Length); + data.Write(data_2A.BaseStream.ToBytesArray()); //数据长度 BodyWriter.BeWrite(data.BaseStream.Length); - BodyWriter.Write(new byte[] {0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00}); + BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00 }); //数据 BodyWriter.Write(data.BaseStream.ToBytesArray()); } diff --git a/QQ.Framework/Packets/Send/Message/Send_0x03FC.cs b/QQ.Framework/Packets/Send/Message/Send_0x03FC.cs index 0c4a93c..c1a036b 100644 --- a/QQ.Framework/Packets/Send/Message/Send_0x03FC.cs +++ b/QQ.Framework/Packets/Send/Message/Send_0x03FC.cs @@ -12,7 +12,7 @@ public class Send_0X03FC : SendPacket /// /// /// - public Send_0X03FC(QQUser user, long recvQQ, byte[] messageTime, char msgSequence, byte[] MessageId) + public Send_0X03FC(QQUser user, long recvQQ, byte[] messageTime, char msgSequence, byte[] messageId) : base(user) { Sequence = GetNextSeq(); @@ -21,19 +21,19 @@ public Send_0X03FC(QQUser user, long recvQQ, byte[] messageTime, char msgSequenc _recvQQ = recvQQ; MessageTime = messageTime; _msgSequence = msgSequence; - _messageId = MessageId; + MessageId = messageId; } private byte[] MessageTime { get; } - private byte[] _messageId { get; } + private byte[] MessageId { get; } protected override void PutHeader() { base.PutHeader(); - Writer.Write(new byte[] {0x04, 0x00, 0x00}); + Writer.Write(new byte[] { 0x04, 0x00, 0x00 }); Writer.Write(User.TXProtocol.DwClientType); Writer.Write(User.TXProtocol.DwPubNo); - Writer.Write(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); + Writer.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }); } /// @@ -41,31 +41,31 @@ protected override void PutHeader() /// protected override void PutBody() { - BodyWriter.Write(new byte[] {0x00, 0x00, 0x00, 0x07}); + BodyWriter.Write(new byte[] { 0x00, 0x00, 0x00, 0x07 }); var data = new BinaryWriter(new MemoryStream()); - var data_0a = new BinaryWriter(new MemoryStream()); - data_0a.Write((byte) 0x08); - data_0a.Write(Util.HexStringToByteArray(Util.PB_toLength(User.QQ))); - data_0a.Write((byte) 0x10); - data_0a.Write(Util.HexStringToByteArray(Util.PB_toLength(_recvQQ))); - data_0a.Write((byte) 0x18); - data_0a.Write(Util.HexStringToByteArray(Util.PB_toLength(_msgSequence))); //消息包序 - data_0a.Write((byte) 0x28); - data_0a.Write( + var data_0A = new BinaryWriter(new MemoryStream()); + data_0A.Write((byte) 0x08); + data_0A.Write(Util.HexStringToByteArray(Util.PB_toLength(User.QQ))); + data_0A.Write((byte) 0x10); + data_0A.Write(Util.HexStringToByteArray(Util.PB_toLength(_recvQQ))); + data_0A.Write((byte) 0x18); + data_0A.Write(Util.HexStringToByteArray(Util.PB_toLength(_msgSequence))); //消息包序 + data_0A.Write((byte) 0x28); + data_0A.Write( Util.HexStringToByteArray( Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageTime).Replace(" ", ""), 16)))); - data_0a.Write(new byte[] {0x30}); - data_0a.Write( + data_0A.Write(new byte[] { 0x30 }); + data_0A.Write( Util.HexStringToByteArray( - Util.PB_toLength(Convert.ToInt64(Util.ToHex(_messageId).Replace(" ", ""), 16)))); //消息Id - data_0a.Write(new byte[] {0x38, 0x01, 0x40, 0x00, 0x48, 0x00}); + Util.PB_toLength(Convert.ToInt64(Util.ToHex(MessageId).Replace(" ", ""), 16)))); //消息Id + data_0A.Write(new byte[] { 0x38, 0x01, 0x40, 0x00, 0x48, 0x00 }); data.Write((byte) 0x0A); - data.Write((byte) data_0a.BaseStream.Length); //length - data.Write(data_0a.BaseStream.ToBytesArray()); - data.Write(new byte[] {0x10, 0x01, 0x18, 0x01, 0x20, 0x00, 0x2a, 0x04, 0x08, 0x00, 0x10, 0x00}); + data.Write((byte) data_0A.BaseStream.Length); //length + data.Write(data_0A.BaseStream.ToBytesArray()); + data.Write(new byte[] { 0x10, 0x01, 0x18, 0x01, 0x20, 0x00, 0x2a, 0x04, 0x08, 0x00, 0x10, 0x00 }); //数据长度 BodyWriter.BeWrite(data.BaseStream.Length); - BodyWriter.Write(new byte[] {0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00}); + BodyWriter.Write(new byte[] { 0x08, 0x01, 0x12, 0x03, 0x98, 0x01, 0x00 }); //数据 BodyWriter.Write(data.BaseStream.ToBytesArray()); } diff --git a/QQ.Framework/Packets/SendPacket.cs b/QQ.Framework/Packets/SendPacket.cs index c9ec67b..65ea854 100644 --- a/QQ.Framework/Packets/SendPacket.cs +++ b/QQ.Framework/Packets/SendPacket.cs @@ -188,11 +188,11 @@ public static byte[] ConstructMessage(string message) } //表情 - bw.Write(new byte[] {0x02, 0x00, 0x14, 0x01, 0x00, 0x01}); + bw.Write(new byte[] { 0x02, 0x00, 0x14, 0x01, 0x00, 0x01 }); bw.Write(faceIndex); - bw.Write(new byte[] {0xFF, 0x00, 0x02, 0x14}); + bw.Write(new byte[] { 0xFF, 0x00, 0x02, 0x14 }); bw.Write((byte) (faceIndex + 65)); - bw.Write(new byte[] {0x0B, 0x00, 0x08, 0x00, 0x01, 0x00, 0x04, 0x52, 0xCC, 0x85, 0x50}); + bw.Write(new byte[] { 0x0B, 0x00, 0x08, 0x00, 0x01, 0x00, 0x04, 0x52, 0xCC, 0x85, 0x50 }); } else if (!string.IsNullOrEmpty(group)) { @@ -215,9 +215,9 @@ public static byte[] ConstructMessage(string message) [Obsolete("请使用BinaryWriter.Write(Richtext)方法。")] public static void ConstructMessage(BinaryWriter writer, byte[] groupMsg) { - writer.Write(new byte[] {0x01}); + writer.Write(new byte[] { 0x01 }); writer.BeWrite((ushort) (groupMsg.Length + 3)); - writer.Write(new byte[] {0x01}); + writer.Write(new byte[] { 0x01 }); writer.BeWrite((ushort) groupMsg.Length); writer.Write(groupMsg); } @@ -240,16 +240,16 @@ public static byte[] SendXml(byte[] compressMsg) { var bw = new BinaryWriter(new MemoryStream()); bw.Write(Util.RandomKey(4)); - bw.Write(new byte[] {0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00}); - bw.Write(new byte[] {0x00, 0x0C}); - bw.Write(new byte[] {0xE5, 0xBE, 0xAE, 0xE8, 0xBD, 0xAF, 0xE9, 0x9B, 0x85, 0xE9, 0xBB, 0x91}); - bw.Write(new byte[] {0x00, 0x00, 0x14}); + bw.Write(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x86, 0x00 }); + bw.Write(new byte[] { 0x00, 0x0C }); + bw.Write(new byte[] { 0xE5, 0xBE, 0xAE, 0xE8, 0xBD, 0xAF, 0xE9, 0x9B, 0x85, 0xE9, 0xBB, 0x91 }); + bw.Write(new byte[] { 0x00, 0x00, 0x14 }); bw.BeWrite((ushort) (compressMsg.Length + 11)); bw.Write((byte) 0x01); bw.BeWrite((ushort) (compressMsg.Length + 1)); bw.Write((byte) 0x01); bw.Write(compressMsg); - bw.Write(new byte[] {0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x4D}); + bw.Write(new byte[] { 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x4D }); return bw.BaseStream.ToBytesArray(); } diff --git a/QQ.Framework/QQ.Framework.csproj b/QQ.Framework/QQ.Framework.csproj index 3464e40..542eb0e 100644 --- a/QQ.Framework/QQ.Framework.csproj +++ b/QQ.Framework/QQ.Framework.csproj @@ -218,7 +218,6 @@ - @@ -228,7 +227,6 @@ - @@ -253,6 +251,9 @@ 11.0.2 + + 4.5.0 + \ No newline at end of file diff --git a/QQ.Framework/QQGlobal.cs b/QQ.Framework/QQGlobal.cs index 049877f..7bcc5a1 100644 --- a/QQ.Framework/QQGlobal.cs +++ b/QQ.Framework/QQGlobal.cs @@ -148,7 +148,7 @@ public static class QQGlobal public static bool DebugLog = true; public static byte[] QqexeMD5 { get; set; } = - {0xfa, 0xcf, 0x7c, 0xc5, 0xae, 0x02, 0xe6, 0x65, 0x0c, 0x01, 0x07, 0xcd, 0xfe, 0x0e, 0x1b, 0x2c}; + { 0xfa, 0xcf, 0x7c, 0xc5, 0xae, 0x02, 0xe6, 0x65, 0x0c, 0x01, 0x07, 0xcd, 0xfe, 0x0e, 0x1b, 0x2c }; } /// @@ -375,7 +375,7 @@ public enum QQCommand : ushort /// /// 消息撤回 /// - Message0X03FC = 0x03FC, + Message0X03FC = 0X03FC, /// /// 发送好友消息 diff --git a/QQ.Framework/QQUser.cs b/QQ.Framework/QQUser.cs index 55cb255..57bf338 100644 --- a/QQ.Framework/QQUser.cs +++ b/QQ.Framework/QQUser.cs @@ -15,7 +15,7 @@ namespace QQ.Framework { public class QQUser { - private readonly string UA = + private readonly string _ua = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36"; public QQUser(long qqNum, string pwd) @@ -158,7 +158,7 @@ public bool GetCookies() // QQ, Util.ToHex(TXProtocol.ClientKey, "", "{0}"), Util.GetTimeMillis(DateTime.Now)); var address = $"https://ssl.ptlogin2.qq.com/jump?pt_clientver=5593&pt_src=1&keyindex=9&ptlang=2052&clientuin={QQ}&clientkey={Util.ToHex(TXProtocol.BufServiceTicketHttp, "", "{0}")}&u1=https:%2F%2Fuser.qzone.qq.com%2F417085811%3FADUIN=417085811%26ADSESSION={Util.GetTimeMillis(DateTime.Now)}%26ADTAG=CLIENT.QQ.5593_MyTip.0%26ADPUBNO=26841&source=namecardhoverstar"; - httpWebClient.Headers["User-Agent"] = UA; + httpWebClient.Headers["User-Agent"] = _ua; var text = Encoding.UTF8.GetString(httpWebClient.DownloadData(address)); QQCookies = httpWebClient.Cookies; var cookies = QQCookies.GetCookies(new Uri("http://qq.com")); @@ -193,7 +193,7 @@ public bool GetQunCookies() "https://ssl.ptlogin2.qq.com/jump?pt_clientver=5509&pt_src=1&keyindex=9&clientuin={0}&clientkey={1}&u1=http%3A%2F%2Fqun.qq.com%2Fmember.html%23gid%3D168209441", QQ, Util.ToHex(TXProtocol.BufServiceTicketHttp /*QunKey*/, "", "{0}"), Util.GetTimeMillis(DateTime.Now)); - httpWebClient.Headers["User-Agent"] = UA; + httpWebClient.Headers["User-Agent"] = _ua; var result = Encoding.UTF8.GetString(httpWebClient.DownloadData(address)); QunCookies = httpWebClient.Cookies; var cookies = QunCookies.GetCookies(new Uri("http://qun.qq.com")); @@ -221,19 +221,19 @@ public bool GetQunCookies() return false; } - public GroupMembers Search_Group_Members(long ExternalId) + public GroupMembers Search_Group_Members(long externalId) { try { using (var httpWebClient = new HttpWebClient()) { var address = "https://qun.qq.com/cgi-bin/qun_mgr/search_group_members"; - var s = $"gc={ExternalId}&st=0&end=10000&sort=0&bkn={Bkn}"; + var s = $"gc={externalId}&st=0&end=10000&sort=0&bkn={Bkn}"; httpWebClient.Headers["Accept"] = "application/json, text/javascript, */*; q=0.01"; httpWebClient.Headers["Referer"] = "http://qun.qq.com/member.html"; httpWebClient.Headers["X-Requested-With"] = "XMLHttpRequest"; httpWebClient.Headers.Add("Cache-Control: no-cache"); - httpWebClient.Headers["User-Agent"] = UA; + httpWebClient.Headers["User-Agent"] = _ua; httpWebClient.Cookies = QunCookies; var text = Encoding.UTF8.GetString(httpWebClient.UploadData(address, "POST", Encoding.UTF8.GetBytes(s))); @@ -245,25 +245,25 @@ public GroupMembers Search_Group_Members(long ExternalId) { var str = ((Capture) match).Value.Split(':'); var r2 = new Regex("\"[0-9]+\""); - var Level = r2.Matches(str[0])[0].Value; + var level = r2.Matches(str[0])[0].Value; var r3 = new Regex("\"[^\"]+\""); - var Name = r3.Matches(str[1])[0].Value; - var DataItem = "{\"level\":" + Level + ",\"name\":" + Name + "}"; + var name = r3.Matches(str[1])[0].Value; + var dataItem = "{\"level\":" + level + ",\"name\":" + name + "}"; - text = text.Replace(((Capture) match).Value, DataItem); + text = text.Replace(((Capture) match).Value, dataItem); } text = text.Replace("\"levelname\":{", "\"levelname\":[") .Replace("},\"max_count\"", "],\"max_count\""); } - MessageLog($"获取群{ExternalId}成员列表成功:{text}"); + MessageLog($"获取群{externalId}成员列表成功:{text}"); return JsonConvert.DeserializeObject(text); } } catch (Exception ex) { - MessageLog($"获取群{ExternalId}成员列表失败:{ex.Message}"); + MessageLog($"获取群{externalId}成员列表失败:{ex.Message}"); } return null; @@ -281,39 +281,39 @@ public GroupList Get_Group_List() httpWebClient.Headers["Referer"] = "http://qun.qq.com/member.html"; httpWebClient.Headers["X-Requested-With"] = "XMLHttpRequest"; httpWebClient.Headers.Add("Cache-Control: no-cache"); - httpWebClient.Headers["User-Agent"] = UA; + httpWebClient.Headers["User-Agent"] = _ua; httpWebClient.Cookies = QunCookies; var text = Encoding.UTF8.GetString(httpWebClient.UploadData(address, "POST", Encoding.UTF8.GetBytes(s))); MessageLog("获取群列表成功:" + text); - var Groups = JsonConvert.DeserializeObject(text); - if (Groups.Create != null) + var groups = JsonConvert.DeserializeObject(text); + if (groups.Create != null) { - foreach (var item in Groups.Create) + foreach (var item in groups.Create) { item.Members = Search_Group_Members((long) item.Gc); } } - if (Groups.Join != null) + if (groups.Join != null) { - foreach (var item in Groups.Join) + foreach (var item in groups.Join) { item.Members = Search_Group_Members((long) item.Gc); } } - if (Groups.Manage != null) + if (groups.Manage != null) { - foreach (var item in Groups.Manage) + foreach (var item in groups.Manage) { item.Members = Search_Group_Members((long) item.Gc); } } - return Groups; + return groups; } } catch (Exception ex) @@ -335,7 +335,7 @@ public FriendList Get_Friend_List() httpWebClient.Headers["Accept"] = "application/json, text/javascript, */*; q=0.01"; httpWebClient.Headers["Referer"] = "http://qun.qq.com/member.html"; httpWebClient.Headers["X-Requested-With"] = "XMLHttpRequest"; - httpWebClient.Headers["User-Agent"] = UA; + httpWebClient.Headers["User-Agent"] = _ua; httpWebClient.Headers.Add("Cache-Control: no-cache"); httpWebClient.Cookies = QunCookies; var text = Encoding.UTF8.GetString(httpWebClient.UploadData(address, "POST", @@ -401,21 +401,22 @@ public byte[] Md52() #endregion /// - /// 好友发送消息合集 + /// 好友发送消息合集 /// public List FriendSendMessages { get; set; } = new List(); + /// - /// 群发送消息合集 + /// 群发送消息合集 /// public List GroupSendMessages { get; set; } = new List(); /// - /// 好友接收消息合集 + /// 好友接收消息合集 /// public List FriendReceiveMessages { get; set; } = new List(); /// - /// 群接收消息合集 + /// 群接收消息合集 /// public List GroupReceiveMessages { get; set; } = new List(); } diff --git a/QQ.Framework/TXProtocol.cs b/QQ.Framework/TXProtocol.cs index 2c52699..41927c7 100644 --- a/QQ.Framework/TXProtocol.cs +++ b/QQ.Framework/TXProtocol.cs @@ -14,11 +14,11 @@ public class TXProtocol //public byte[] bufComputerIDEx { get; set; } = Util.RandomKey(); public byte[] BufComputerId { get; set; } = - {0x43, 0x04, 0x21, 0x7D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + { 0x43, 0x04, 0x21, 0x7D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; //public byte[] bufComputerID { get; set; } = Util.RandomKey(); public byte[] BufComputerIdEx { get; set; } = - {0x77, 0x98, 0x00, 0x0B, 0xAB, 0x5D, 0x4F, 0x3D, 0x30, 0x50, 0x65, 0x2C, 0x4A, 0x2A, 0xF8, 0x65}; + { 0x77, 0x98, 0x00, 0x0B, 0xAB, 0x5D, 0x4F, 0x3D, 0x30, 0x50, 0x65, 0x2C, 0x4A, 0x2A, 0xF8, 0x65 }; public byte[] BufDeviceId { get; set; } = { @@ -57,7 +57,7 @@ public class TXProtocol //public byte[] bufMacGuid { get; set; } = Util.RandomKey(); public byte[] BufMacGuid { get; set; } = - {0x21, 0x4B, 0x1A, 0x04, 0x09, 0xED, 0x19, 0x70, 0x98, 0x75, 0x51, 0xBB, 0x2D, 0x3A, 0x7E, 0x0A}; + { 0x21, 0x4B, 0x1A, 0x04, 0x09, 0xED, 0x19, 0x70, 0x98, 0x75, 0x51, 0xBB, 0x2D, 0x3A, 0x7E, 0x0A }; #region 用户相关 @@ -91,20 +91,20 @@ public class TXProtocol /// /// Array /// - public byte[] XxooA = {0x03, 0x00, 0x00}; + public byte[] XxooA = { 0x03, 0x00, 0x00 }; - public byte[] XxooD = {0x30, 0x00, 0x00, 0x00}; + public byte[] XxooD = { 0x30, 0x00, 0x00, 0x00 }; public byte XxooB = 0x01; /// /// 客户端类型 /// - public byte[] DwClientType = {0x00, 0x01, 0x01, 0x01}; + public byte[] DwClientType = { 0x00, 0x01, 0x01, 0x01 }; /// /// 发行版本号 /// - public byte[] DwPubNo = {0x00, 0x00, 0x68, 0x1C}; + public byte[] DwPubNo = { 0x00, 0x00, 0x68, 0x1C }; #region QdData 相关参数 @@ -128,21 +128,21 @@ public class TXProtocol /// /// TSSafeEdit.dat的"文件版本" /// - public byte[] BufVersionTsSafeEditDat = {0x07, 0xdf, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x01}; + public byte[] BufVersionTsSafeEditDat = { 0x07, 0xdf, 0x00, 0x0a, 0x00, 0x0c, 0x00, 0x01 }; /// /// QScanEngine.dll的"文件版本" /// - public byte[] BufVersionQScanEngineDll = {0x00, 0x04, 0x00, 0x03, 0x00, 0x04, 0x20, 0x5c}; + public byte[] BufVersionQScanEngineDll = { 0x00, 0x04, 0x00, 0x03, 0x00, 0x04, 0x20, 0x5c }; - public byte[] QdSufFix = {0x68}; - public byte[] QdPreFix = {0x3E}; + public byte[] QdSufFix = { 0x68 }; + public byte[] QdPreFix = { 0x3E }; /// /// wE7^3img#i)%h12] /// public byte[] BufQdKey = - {0x77, 0x45, 0x37, 0x5e, 0x33, 0x69, 0x6d, 0x67, 0x23, 0x69, 0x29, 0x25, 0x68, 0x31, 0x32, 0x5d}; + { 0x77, 0x45, 0x37, 0x5e, 0x33, 0x69, 0x6d, 0x67, 0x23, 0x69, 0x29, 0x25, 0x68, 0x31, 0x32, 0x5d }; #endregion @@ -167,7 +167,7 @@ public class TXProtocol public long TimeDifference { get; set; } public byte[] BufSid { get; set; } = - {0x1E, 0xC1, 0x25, 0x71, 0xB2, 0x4C, 0xEA, 0x91, 0x9A, 0x6E, 0x8D, 0xE6, 0x95, 0x4E, 0xCE, 0x06}; + { 0x1E, 0xC1, 0x25, 0x71, 0xB2, 0x4C, 0xEA, 0x91, 0x9A, 0x6E, 0x8D, 0xE6, 0x95, 0x4E, 0xCE, 0x06 }; //public byte[] bufSID { get; set; } = Util.RandomKey(); public byte[] QqexeMD5 { get; set; } diff --git a/QQ.Framework/Utils/AtSnippet.cs b/QQ.Framework/Utils/AtSnippet.cs deleted file mode 100644 index c90460e..0000000 --- a/QQ.Framework/Utils/AtSnippet.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace QQ.Framework.Utils -{ - public class AtSnippet : TextSnippet - { - public ulong AtQQ { get; set; } - } -} \ No newline at end of file diff --git a/QQ.Framework/Utils/QdData.cs b/QQ.Framework/Utils/QdData.cs index 1b3abcc..244e9e3 100644 --- a/QQ.Framework/Utils/QdData.cs +++ b/QQ.Framework/Utils/QdData.cs @@ -24,7 +24,7 @@ public static byte[] GetQdData(QQUser user) data.Write((byte) 0); data.BeWrite(user.TXProtocol.WQdCsCmdNo); data.Write(user.TXProtocol.CQdCcSubNo); - data.Write(new byte[] {0x0E, 0x88}); //xrand(0xFFFF) + 1 + data.Write(new byte[] { 0x0E, 0x88 }); //xrand(0xFFFF) + 1 data.BeWrite(0); //四个0 data.Write(user.TXProtocol.BufComputerIdEx); data.Write(user.TXProtocol.COsType); diff --git a/QQ.Framework/Utils/RedBagSnippet.cs b/QQ.Framework/Utils/RedBagSnippet.cs deleted file mode 100644 index a38c735..0000000 --- a/QQ.Framework/Utils/RedBagSnippet.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace QQ.Framework.Utils -{ - public class RedBagSnippet : TextSnippet - { - public string RedId { get; set; } - - public string Key1 { get; set; } - - public string Key2 { get; set; } - } -} \ No newline at end of file diff --git a/QQ.Framework/Utils/Richtext.cs b/QQ.Framework/Utils/Richtext.cs index 8f95df1..c6c01d7 100644 --- a/QQ.Framework/Utils/Richtext.cs +++ b/QQ.Framework/Utils/Richtext.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; @@ -10,20 +11,121 @@ public class Richtext public List Snippets = new List(); public int Length => Snippets.Sum(s => s.Length); - public static Richtext Parse(byte[] message) + public static Richtext Parse(BinaryReader reader) { + var result = new Richtext(); // TODO: 解析富文本 - return Encoding.UTF8.GetString(message); + try + { + var messageType = reader.ReadByte(); + var dataLength = reader.BeReadChar(); + while (reader.BaseStream.Position + dataLength < reader.BaseStream.Length) + { + reader.ReadByte(); + switch (messageType) + { + case 0x01: //文本消息 + { + var messageStr = Encoding.UTF8.GetString(reader.ReadBytes(reader.BeReadChar())); + if (messageStr.Contains("@")) + { + //Reader.ReadBytes(10); + //var AtQQ = Util.GetQQNumRetUint(Util.ToHex(Reader.ReadBytes(4)));//被At人的QQ号 + result.Snippets.Add(new TextSnippet(messageStr, MessageType.At)); + } + else + { + result.Snippets.Add(messageStr); + } + + break; + } + + case 0x02: //小黄豆表情 + { + result.Snippets.Add(new TextSnippet( + Util.GetQQNumRetUint(Util.ToHex(reader.ReadBytes(reader.BeReadChar()))).ToString(), + MessageType.Emoji)); + break; + } + case 0x03: //图片 + { + result.Snippets.Add(new TextSnippet( + Encoding.UTF8.GetString(reader.ReadBytes(reader.BeReadChar())), MessageType.Picture)); + break; + } + case 0x0A: //音频 + { + result.Snippets.Add(new TextSnippet(Encoding.UTF8.GetString(reader.ReadBytes(reader.BeReadChar())), MessageType.Audio)); + break; + } + case 0x0E: //未知 + { + break; + } + case 0x14: //XML + { + reader.ReadByte(); + result.Snippets.Add(new TextSnippet( GZipByteArray.DecompressString(reader.ReadBytes((int) (reader.BaseStream.Length - 1))), MessageType.Xml)); + break; + } + case 0x18: //群文件 + { + reader.ReadBytes(3); + var fileName = reader.ReadBytes(reader.ReadByte()); //文件名称 + reader.ReadByte(); + reader.ReadBytes(reader.ReadByte()); //文件大小 + result.Snippets.Add(new TextSnippet(Encoding.UTF8.GetString(fileName), + MessageType.OfflineFile)); + break; + } + case 0x19: //红包秘钥段 + { + if (reader.ReadByte() != 0xC2) + { + break; + } + reader.ReadBytes(19); + reader.ReadBytes(reader.ReadByte()); //恭喜发财 + reader.ReadByte(); + reader.ReadBytes(reader.ReadByte()); //赶紧点击拆开吧 + reader.ReadByte(); + reader.ReadBytes(reader.ReadByte()); //QQ红包 + reader.ReadBytes(5); + reader.ReadBytes(reader.ReadByte()); //[QQ红包]恭喜发财 + reader.ReadBytes(22); + var redId = Encoding.UTF8.GetString(reader.ReadBytes(32)); //redid + reader.ReadBytes(12); + reader.ReadBytes(reader.BeReadChar()); + reader.ReadBytes(0x10); + var key1 = Encoding.UTF8.GetString(reader.ReadBytes(reader.ReadByte())); //Key1 + reader.BeReadChar(); + var key2 = Encoding.UTF8.GetString(reader.ReadBytes(reader.ReadByte())); //Key2 + result.Snippets.Add(new TextSnippet("", MessageType.RedBag, ("RedId", redId), + ("Key1", key1), ("Key2", key2))); + break; + } + } + + messageType = reader.ReadByte(); + dataLength = reader.BeReadChar(); + } + } + catch (Exception ex) + { + } + + return result; } public static Richtext FromLiteral(string message) { - return new Richtext {Snippets = new List {new TextSnippet(message ?? "")}}; + return new Richtext { Snippets = new List { new TextSnippet(message ?? "") } }; } public static Richtext FromSnippets(params TextSnippet[] message) { - return new Richtext {Snippets = message.ToList()}; + return new Richtext { Snippets = message.ToList() }; } public override string ToString() @@ -51,11 +153,27 @@ public class TextSnippet { public string Content; public MessageType Type; + private Dictionary _data; - public TextSnippet(string message = "", MessageType type = MessageType.Normal) + public T Get(string name, T value = default(T)) + { + return (T) _data[name]; + } + + public void Set(string name, T value) + { + _data[name] = value; + } + + public TextSnippet(string message = "", MessageType type = MessageType.Normal, + params (string name, object value)[] data) { Content = message; Type = type; + foreach (var valueTuple in data) + { + Set(valueTuple.name, valueTuple.value); + } } public int Length diff --git a/QQ.Framework/Utils/Util.cs b/QQ.Framework/Utils/Util.cs index 3b2c713..e9007be 100644 --- a/QQ.Framework/Utils/Util.cs +++ b/QQ.Framework/Utils/Util.cs @@ -593,9 +593,9 @@ public static List WriteSnippet(TextSnippet snippet, int length) { var pos = bw.BaseStream.Position; bw.BaseStream.Position = 0; - bw.Write(new byte[] {0x01}); + bw.Write(new byte[] { 0x01 }); bw.BeWrite((ushort) (pos - 3)); // 本来是+3和0的,但是提前预留了6个byte给它们,所以变成了-3和-6。下同理。 - bw.Write(new byte[] {0x01}); + bw.Write(new byte[] { 0x01 }); bw.BeWrite((ushort) (pos - 6)); bw.BaseStream.Position = pos; ret.Add(bw.BaseStream.ToBytesArray()); @@ -611,9 +611,9 @@ public static List WriteSnippet(TextSnippet snippet, int length) { var pos = bw.BaseStream.Position; bw.BaseStream.Position = 0; - bw.Write(new byte[] {0x01}); + bw.Write(new byte[] { 0x01 }); bw.BeWrite((ushort) (pos - 3)); - bw.Write(new byte[] {0x01}); + bw.Write(new byte[] { 0x01 }); bw.BeWrite((ushort) (pos - 6)); bw.BaseStream.Position = pos; } @@ -634,11 +634,11 @@ public static List WriteSnippet(TextSnippet snippet, int length) faceIndex = 0; } - bw.Write(new byte[] {0x02, 0x00, 0x14, 0x01, 0x00, 0x01}); + bw.Write(new byte[] { 0x02, 0x00, 0x14, 0x01, 0x00, 0x01 }); bw.Write(faceIndex); - bw.Write(new byte[] {0xFF, 0x00, 0x02, 0x14}); + bw.Write(new byte[] { 0xFF, 0x00, 0x02, 0x14 }); bw.Write((byte) (faceIndex + 65)); - bw.Write(new byte[] {0x0B, 0x00, 0x08, 0x00, 0x01, 0x00, 0x04, 0x52, 0xCC, 0x85, 0x50}); + bw.Write(new byte[] { 0x0B, 0x00, 0x08, 0x00, 0x01, 0x00, 0x04, 0x52, 0xCC, 0x85, 0x50 }); break; } case MessageType.Picture: @@ -709,135 +709,9 @@ public static List WriteRichtext(Richtext richtext) return ret; } - public static Richtext ReadRichtext(this BinaryReader Reader, byte _messageType, Richtext result) + public static Richtext ReadRichtext(this BinaryReader reader) { - // TODO: 解析富文本 - try - { - var DataLength = Reader.BeReadChar(); - if (Reader.BaseStream.Length - Reader.BaseStream.Position >= DataLength) - { - var Data = Reader.ReadBytes(DataLength); - var subReader = new BinaryReader(new MemoryStream(Data)); - subReader.ReadByte(); - var MessageData = subReader.ReadBytes(subReader.BeReadChar()); - if (_messageType == 0x01)//文本消息 - { - var MessageStr = Encoding.UTF8.GetString(MessageData); - if (MessageStr.Contains("@")) - { - //Reader.ReadBytes(10); - //var AtQQ = Util.GetQQNumRetUint(Util.ToHex(Reader.ReadBytes(4)));//被At人的QQ号 - result.Snippets.Add(new AtSnippet() - { - Content = MessageStr, - //AtQQ = AtQQ, - //Type=Framework.MessageType.At - }); - } - else - { - result.Snippets.Add(new TextSnippet() - { - Content = MessageStr, - Type = Framework.MessageType.Normal - }); - } - } - else if (_messageType == 0x02)//小黄豆表情 - { - result.Snippets.Add(new TextSnippet() - { - Content = Util.GetQQNumRetUint(Util.ToHex(MessageData)).ToString(), - Type = Framework.MessageType.Emoji - }); - } - else if (_messageType == 0x03)//图片 - { - result.Snippets.Add(new TextSnippet() - { - Content = Encoding.UTF8.GetString(MessageData), - Type = Framework.MessageType.Picture - }); - } - else if (_messageType == 0x0A)//音频 - { - result.Snippets.Add(new TextSnippet() - { - Content = Encoding.UTF8.GetString(MessageData), - Type = Framework.MessageType.Audio - }); - } - else if (_messageType == 0x0E)//未知 - { - - } - else if (_messageType == 0x14)//XML - { - var XmlReader = new BinaryReader(new MemoryStream(MessageData)); - XmlReader.ReadByte(); - result.Snippets.Add(new TextSnippet() - { - Content = GZipByteArray.DecompressString(XmlReader.ReadBytes((int)(XmlReader.BaseStream.Length - 1))), - Type = Framework.MessageType.Xml - }); - } - else if (_messageType == 0x18)//群文件 - { - var XmlReader = new BinaryReader(new MemoryStream(MessageData)); - XmlReader.ReadBytes(3); - var FileName = XmlReader.ReadBytes(XmlReader.ReadByte());//文件名称 - XmlReader.ReadByte(); - XmlReader.ReadBytes(XmlReader.ReadByte());//文件大小 - result.Snippets.Add(new TextSnippet() - { - Content = Encoding.UTF8.GetString(FileName), - Type = Framework.MessageType.OfflineFile - }); - } - else if (_messageType == 0x19)//红包秘钥段 - { - var RedBagReader = new BinaryReader(new MemoryStream(MessageData)); - if (RedBagReader.ReadByte() == 0xC2) - { - RedBagReader.ReadBytes(19); - RedBagReader.ReadBytes(RedBagReader.ReadByte());//恭喜发财 - RedBagReader.ReadByte(); - RedBagReader.ReadBytes(RedBagReader.ReadByte());//赶紧点击拆开吧 - RedBagReader.ReadByte(); - RedBagReader.ReadBytes(RedBagReader.ReadByte());//QQ红包 - RedBagReader.ReadBytes(5); - RedBagReader.ReadBytes(RedBagReader.ReadByte());//[QQ红包]恭喜发财 - RedBagReader.ReadBytes(22); - var RedId = Encoding.UTF8.GetString(RedBagReader.ReadBytes(32));//redid - RedBagReader.ReadBytes(12); - RedBagReader.ReadBytes(RedBagReader.BeReadChar()); - RedBagReader.ReadBytes(0x10); - var Key1 = Encoding.UTF8.GetString(RedBagReader.ReadBytes(RedBagReader.ReadByte()));//Key1 - RedBagReader.BeReadChar(); - var Key2 = Encoding.UTF8.GetString(RedBagReader.ReadBytes(RedBagReader.ReadByte()));//Key2 - result.Snippets.Add(new RedBagSnippet - { - RedId = RedId, - Key1 = Key1, - Key2 = Key2, - Type = Framework.MessageType.RedBag - }); - } - } - var MessageType = Reader.ReadByte(); - //如果没有结束继续解析消息内容 - if (Reader.BaseStream.Length - Reader.BaseStream.Position > 2) - { - Reader.ReadRichtext(MessageType, result); - } - } - } - catch (Exception ex) - { - - } - return result; + return Richtext.Parse(reader); } #endregion diff --git a/README.md b/README.md index f7d66b0..827fb8e 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ PCQQ协议 ------------------------------------------ #### 2018-10-12 1. 新增XML接收简单解析 +2. 群文件名称解析 #### 2018-10-10 1. 新增私聊消息撤回与群消息撤回