Supported FaceEntity

This commit is contained in:
Linwenxuan05 2023-06-29 21:14:31 +08:00
parent 35886fca17
commit be7228cae7
3 changed files with 35 additions and 30 deletions

View file

@ -66,9 +66,7 @@ internal class FaceEntity : IMessageEntity
if (elems.Face is { Old: not null })
{
using var stream = new MemoryStream(elems.Face.Old);
var face = Serializer.Deserialize<FaceExtra>(stream);
ushort? faceId = (ushort?)face.FaceId;
ushort? faceId = (ushort?)elems.Face.Index;
if (faceId != null) return new FaceEntity((ushort)faceId, false);
}
@ -84,5 +82,5 @@ internal class FaceEntity : IMessageEntity
return null;
}
public string ToPreviewString() => $"[Face][{(IsLargeFace ? "Small" : "Large")}]: {FaceId}";
public string ToPreviewString() => $"[Face][{(IsLargeFace ? "Large" : "Small")}]: {FaceId}";
}

View file

@ -15,7 +15,7 @@ namespace Lagrange.Core.Message;
/// </summary>
internal class MessagePacker
{
private static readonly Dictionary<Type, PropertyInfo> EntityToElem;
private static readonly Dictionary<Type, List<PropertyInfo>> EntityToElem;
private static readonly Dictionary<Type, IMessageEntity> Factory;
private static readonly List<IMessageEntity> MsgFactory;
@ -23,7 +23,7 @@ internal class MessagePacker
static MessagePacker()
{
EntityToElem = new Dictionary<Type, PropertyInfo>();
EntityToElem = new Dictionary<Type, List<PropertyInfo>>();
Factory = new Dictionary<Type, IMessageEntity>();
var assembly = Assembly.GetExecutingAssembly();
@ -38,7 +38,11 @@ internal class MessagePacker
foreach (var attribute in attributes)
{
var property = elemType.GetProperty(attribute.Element.Name);
if (property != null) EntityToElem[type] = property;
if (property != null)
{
if (EntityToElem.TryGetValue(type, out var properties)) properties.Add(property);
else EntityToElem[type] = new List<PropertyInfo> { property };
}
}
if (type.CreateInstance() is IMessageEntity factory) Factory[type] = factory;
@ -85,7 +89,9 @@ internal class MessagePacker
{
foreach (var element in message.Body.RichText.Elems)
{
foreach (var (entityType, expectElem) in EntityToElem)
foreach (var (entityType, expectElems) in EntityToElem)
{
foreach (var expectElem in expectElems)
{
var val = expectElem.GetValueByExpr(element);
if (val != null)
@ -100,6 +106,7 @@ internal class MessagePacker
}
}
}
}
if (message.Body is { MsgContent: not null, RichText: null }) // if RichText is not null, it means that the message is from Tencent's SSO server
{

View file

@ -12,11 +12,11 @@ An Implementation of NTQQ Protocol, with Pure C#, Derived from Konata.Core
## Features List
| Login | Support | Messages | Support | Operations | Support | Events | Support |
|---------------------------|---------|:----------------|:-----------|:--------------------|:----------|:-----------------------|:--------|
|---------------------------|---------|:-----------------|:-----------|:--------------------|:----------|:-----------------------|:--------|
| QrCode | 🟢 | Images | 🟡 | ~~Poke~~ | 🔴 | Captcha | 🔴 |
| Password | 🔴 | Text / At | 🟡 | Recall | 🔴 | BotOnline | 🟢 |
| EasyLogin | 🟢 | Records | 🔴 | Leave Group | 🔴 | BotOffline | 🟢 |
| UnusalDevice<br/>Password | 🔴 | QFace | 🔴 | ~~Special Title~~ | 🔴 | Message | 🔴 |
| UnusalDevice<br/>Password | 🔴 | QFace | 🟡 | ~~Special Title~~ | 🔴 | Message | 🔴 |
| | | Json | 🟡 | Kick Member | 🔴 | ~~Poke~~ | 🔴 |
| | | Xml | 🟡 | Mute Member | 🔴 | MessageRecall | 🔴 |
| | | Forward | 🔴 | Set Admin | 🔴 | GroupMemberDecrease | 🔴 |