Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion Lagrange.Core.NativeAPI/SendMessageContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Text;
using System.Text;
using Lagrange.Core.Message;

namespace Lagrange.Core.NativeAPI
Expand Down Expand Up @@ -87,6 +87,32 @@ public void AddLocalImage(int id, byte[] path, byte[]? summary = null,
}
}

public void AddMention(int id, long uin, byte[]? display = null)
{
if (MessageBuilders.TryGetValue(id, out var builder))
{
builder.Mention(uin, display is null ? null : Encoding.UTF8.GetString(display));
}
}

public void AddReply(int id /*, BotMessage messages */)
{
throw new NotImplementedException();
}

public void AddMultiMsg(int id /*, List<BotMessage> messages */)
{
throw new NotImplementedException();
}

public void AddMultiMsg(int id, byte[] resId)
{
if (MessageBuilders.TryGetValue(id, out var builder))
{
builder.MultiMsg(Encoding.UTF8.GetString(resId));
}
}

public void AddRecord(int id, byte[] record)
{
if (MessageBuilders.TryGetValue(id, out var builder))
Expand Down
40 changes: 40 additions & 0 deletions Lagrange.Core.NativeAPI/SendMessageEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,46 @@ int subType
);
}

//display可选,可以传结构内Length为0或Data为Zero的ByteArrayNative
[UnmanagedCallersOnly(EntryPoint = "AddMention")]
public static void AddMention(
int index,
int id,
long uin,
ByteArrayNative display
)
{
if (Program.Contexts.Count <= index)
{
return;
}

byte[]? ds = display.IsEmpty() ? null : display.ToByteArrayWithoutFree();

var context = Program.Contexts[index];
context.SendMessageContext.AddMention(
id, uin, ds
);
}

[UnmanagedCallersOnly(EntryPoint = "AddMultiMsg")]
public static void AddMultiMsg(
int index,
int id,
ByteArrayNative resId
)
{
if (Program.Contexts.Count <= index)
{
return;
}

var context = Program.Contexts[index];
context.SendMessageContext.AddMultiMsg(
id, resId.ToByteArrayWithoutFree()
);
}

[UnmanagedCallersOnly(EntryPoint = "AddRecord")]
public static void AddRecord(int index, int id, ByteArrayNative byteArrayNative)
{
Expand Down
Loading