This repository has been archived by the owner on Jan 7, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Program.cs
105 lines (79 loc) · 3.3 KB
/
Program.cs
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
using Blazored.Toast;
using Newtonsoft.Json;
using ProSwapperLobby.Data;
using ProSwapperLobby.Services;
using System.Diagnostics;
public class Program
{
private static void OpenUrl(string url)
{
Process webProcess = new Process();
webProcess.StartInfo = new ProcessStartInfo() { UseShellExecute = true, FileName = url };
webProcess.Start();
}
/// <summary>
/// Kills all proccesses with the same name that is not the current process.
/// </summary>
private static void KillDuplicates()
{
Process thisProc = Process.GetCurrentProcess();
Process[] procs = Process.GetProcessesByName(thisProc.ProcessName);
foreach (var proc in procs)
{
if (proc.Id != thisProc.Id)
proc.Kill();
}
}
public static void Main()
{
#if RELEASE
if (!File.Exists("aspnetcorev2_inprocess.dll"))
{
Console.Clear();
Console.WriteLine("Please extract Pro Swapper Lobby.zip to a folder instead of doubling clicking it inside a zipping program.");
Console.ReadKey();
Process.GetCurrentProcess().Kill();
}
#endif
string url = "http://localhost:6969/";
KillDuplicates();
var builder = WebApplication.CreateBuilder();
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
// builder.Services.AddSingleton<MainService>();
builder.Services.AddBlazoredToast();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
}
app.UseStaticFiles();
app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
string data = MainService.httpClient.GetStringAsync("https://pro-swapper.github.io/api/LobbyAPI.json").Result;
MainService.ProSwapperAPI = JsonConvert.DeserializeObject<ProSwapperLobby.Data.API.Rootobject>(data);
if (MainService.ProSwapperAPI.Disable == true)
{
Console.Clear();
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Pro Swapper is currently down: ");
Console.Write(MainService.ProSwapperAPI.DisableMessage);
Console.ReadLine();
Process.GetCurrentProcess().Kill();
}
MainService.DiscordWidgetAPI = JsonConvert.DeserializeObject<DiscordWidgetAPI.Root>(MainService.httpClient.GetStringAsync($"https://discord.com/api/guilds/{MainService.ProSwapperAPI.DiscordID}/widget.json").Result);
ProSwapperLobby.DiscordRPC.InitializeRPC();
Directory.CreateDirectory(MainService.ProSwapperFolder + "\\.Config");
MainService.InitConfig();
Console.Clear();
Console.Title = "Pro Swapper Lobby | Made by Kye#5000";
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Welcome to Pro Swapper Lobby!");
Console.WriteLine("You will be directed to linkvertise so you can access Pro Swapper Lobby, leave Pro Swapper Lobby opened if you don't want to go through linkvertise again.");
OpenUrl("https://direct-link.net/86737/pro-swapper-lobby2");
app.Run(url);
}
}