Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
sgkoishi committed Oct 11, 2018
1 parent 95a30c1 commit 86460df
Showing 1 changed file with 37 additions and 62 deletions.
99 changes: 37 additions & 62 deletions QQ.Framework/Utils/Richtext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,59 +22,41 @@ public static Richtext Parse(BinaryReader reader)
while (reader.BaseStream.Position + dataLength < reader.BaseStream.Length)
{
reader.ReadByte();
var messageData = reader.ReadBytes(reader.BeReadChar());
switch (messageType)
{
case 0x01: //文本消息
{
var messageStr = Encoding.UTF8.GetString(messageData);
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
{
Content = messageStr,
Type = MessageType.At
});
result.Snippets.Add(new TextSnippet(messageStr, MessageType.At));
}
else
{
result.Snippets.Add(new TextSnippet
{
Content = messageStr,
Type = MessageType.Normal
});
result.Snippets.Add(messageStr);
}

break;
}

case 0x02: //小黄豆表情
{
result.Snippets.Add(new TextSnippet
{
Content = Util.GetQQNumRetUint(Util.ToHex(messageData)).ToString(),
Type = MessageType.Emoji
});
result.Snippets.Add(new TextSnippet(
Util.GetQQNumRetUint(Util.ToHex(reader.ReadBytes(reader.BeReadChar()))).ToString(),
MessageType.Emoji));
break;
}
case 0x03: //图片
{
result.Snippets.Add(new TextSnippet
{
Content = Encoding.UTF8.GetString(messageData),
Type = MessageType.Picture
});
result.Snippets.Add(new TextSnippet(
Encoding.UTF8.GetString(reader.ReadBytes(reader.BeReadChar())), MessageType.Picture));
break;
}
case 0x0A: //音频
{
result.Snippets.Add(new TextSnippet
{
Content = Encoding.UTF8.GetString(messageData),
Type = MessageType.Audio
});
result.Snippets.Add(new TextSnippet(Encoding.UTF8.GetString(reader.ReadBytes(reader.BeReadChar())), MessageType.Audio));
break;
}
case 0x0E: //未知
Expand All @@ -83,49 +65,42 @@ public static Richtext Parse(BinaryReader reader)
}
case 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 = MessageType.Xml
});
reader.ReadByte();
result.Snippets.Add(new TextSnippet( GZipByteArray.DecompressString(reader.ReadBytes((int) (reader.BaseStream.Length - 1))), MessageType.Xml));
break;
}
case 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 = MessageType.OfflineFile
});
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: //红包秘钥段
{
var redBagReader = new BinaryReader(new MemoryStream(messageData));
redBagReader.ReadBytes(20);
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
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;
Expand Down

0 comments on commit 86460df

Please sign in to comment.