Skip to content

Commit

Permalink
[OneBot] Create a default config
Browse files Browse the repository at this point in the history
  • Loading branch information
Linwenxuan authored Feb 15, 2024
2 parents 322e222 + 61fadea commit 626e0ed
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Lagrange.OneBot/Lagrange.OneBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
<TargetFrameworks>net7.0;net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<None Remove="Resources\appsettings.json" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\appsettings.json" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fleck" Version="1.2.0" />
<PackageReference Include="LiteDB" Version="5.0.17" />
Expand Down
15 changes: 13 additions & 2 deletions Lagrange.OneBot/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Reflection;
using System.Runtime;
using System.Text;
using Microsoft.Extensions.Hosting;
Expand All @@ -12,12 +13,22 @@ public static void Main(string[] args)
Console.InputEncoding = Encoding.UTF8;

GCSettings.LatencyMode = GCLatencyMode.Batch;


if (!File.Exists("appsettings.json"))
{
Console.WriteLine("No exist config file, create it now...");

var assm = Assembly.GetExecutingAssembly();
using var istr = assm.GetManifestResourceStream("Lagrange.OneBot.Resources.appsettings.json")!;
using var temp = File.Create("appsettings.json");
istr.CopyTo(temp);
}

var hostBuilder = new LagrangeAppBuilder(args)
.ConfigureConfiguration("appsettings.json", false, true)
.ConfigureBots()
.ConfigureOneBot();

hostBuilder.Build().Run();
}
}
47 changes: 47 additions & 0 deletions Lagrange.OneBot/Resources/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"Logging": {
"LogLevel": {
"Default": "Trace",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"SignServerUrl": "",
"Account": {
"Uin": 0,
"Password": "",
"Protocol": "Linux",
"AutoReconnect": true,
"GetOptimumServer": true
},
"Message": {
"IgnoreSelf": true
},
"Implementation": {
"ForwardWebSocket": {
"Host": "127.0.0.1",
"Port": 8081,
"HeartBeatInterval": 5000,
"AccessToken": ""
},
"ReverseWebSocket": {
"Host": "127.0.0.1",
"Port": 8080,
"Suffix": "/onebot/v11/ws",
"ReconnectInterval": 5000,
"HeartBeatInterval": 5000,
"AccessToken": ""
},
"Http": {
"Host": "",
"Port": 0,
"EventEnabled": false
},
"HttpPost": {
"Host": "127.0.0.1",
"Port": 8080,
"Suffix": "/onebot/v11/http",
"Timeout": 0
}
}
}

0 comments on commit 626e0ed

Please sign in to comment.