2023-07-06 06:37:48 +08:00
|
|
|
using System;
|
|
|
|
using Jint;
|
2023-07-06 06:56:13 +08:00
|
|
|
using Jint.Native.Json;
|
2023-07-06 06:37:48 +08:00
|
|
|
using Jint.Native.Object;
|
|
|
|
using Jint.Runtime.Descriptors;
|
|
|
|
|
|
|
|
namespace BililiveRecorder.Core.Scripting.Runtime
|
|
|
|
{
|
|
|
|
internal class JintRoomInfo : ObjectInstance
|
|
|
|
{
|
|
|
|
public JintRoomInfo(Engine engine, IRoom room) : base(engine)
|
|
|
|
{
|
|
|
|
if (room is null) throw new ArgumentNullException(nameof(room));
|
|
|
|
|
|
|
|
this.FastSetProperty("roomId", new PropertyDescriptor(room.RoomConfig.RoomId, false, true, false));
|
|
|
|
this.FastSetProperty("shortId", new PropertyDescriptor(room.ShortId, false, true, false));
|
|
|
|
this.FastSetProperty("name", new PropertyDescriptor(room.Name, false, true, false));
|
2023-07-08 16:14:45 +08:00
|
|
|
this.FastSetProperty("uid", new PropertyDescriptor(room.Uid.ToString(), false, true, false));
|
2023-07-06 06:37:48 +08:00
|
|
|
this.FastSetProperty("title", new PropertyDescriptor(room.Title, false, true, false));
|
|
|
|
this.FastSetProperty("areaParent", new PropertyDescriptor(room.AreaNameParent, false, true, false));
|
|
|
|
this.FastSetProperty("areaChild", new PropertyDescriptor(room.AreaNameChild, false, true, false));
|
|
|
|
this.FastSetProperty("objectId", new PropertyDescriptor(room.ObjectId.ToString(), false, true, false));
|
2023-07-06 06:56:13 +08:00
|
|
|
|
|
|
|
var apiData = new JsonParser(engine).Parse(room.RawBilibiliApiJsonData?.ToString() ?? "{}");
|
|
|
|
this.FastSetProperty("apiData", new PropertyDescriptor(apiData, false, true, false));
|
2023-07-06 06:37:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|