/// <summary> /// Метод по запуску функционирования бота /// </summary> public static void Start() { ProxyParser.LoadProxy(); setBotWithProxy(); UsersBase.getUsersFromFile(); Command.Start(); Console.ReadKey(); }
/// <summary> /// Запуск команд бота /// </summary> public static void Start() { try { Console.WriteLine("~~Пытаюсь подключится~~"); var u = Bot.TelegramBot.TestApiAsync().Result; // Console.WriteLine(u); if (u) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Соединение установленно"); Console.ForegroundColor = ConsoleColor.White; ProxyParser.SaveCurrentProxy(); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Введен не верный токен для телеграм бота"); Console.ForegroundColor = ConsoleColor.White; } Bot.TelegramBot.OnMessage += MessageParser; Bot.TelegramBot.OnCallbackQuery += TypeOfFile; Bot.TelegramBot.StartReceiving(); Console.ReadKey(); Bot.TelegramBot.StopReceiving(); } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Попытка соединения не удалась , меняем прокси"); Console.ForegroundColor = ConsoleColor.White; ProxyParser.BadProxyRemove(); Bot.setBotWithProxy(); Start(); return; } }