private static void ResetUserbotMethod()
        {
            var lines    = File.ReadAllText(Paths.Info.ConfigUserBotsInfo).Split(RowSeparator);
            var botInfos = new List <UserBotInfo>();

            foreach (var t in lines)
            {
                var line = t;
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                line = line.Trim();

                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                var lineInfo = line.Split(ColumnSeparator);

                var bot = new UserBotInfo();
                bot.SetApiId(lineInfo[0].Trim());
                bot.SetApiHash(lineInfo[1].Trim());
                bot.SetUserId(lineInfo[2].Trim());
                bot.SetNumberCountry(lineInfo[3].Trim());
                bot.SetNumberNumber(lineInfo[4].Trim());
                bot.SetPasswordToAuthenticate(lineInfo[5].Trim());
                bot.SetIsBot(BotTypeApi.USER_BOT);
                bot.SetMethod(lineInfo[6].Trim());

                botInfos.Add(bot);
            }

            FileSerialization.WriteToBinaryFile(Paths.Bin.ConfigUserbot, botInfos);
        }
        internal static async Task <TelegramClient> ConnectAsync(UserBotInfo userbot)
        {
            var apiId = userbot.GetApiId();

            if (apiId == null)
            {
                return(null);
            }

            TelegramClient telegramClient = null;

            try
            {
                telegramClient = new TelegramClient(apiId.Value, userbot.GetApiHash(),
                                                    sessionUserId: userbot.GetSessionUserId());
            }
            catch
            {
                ;
            }

            if (telegramClient == null)
            {
                return(null);
            }

            await telegramClient.ConnectAsync();

            if (telegramClient.IsUserAuthorized())
            {
                return(telegramClient);
            }

            var numberToAuthenticate = userbot.GetPhoneNumber();
            var hash = await telegramClient.SendCodeRequestAsync(numberToAuthenticate);

            var code = "";
            var passwordToAuthenticate = userbot.GetPasswordToAuthenticate();

            ;

            TLUser user;

            try
            {
                user = await telegramClient.MakeAuthAsync(numberToAuthenticate, hash, code);
            }
            catch (CloudPasswordNeededException ex)
            {
                Console.WriteLine(ex.Message);

                var passwordSetting = await telegramClient.GetPasswordSetting();

                var password = passwordToAuthenticate;

                user = await telegramClient.MakeAuthWithPasswordAsync(passwordSetting, password);
            }
            catch (InvalidPhoneCodeException ex)
            {
                throw new Exception(
                          "CodeToAuthenticate is wrong in the app.config file, fill it with the code you just got now by SMS/Telegram",
                          ex);
            }

            if (user != null && telegramClient.IsUserAuthorized())
            {
                return(telegramClient);
            }

            return(null);
        }