This repository was archived by the owner on Oct 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 352
Expand file tree
/
Copy pathProgram.cs
More file actions
118 lines (105 loc) · 3.71 KB
/
Program.cs
File metadata and controls
118 lines (105 loc) · 3.71 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System.Reflection;
using System.Runtime;
using System.Text;
using Lagrange.OneBot.Extensions;
using Microsoft.Extensions.Hosting;
namespace Lagrange.OneBot;
internal abstract class Program
{
public static async Task Main(string[] args)
{
string? version = Assembly
.GetAssembly(typeof(Program))
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion;
try
{
Console.ForegroundColor = ConsoleColor.Magenta;
if (Console.BufferWidth >= 45)
{
Console.WriteLine(
$$"""
__
/ / ___ ____ ________ ____ ___ ____
/ /_/ _ `/ _ `/ __/ _ `/ _ \/ _ `/ -_)
/____|_,_/\_, /_/ \_,_/_//_/\_, /\__/
/___/ ____ /___/__ __
/ __ \___ ___ / _ )___ / /_
/ /_/ / _ \/ -_) _ / _ \/ __/
\____/_//_/\__/____/\___/\__/
"""
);
}
else
Console.WriteLine("Lagrange.OneBot");
Console.ResetColor();
Console.WriteLine($"Version: {version?[^40..] ?? "unknown"}\n");
}
catch (IOException)
{
}
// AutoUpdate
var updater = new Updater.GithubUpdater();
await updater.GetConfig();
if (updater.Config.EnableAutoUpdate)
{
try
{
Console.WriteLine("Auto update enabled, Checking for updates...");
if (await updater.CheckUpdate())
{
Console.WriteLine($"Update available, downloading...");
await updater.Update();
}
else
{
Console.WriteLine("No updates available, continuing...");
}
if (updater.Config.CheckInterval > 0)
{
Console.WriteLine(
$"Interval check enabled, Next check in {updater.Config.CheckInterval} seconds."
);
updater.StartIntervalCheck();
}
}
catch (Exception e)
{
Console.WriteLine(
$"Error checking for updates: {e.Message}, please check your network connection or config file, use proxy if needed."
);
}
}
Console.OutputEncoding = Encoding.UTF8;
Console.InputEncoding = Encoding.UTF8;
GCSettings.LatencyMode = GCLatencyMode.Batch;
if (!File.Exists("appsettings.json"))
{
try
{
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);
istr.Close();
temp.Close();
Console.WriteLine(
"Please Edit the appsettings.json to set configs and press any key to continue"
);
Console.ReadKey(true);
}
catch (IOException)
{
}
}
await Host.CreateApplicationBuilder()
.ConfigureLagrangeCore()
.ConfigureOneBot()
.Build()
.InitializeMusicSigner() // Very ugly (
.RunAsync();
}
}