-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
66 lines (57 loc) · 2.87 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
// Copyright (C) 2024-2025 ZenonEl
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Эта программа является свободным программным обеспечением: вы можете распространять и/или изменять
// её на условиях Стандартной общественной лицензии GNU Affero, опубликованной
// Фондом свободного программного обеспечения, либо версии 3 лицензии, либо
// (по вашему выбору) любой более поздней версии.
using System.Globalization;
using DataBase;
using Serilog;
namespace TelegramMediaRelayBot
{
class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("============================================");
Console.WriteLine("TelegramMediaRelayBot");
Console.WriteLine("Copyright (C) 2024-2025 ZenonEl");
Console.WriteLine("This program is free software: you can redistribute it and/or modify");
Console.WriteLine("it under the terms of the GNU Affero General Public License as published");
Console.WriteLine("by the Free Software Foundation, either version 3 of the License, or");
Console.WriteLine("(at your option) any later version.");
Console.WriteLine("Source code: https://github.com/ZenonEl/TelegramMediaRelayBot");
Console.WriteLine("============================================\n");
Config.LoadConfig();
CultureInfo currentCulture = CultureInfo.CurrentUICulture;
if (Config.language != null)
{
currentCulture = new CultureInfo(Config.language);
}
Thread.CurrentThread.CurrentUICulture = currentCulture;
Thread.CurrentThread.CurrentCulture = currentCulture;
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Is(Config.logLevel)
.Enrich.FromLogContext()
.WriteTo.Console(outputTemplate: "{Timestamp:HH:mm:ss} [{Level}] {Message} {Exception}{NewLine}").CreateLogger();
try
{
Log.Information($"Log level: {Config.logLevel}");
CoreDB.initDB();
Scheduler.Scheduler.Init();
await MediaTelegramBot.TelegramBot.Start();
}
catch (Exception ex)
{
Log.Error(ex, "An error occurred in the method{MethodName}", nameof(Main));
}
finally
{
Log.CloseAndFlush();
}
}
}
}