Skip to content

Commit

Permalink
解析被@的群员
Browse files Browse the repository at this point in the history
  • Loading branch information
sgkoishi committed Oct 14, 2018
1 parent a63c1df commit ad7b08a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions QQ.Framework/Utils/Richtext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public static Richtext Parse(BinaryReader reader)
case 0x01: //文本消息
{
var messageStr = Encoding.UTF8.GetString(reader.ReadBytes(reader.BeReadChar()));
if (messageStr.Contains("@"))
if (messageStr.StartsWith("@") && pos + dataLength - reader.BaseStream.Position == 16)
{
//Reader.ReadBytes(10);
//var AtQQ = Util.GetQQNumRetUint(Util.ToHex(Reader.ReadBytes(4)));//被At人的QQ号
result.Snippets.Add(new TextSnippet(messageStr, MessageType.At));
reader.ReadBytes(10);
result.Snippets.Add(new TextSnippet(messageStr, MessageType.At,
("Target", reader.BeReadUInt32())));
}
else
{
Expand All @@ -57,21 +57,24 @@ public static Richtext Parse(BinaryReader reader)
}
case 0x0A: //音频
{
result.Snippets.Add(new TextSnippet(Encoding.UTF8.GetString(reader.ReadBytes(reader.BeReadChar())), MessageType.Audio));
result.Snippets.Add(new TextSnippet(
Encoding.UTF8.GetString(reader.ReadBytes(reader.BeReadChar())), MessageType.Audio));
break;
}
case 0x0E: //未知
{
break;
}
case 0x12://群名片
case 0x12: //群名片
{
break;
}
case 0x14: //XML
{
reader.ReadByte();
result.Snippets.Add(new TextSnippet( GZipByteArray.DecompressString(reader.ReadBytes((int) (reader.BaseStream.Length - 1))), MessageType.Xml));
reader.ReadByte();
result.Snippets.Add(new TextSnippet(
GZipByteArray.DecompressString(reader.ReadBytes((int) (reader.BaseStream.Length - 1))),
MessageType.Xml));
break;
}
case 0x18: //群文件
Expand All @@ -90,6 +93,7 @@ public static Richtext Parse(BinaryReader reader)
{
break;
}

reader.ReadBytes(19);
reader.ReadBytes(reader.ReadByte()); //恭喜发财
reader.ReadByte();
Expand Down Expand Up @@ -160,13 +164,13 @@ public class TextSnippet
{
public string Content;
public MessageType Type;
private Dictionary<string, object> _data = new Dictionary<string, object>();
private readonly Dictionary<string, object> _data = new Dictionary<string, object>();

public T Get<T>(string name, T value = default(T))
{
if (_data.ContainsKey(name))
{
return (T)_data[name];
return (T) _data[name];
}

return value;
Expand Down

0 comments on commit ad7b08a

Please sign in to comment.