forked from LagrangeDev/LagrangeV2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBotOfflineEventStruct.cs
More file actions
36 lines (30 loc) · 1.07 KB
/
BotOfflineEventStruct.cs
File metadata and controls
36 lines (30 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Runtime.InteropServices;
using System.Text;
using Lagrange.Core.Events.EventArgs;
using Lagrange.Core.NativeAPI.NativeModel.Common;
namespace Lagrange.Core.NativeAPI.NativeModel.Event
{
[StructLayout(LayoutKind.Sequential)]
public struct BotOfflineEventStruct : IEventStruct
{
public BotOfflineEventStruct() { }
public int Reason = 0;
ByteArrayNative Tag = new();
ByteArrayNative Message = new();
public static implicit operator BotOfflineEvent(BotOfflineEventStruct e)
{
return new BotOfflineEvent((BotOfflineEvent.Reasons)e.Reason, (
Encoding.UTF8.GetString(e.Tag), Encoding.UTF8.GetString(e.Message)
));
}
public static implicit operator BotOfflineEventStruct(BotOfflineEvent e)
{
return new BotOfflineEventStruct()
{
Reason = (int)e.Reason,
Tag = Encoding.UTF8.GetBytes(e.Tips?.Tag ?? ""),
Message = Encoding.UTF8.GetBytes(e.Tips?.Message ?? ""),
};
}
}
}