Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
luojinfang committed Oct 12, 2018
2 parents 658486c + c839812 commit d898819
Show file tree
Hide file tree
Showing 51 changed files with 407 additions and 454 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand All @@ -40,26 +41,20 @@ public override void Process()

//添加到已处理消息列表
_user.GroupReceiveMessages.Add(_packet);


}

//查看群消息确认
if (_packet.ReceiveTime != null)
{
_service.Send(new Send_0X0391(_user, _packet.Group, _packet.MessageIndex));
}
}
}
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));

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion QQ.Framework/Packets/PCTLV/TLV_0102.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions QQ.Framework/Packets/PCTLV/TLV_0104.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions QQ.Framework/Packets/PCTLV/TLV_0109.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
47 changes: 24 additions & 23 deletions QQ.Framework/Packets/PCTLV/TLV_050C.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions QQ.Framework/Packets/Receive/Data/Receive_0x00D8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
4 changes: 2 additions & 2 deletions QQ.Framework/Packets/Receive/Data/Receive_0x0126.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
4 changes: 2 additions & 2 deletions QQ.Framework/Packets/Receive/Data/Receive_0x0134.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
18 changes: 9 additions & 9 deletions QQ.Framework/Packets/Receive/Data/Receive_0x0195.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ public class Receive_0X0195 : ReceivePacket
/// <summary>
/// 群分组信息查询
/// </summary>
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)
{
}

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();
Expand All @@ -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();
}
Expand Down
4 changes: 2 additions & 2 deletions QQ.Framework/Packets/Receive/Data/Receive_0x019B.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
4 changes: 2 additions & 2 deletions QQ.Framework/Packets/Receive/Data/Receive_0x01A5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
4 changes: 2 additions & 2 deletions QQ.Framework/Packets/Receive/Data/Receive_0x01C4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
4 changes: 2 additions & 2 deletions QQ.Framework/Packets/Receive/Data/Receive_0x01C5.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
4 changes: 2 additions & 2 deletions QQ.Framework/Packets/Receive/Login/Receive_0x0839.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
}

Expand Down
14 changes: 4 additions & 10 deletions QQ.Framework/Packets/Receive/Message/Receive_0x0017.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ public Receive_0X0017(byte[] byteBuffer, QQUser user)
/// </summary>
public long Group { get; set; }

/// <summary>
/// 消息类型
/// </summary>
public byte MessageType { get; set; }

/// <summary>
/// 消息
/// </summary>
Expand Down Expand Up @@ -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); //发送时间
Expand All @@ -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();
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions QQ.Framework/Packets/Receive/Message/Receive_0x00CE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,20 @@ public Receive_0X00Ce(byte[] byteBuffer, QQUser user)
/// 消息内容
/// </summary>
public Richtext Message { get; set; } = new Richtext();

/// <summary>
/// 消息id
/// </summary>
public byte[] MessageId { get; set; }

public string Key1 { get; set; }
public string Key2 { get; set; }
public string RedId { get; set; }

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);
Expand All @@ -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();
}
}
}
Loading

0 comments on commit d898819

Please sign in to comment.