Skip to content

Commit 9cee0c8

Browse files
authored
[NativeAPI] 同步 Core 功能添加 (#47)
1 parent 88ea319 commit 9cee0c8

10 files changed

Lines changed: 261 additions & 32 deletions

Lagrange.Core.NativeAPI.Test/NativeModel/ReverseEventCountStruct.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ public struct ReverseEventCountStruct
88
public ReverseEventCountStruct() { }
99

1010
public int BotCaptchaEventCount = 0;
11+
public int BotFriendRequestEventCount = 0;
1112
public int BotGroupInviteNotificationEventCount = 0;
13+
public int BotGroupInviteSelfEventCount = 0;
1214
public int BotGroupJoinNotificationEventCount = 0;
1315
public int BotGroupMemberDecreaseEventCount = 0;
1416
public int BotGroupNudgeEventCount = 0;
17+
public int BotGroupReactionEventCount = 0;
1518
public int BotLoginEventCount = 0;
1619
public int BotLogEventCount = 0;
1720
public int BotMessageEventCount = 0;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Runtime.InteropServices;
2+
using System.Text;
3+
using Lagrange.Core.Common.Entity;
4+
using Lagrange.Core.Events.EventArgs;
5+
using Lagrange.Core.NativeAPI.NativeModel.Common;
6+
7+
namespace Lagrange.Core.NativeAPI.NativeModel.Event
8+
{
9+
[StructLayout(LayoutKind.Sequential)]
10+
public struct BotFriendRequestEventStruct : IEventStruct
11+
{
12+
public BotFriendRequestEventStruct() { }
13+
14+
public ByteArrayNative InitiatorUid = new();
15+
16+
public long InitiatorUin = 0;
17+
18+
public ByteArrayNative Message = new();
19+
20+
public ByteArrayNative Source = new();
21+
22+
//public static implicit operator BotGroupMemberDecreaseEvent(BotGroupMemberDecreaseEventStruct e)
23+
//{
24+
// return new BotGroupMemberDecreaseEvent(
25+
// e.GroupUin, e.UserUin, e.OperatorUin
26+
// );
27+
//}
28+
29+
public static implicit operator BotFriendRequestEventStruct(BotFriendRequestEvent e)
30+
{
31+
return new BotFriendRequestEventStruct()
32+
{
33+
InitiatorUid = Encoding.UTF8.GetBytes(e.InitiatorUid),
34+
InitiatorUin = e.InitiatorUin,
35+
Message = Encoding.UTF8.GetBytes(e.Message),
36+
Source = Encoding.UTF8.GetBytes(e.Source)
37+
};
38+
}
39+
}
40+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System.Runtime.InteropServices;
2+
using Lagrange.Core.Events.EventArgs;
3+
4+
namespace Lagrange.Core.NativeAPI.NativeModel.Event
5+
{
6+
[StructLayout(LayoutKind.Sequential)]
7+
public struct BotGroupInviteSelfEventStruct : IEventStruct
8+
{
9+
public BotGroupInviteSelfEventStruct() { }
10+
11+
public long InvitationSeq = 0;
12+
13+
public long InitiatorUin = 0;
14+
15+
public long GroupUin = 0;
16+
17+
//public static implicit operator BotGroupMemberDecreaseEvent(BotGroupMemberDecreaseEventStruct e)
18+
//{
19+
// return new BotGroupMemberDecreaseEvent(
20+
// e.GroupUin, e.UserUin, e.OperatorUin
21+
// );
22+
//}
23+
24+
public static implicit operator BotGroupInviteSelfEventStruct(BotGroupInviteSelfEvent e)
25+
{
26+
return new BotGroupInviteSelfEventStruct()
27+
{
28+
InvitationSeq = e.InvitationSeq,
29+
InitiatorUin = e.InitiatorUin,
30+
GroupUin = e.GroupUin
31+
};
32+
}
33+
}
34+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System.Runtime.InteropServices;
2+
using System.Text;
3+
using Lagrange.Core.Events.EventArgs;
4+
using Lagrange.Core.NativeAPI.NativeModel.Common;
5+
6+
namespace Lagrange.Core.NativeAPI.NativeModel.Event
7+
{
8+
[StructLayout(LayoutKind.Sequential)]
9+
public struct BotGroupReactionEventStruct : IEventStruct
10+
{
11+
public BotGroupReactionEventStruct() { }
12+
13+
public long TargetGroupUin = 0;
14+
15+
public ulong TargetSequence = 0;
16+
17+
public long OperatorUin = 0;
18+
19+
public bool IsAdd = false;
20+
21+
public ByteArrayNative Code = new();
22+
23+
public ulong CurrentCount = 0;
24+
25+
public static implicit operator BotGroupReactionEventStruct(BotGroupReactionEvent e)
26+
{
27+
return new BotGroupReactionEventStruct()
28+
{
29+
TargetGroupUin = e.TargetGroupUin,
30+
TargetSequence = e.TargetSequence,
31+
OperatorUin = e.OperatorUin,
32+
IsAdd = e.IsAdd,
33+
Code = Encoding.UTF8.GetBytes(e.Code),
34+
CurrentCount = e.CurrentCount
35+
};
36+
}
37+
}
38+
}

Lagrange.Core.NativeAPI/NativeModel/Event/ReverseEventCountStruct.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ public struct ReverseEventCountStruct
88
public ReverseEventCountStruct() { }
99

1010
public int BotCaptchaEventCount = 0;
11+
public int BotFriendRequestEventCount = 0;
1112
public int BotGroupInviteNotificationEventCount = 0;
13+
public int BotGroupInviteSelfEventCount = 0;
1214
public int BotGroupJoinNotificationEventCount = 0;
1315
public int BotGroupMemberDecreaseEventCount = 0;
1416
public int BotGroupNudgeEventCount = 0;
17+
public int BotGroupReactionEventCount = 0;
1518
public int BotLoginEventCount = 0;
1619
public int BotLogEventCount = 0;
1720
public int BotMessageEventCount = 0;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Lagrange.Core.Events.EventArgs;
2+
using Lagrange.Core.NativeAPI.NativeModel;
3+
using Lagrange.Core.NativeAPI.NativeModel.Event;
4+
using Lagrange.Core.NativeAPI.ReverseEvent.Abstract;
5+
6+
namespace Lagrange.Core.NativeAPI.ReverseEvent
7+
{
8+
public class BotFriendRequestReverseEvent : ReverseEventBase
9+
{
10+
public override void RegisterEventHandler(BotContext context)
11+
{
12+
context.EventInvoker.RegisterEvent<BotFriendRequestEvent>((ctx, e) =>
13+
{
14+
Events.Add((BotFriendRequestEventStruct)e);
15+
});
16+
}
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Lagrange.Core.Events.EventArgs;
2+
using Lagrange.Core.NativeAPI.NativeModel;
3+
using Lagrange.Core.NativeAPI.NativeModel.Event;
4+
using Lagrange.Core.NativeAPI.ReverseEvent.Abstract;
5+
6+
namespace Lagrange.Core.NativeAPI.ReverseEvent
7+
{
8+
public class BotGroupInviteSelfReverseEvent : ReverseEventBase
9+
{
10+
public override void RegisterEventHandler(BotContext context)
11+
{
12+
context.EventInvoker.RegisterEvent<BotGroupInviteSelfEvent>((ctx, e) =>
13+
{
14+
Events.Add((BotGroupInviteSelfEventStruct)e);
15+
});
16+
}
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Lagrange.Core.Events.EventArgs;
2+
using Lagrange.Core.NativeAPI.NativeModel;
3+
using Lagrange.Core.NativeAPI.NativeModel.Event;
4+
using Lagrange.Core.NativeAPI.ReverseEvent.Abstract;
5+
6+
namespace Lagrange.Core.NativeAPI.ReverseEvent
7+
{
8+
public class BotGroupReactionReverseEvent : ReverseEventBase
9+
{
10+
public override void RegisterEventHandler(BotContext context)
11+
{
12+
context.EventInvoker.RegisterEvent<BotGroupReactionEvent>((ctx, e) =>
13+
{
14+
Events.Add((BotGroupReactionEventStruct)e);
15+
});
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)