public static void ShowGeneralInfo() { Logger.Log.Info("Configuration info -------------------"); ShowFoldersForListen(); Logger.Log.Info($"Files extension: {ConfigReader.GetFilesExtension().ToUpper()}"); Logger.Log.Info($"Search timeout: {ConfigReader.GetSearchTimeout() / 1000} seconds"); Logger.Log.Info($"Telegram message from user: +{ConfigReader.GetUserPhoneNumber()}"); Logger.Log.Info($"Telegram message to {ConfigReader.GetRecipientType()}: {GetRecipientInfo()}"); Logger.Log.Info("--------------------------------------\n"); }
/// <summary> /// When user is authenticated, TLSharp creates special file called session.dat. /// In this file TLSharp store all information needed for user session. /// So you need to authenticate user every time the session.dat file is corrupted or removed. /// </summary> public static async Task AuthUserAsync() { var client = NewClient(); await client.ConnectAsync(); if (!client.IsUserAuthorized()) { Logger.Log.Debug("Telegram client is not authorized."); var hash = await client.SendCodeRequestAsync(ConfigReader.GetUserPhoneNumber()); // authorization code will be send to the specified phone number var code = Helper.ReadTelegramCodeFromConsole(); var user = await client.MakeAuthAsync(ConfigReader.GetUserPhoneNumber(), hash, code); Logger.Log.Debug("Telegram authorization succeed."); } }