├── .gitignore
├── Kagami.Test
├── Kagami.Test.csproj
├── TestCommands.cs
└── TestReplRuntime.cs
├── Kagami.sln
├── Kagami
├── Command.cs
├── Kagami.csproj
├── Program.cs
├── SandBox
│ ├── ReplEnvironment.cs
│ └── ReplRuntime.cs
└── Utils
│ ├── Build.cs
│ └── Util.cs
├── LICENSE
├── README.md
└── ScriptExample
├── chess.cs
├── hello.cs
└── ic.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | .vs/
2 | .idea/
3 | bin/
4 | obj/
5 | *.user
6 |
--------------------------------------------------------------------------------
/Kagami.Test/Kagami.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | enable
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | all
15 | runtime; build; native; contentfiles; analyzers; buildtransitive
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/Kagami.Test/TestCommands.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading.Tasks;
3 | using NUnit.Framework;
4 | using Konata.Core.Message.Model;
5 |
6 | namespace Kagami.Test;
7 |
8 | public class Tests
9 | {
10 | [SetUp]
11 | public void Setup()
12 | {
13 | }
14 |
15 | [Test]
16 | public async Task OnCommandGithubParser()
17 | {
18 | var textChain = TextChain.Create
19 | ("https://github.com/KonataDev/Kagami");
20 | {
21 | // Get result
22 | var result = await Command
23 | .OnCommandGithubParser(textChain);
24 |
25 | Console.WriteLine(result.Build());
26 | }
27 | Assert.Pass();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Kagami.Test/TestReplRuntime.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Threading;
3 | using System.Threading.Tasks;
4 | using Kagami.SandBox;
5 | using NUnit.Framework;
6 |
7 | namespace Kagami.Test;
8 |
9 | public class TestReplRuntime
10 | {
11 | private static ReplRuntime? _repl;
12 | private const string StringExploitOk = "ExploitOK";
13 | private const string StringProtected = "Protected";
14 |
15 | [SetUp]
16 | public void Setup()
17 | {
18 | _repl = new ReplRuntime(
19 | // Additional references
20 | new[]
21 | {
22 | "System.Diagnostics",
23 | "Konata.Core",
24 | "Paraparty.JsonChan"
25 | },
26 |
27 | // Additional usings
28 | new[]
29 | {
30 | "System.Runtime",
31 | "System.Threading",
32 | "System.Threading.Tasks",
33 | "Konata.Core",
34 | "Konata.Core.Common",
35 | "Konata.Core.Interfaces",
36 | "Konata.Core.Interfaces.Api",
37 | "Konata.Core.Events",
38 | "Konata.Core.Events.Model",
39 | "Konata.Core.Message",
40 | "Konata.Core.Message.Model",
41 | "Paraparty.JsonChan"
42 | },
43 |
44 | // Initial script
45 | null,
46 |
47 | // Enable checks
48 | true,
49 |
50 | // Execution timeout
51 | 5000
52 | );
53 | }
54 |
55 | private static async Task RunAsync(string code, Action? cb = null)
56 | {
57 | var result = await _repl!.RunAsync(code, cb);
58 | if (result == null) return null;
59 | return result.ToString();
60 | }
61 |
62 | private static async Task