Skip to content

Commit 35c230e

Browse files
authored
[NativeAPI] 修复了群聊通知事件中的类型错误 (#49)
1 parent bebe84b commit 35c230e

8 files changed

Lines changed: 91 additions & 47 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System.Runtime.InteropServices;
2+
using System.Text;
3+
using Lagrange.Core.Common.Entity;
4+
5+
namespace Lagrange.Core.NativeAPI.NativeModel.Common;
6+
[StructLayout(LayoutKind.Sequential)]
7+
public class BotGroupInviteNotificationStruct(BotGroupInviteNotification e) : BotGroupNotificationBaseStruct(e)
8+
{
9+
public int State = (int)e.State;
10+
11+
public long OperatorUin = e.OperatorUin ?? 0;
12+
13+
public ByteArrayNative OperatorUid = Encoding.UTF8.GetBytes(e.OperatorUid ?? "");
14+
15+
public long InviterUin = e.InviterUin;
16+
17+
public ByteArrayNative InviterUid = Encoding.UTF8.GetBytes(e.InviterUid);
18+
19+
public bool IsFiltered = e.IsFiltered;
20+
21+
public static implicit operator BotGroupInviteNotificationStruct(BotGroupInviteNotification e)
22+
{
23+
return new BotGroupInviteNotificationStruct(e);
24+
}
25+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System.Runtime.InteropServices;
2+
using System.Text;
3+
using Lagrange.Core.Common.Entity;
4+
5+
namespace Lagrange.Core.NativeAPI.NativeModel.Common;
6+
[StructLayout(LayoutKind.Sequential)]
7+
public class BotGroupJoinNotificationStruct(BotGroupJoinNotification notification) : BotGroupNotificationBaseStruct(notification)
8+
{
9+
public int State = (int)notification.State;
10+
11+
public long OperatorUin = notification.OperatorUin ?? 0;
12+
13+
public ByteArrayNative OperatorUid { get; } = Encoding.UTF8.GetBytes(notification.OperatorUid ?? "");
14+
15+
public ByteArrayNative Comment { get; } = Encoding.UTF8.GetBytes(notification.Comment);
16+
17+
public bool IsFiltered { get; } = notification.IsFiltered;
18+
19+
public static implicit operator BotGroupJoinNotificationStruct(BotGroupJoinNotification e)
20+
{
21+
return new BotGroupJoinNotificationStruct(e);
22+
}
23+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Runtime.InteropServices;
2+
using System.Text;
3+
using Lagrange.Core.Common.Entity;
4+
5+
namespace Lagrange.Core.NativeAPI.NativeModel.Common;
6+
[StructLayout(LayoutKind.Sequential)]
7+
public abstract class BotGroupNotificationBaseStruct(BotGroupNotificationBase e)
8+
{
9+
public long GroupUin = e.GroupUin;
10+
11+
public ulong Sequence = e.Sequence;
12+
13+
public int Type = (int)e.Type;
14+
15+
public long TargetUin = e.TargetUin;
16+
17+
public ByteArrayNative TargetUid = Encoding.UTF8.GetBytes(e.TargetUid);
18+
}
Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
11
using System.Runtime.InteropServices;
22
using Lagrange.Core.Common.Entity;
33
using Lagrange.Core.Events.EventArgs;
4+
using Lagrange.Core.NativeAPI.NativeModel.Common;
45

5-
namespace Lagrange.Core.NativeAPI.NativeModel.Event
6+
namespace Lagrange.Core.NativeAPI.NativeModel.Event;
7+
[StructLayout(LayoutKind.Sequential)]
8+
public struct BotGroupInviteNotificationEventStruct(BotGroupInviteNotification notification) : IEventStruct
69
{
7-
[StructLayout(LayoutKind.Sequential)]
8-
public struct BotGroupInviteNotificationEventStruct(BotGroupInviteNotification notification) : IEventStruct
9-
{
10-
public BotGroupInviteNotification Notification = notification;
11-
12-
//public static implicit operator BotGroupMemberDecreaseEvent(BotGroupMemberDecreaseEventStruct e)
13-
//{
14-
// return new BotGroupMemberDecreaseEvent(
15-
// e.GroupUin, e.UserUin, e.OperatorUin
16-
// );
17-
//}
10+
public BotGroupInviteNotificationStruct Notification = notification;
1811

19-
public static implicit operator BotGroupInviteNotificationEventStruct(BotGroupInviteNotificationEvent e)
20-
{
21-
return new BotGroupInviteNotificationEventStruct()
22-
{
23-
Notification = e.Notification
24-
};
25-
}
12+
public static implicit operator BotGroupInviteNotificationEventStruct(BotGroupInviteNotificationEvent e)
13+
{
14+
return new BotGroupInviteNotificationEventStruct(e.Notification);
2615
}
27-
}
16+
}
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11
using System.Runtime.InteropServices;
22
using Lagrange.Core.Common.Entity;
33
using Lagrange.Core.Events.EventArgs;
4+
using Lagrange.Core.NativeAPI.NativeModel.Common;
45

56
namespace Lagrange.Core.NativeAPI.NativeModel.Event
67
{
78
[StructLayout(LayoutKind.Sequential)]
89
public struct BotGroupJoinNotificationEventStruct(BotGroupJoinNotification notification) : IEventStruct
910
{
10-
public BotGroupJoinNotification Notification = notification;
11-
12-
//public static implicit operator BotGroupJoinNotificationEvent(BotGroupJoinNotificationEventStruct e)
13-
//{
14-
// return new BotGroupJoinNotificationEvent(
15-
// e.Notification
16-
// );
17-
//}
11+
public BotGroupJoinNotificationStruct Notification = notification;
1812

1913
public static implicit operator BotGroupJoinNotificationEventStruct(BotGroupJoinNotificationEvent e)
2014
{
21-
return new BotGroupJoinNotificationEventStruct()
22-
{
23-
Notification = e.Notification
24-
};
15+
return new BotGroupJoinNotificationEventStruct(e.Notification);
2516
}
2617
}
2718
}

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ namespace Lagrange.Core.NativeAPI.NativeModel.Event
77
public struct BotGroupMemberDecreaseEventStruct : IEventStruct
88
{
99
public BotGroupMemberDecreaseEventStruct() { }
10-
public Int64 GroupUin = 0;
11-
public Int64 UserUin = 0;
12-
public Int64 OperatorUin = 0;
1310

14-
//public static implicit operator BotGroupMemberDecreaseEvent(BotGroupMemberDecreaseEventStruct e)
15-
//{
16-
// return new BotGroupMemberDecreaseEvent(
17-
// e.GroupUin, e.UserUin, e.OperatorUin
18-
// );
19-
//}
11+
public long GroupUin = 0;
12+
13+
public long UserUin = 0;
14+
15+
public long OperatorUin = 0;
2016

2117
public static implicit operator BotGroupMemberDecreaseEventStruct(BotGroupMemberDecreaseEvent e)
2218
{

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ namespace Lagrange.Core.NativeAPI.NativeModel.Event
99
public struct BotGroupNudgeEventStruct : IEventStruct
1010
{
1111
public BotGroupNudgeEventStruct() { }
12-
public Int64 GroupUin = 0;
13-
public Int64 OperatorUin = 0;
12+
13+
public long GroupUin = 0;
14+
15+
public long OperatorUin = 0;
16+
1417
public ByteArrayNative Action = new();
15-
public Int64 TargetUin = 0;
18+
public long TargetUin = 0;
19+
1620
public ByteArrayNative Suffix = new();
1721

1822
public static implicit operator BotGroupNudgeEvent(BotGroupNudgeEventStruct e)

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.Runtime.InteropServices;
2-
3-
namespace Lagrange.Core.NativeAPI.NativeModel.Event
1+
namespace Lagrange.Core.NativeAPI.NativeModel.Event
42
{
53
public interface IEventStruct
64
{

0 commit comments

Comments
 (0)