bonuska2/SimpleTGBot/Program.cs

42 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Text;
using SimpleTGBot.Logging;
namespace SimpleTGBot;
public static class Program
{
// Метод main немного видоизменился для асинхронной работы
public static async Task<int> Main(string[] args)
{
if (Environment.OSVersion.Platform != PlatformID.Win32NT || Environment.OSVersion.Version < new Version(6, 1))
{
Console.WriteLine("К сожалению, из-за используемых графических функций бот поддерживает только Windows начиная с версии 7.");
return 8;
}
// Православная кодировка
Console.OutputEncoding = Encoding.UTF8;
string? botToken = Config.TryReadBotTokenFile();
if (botToken == null)
{
Console.WriteLine($"Файл {Config.DEFAULT_BOT_TOKEN_FILENAME} не найден. Вы можете указать токен вручную:");
Console.Write("$ ");
botToken = Console.ReadLine();
}
if (botToken == null)
{
return 1;
}
Logger logger = new Logger();
logger.Sinks.Add(new StdoutSink());
TelegramBot telegramBot = new TelegramBot(botToken, logger);
await telegramBot.Run();
logger.Dispose();
return 0;
}
}