public void FollowUsingURLs(List<string> list_user_id_toFollow, int minDelay, int maxDelay, bool OtherUser) { int counter = 0; int counterChecktotlaFollowr = 0; try { //Login(); try { DataSet Dataset = new DataSet(); if (NoOfFollowPerDay_ChkBox == true) { Dataset = CheckLimitationOfPerID(Username); if (Dataset != null) { if (Dataset.Tables.Count != 0) { if (Dataset.Tables[0].Rows.Count != 0) { Log("[ " + DateTime.Now + " ] => [ No Of Follow Per Day - " + NoOfFollowPerDay + " ]"); int DataSetTableRowsCount = Dataset.Tables[0].Rows.Count; RemainingNoOfFollowPerDay = NoOfFollowPerDay - DataSetTableRowsCount; } else { RemainingNoOfFollowPerDay = NoOfFollowPerDay; } } else { RemainingNoOfFollowPerDay = NoOfFollowPerDay; } } } else { RemainingNoOfFollowPerDay = TweetAccountManager.NoOfFollowPerDay; } } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- NoOfFollowPerDay_ChkBox --> " + ex.Message, Globals.Path_FollowerErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- FollowUsingURLs() -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } ///Login if Not Logged in if (!IsLoggedIn) { Login(); } ///Return if Suspended if (AccountStatus == "Account Suspended") { Log("[ " + DateTime.Now + " ] => [ " + Username + " : Suspended ]"); return; } if (IsLoggedIn) { #region trial last tweet date code //if (UseDateLastTweeted) //{ // string PageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + Screen_name), "", ""); // string[] Array = Regex.Split(PageSource, "href="); // foreach (string item in Array) // { // if (item.Contains(Screen_name + "/status/") && item.Contains("tweet-timestamp js-permalink js-nav")) // { // try // { // int startIndex = item.IndexOf("title=\""); // string Start = item.Substring(startIndex).Replace("title=\"", ""); // int endIndex = Start.IndexOf("\" >"); // string End = Start.Substring(0, endIndex); // string[] array = Regex.Split(End, " "); // DateTime lastTweetDate = new DateTime(Convert.ToInt32(array[5]), 08, Convert.ToInt32(array[3]), 12, 12, 12); // DateTime dt_Now = DateTime.Now; // TimeSpan dt_Difference = lastTweetDate.Subtract(dt_Now); // TimeSpan t = dt_Now - lastTweetDate; // double NrOfDays = t.TotalDays; // if (dt_Difference.Days >= LastTweetDays) // { // Log("Not Followed as Last Tweeted Day is greated than specified For : " + Username); // continue; // } // } // catch (Exception ex) // { // } // } // } //} #endregion int NoOfFollowCounter = 0; clsDBQueryManager queryManager = new clsDBQueryManager(); TwitterDataScrapper dataScrapper = new TwitterDataScrapper(); ///Get list of Already Followings List<string> lst_AlreadyUserid = new List<string>(); ; List<string> lst_AlreadyUserName = new List<string>(); if (list_user_id_toFollow.Count > 0 && !string.IsNullOrEmpty(list_user_id_toFollow[0])) { foreach (string user_id_toFollow in list_user_id_toFollow) { if (NoOfFollowPerDay_ChkBox) { if (NoOfFollowCounter >= RemainingNoOfFollowPerDay) { Log("[ " + DateTime.Now + " ] => [ Finish Follow Limit " + NoOfFollowPerDay + " Today ]"); break; } } string followStatus; string user_id = string.Empty; string pagesource = string.Empty; string Screen_name = string.Empty; ///Getting Username from User id ///Working from both username n id clsDBQueryManager DB = new clsDBQueryManager(); #region commented for choosing username and userid //if (!GlobusRegex.ValidateNumber(user_id_toFollow))//(!IsItNumber(user_id_toFollow)) //if (frmMain_NewUI.IsFollowerScreanName) //{ // DataSet ds = DB.GetUserId(user_id_toFollow); // if (ds.Tables.Count != 0 && ds.Tables[0].Rows.Count > 0) // { // foreach (DataRow dataRow in ds.Tables["tb_UsernameDetails"].Rows) // { // user_id = dataRow.ItemArray[0].ToString(); // } // } //} //else if (frmMain_NewUI.IsfollowerUserId) //{ // user_id = user_id_toFollow; // DataSet ds = DB.GetUserName(user_id_toFollow); // if (ds.Tables[0].Rows.Count > 0) // { // foreach (DataRow dataRow in ds.Tables["tb_UsernameDetails"].Rows) // { // user_id = dataRow.ItemArray[0].ToString(); // } // } //} //else //{ // user_id = string.Empty; // Log("Please enter Valid user Id Or Screan name. "); //} #endregion #region get check unfollow befor if (TweetAccountManager.UseUnfollowedBeforeFilter) { List<string> lst_AlreadyExist = new List<string>(); if (frmMain_NewUI.IsFollowerScreenName) { lst_AlreadyExist = DB.SelectUnFollowDUsernameID_List(Username); bool isAlreadyExist = lst_AlreadyExist.Exists(s => (s == user_id_toFollow)); if (isAlreadyExist) { Log("[ " + DateTime.Now + " ] => [ " + user_id_toFollow + " Is already Unfollowed before from " + Username + " ]"); continue; } } else if (frmMain_NewUI.IsfollowerUserId && BaseLib.NumberHelper.ValidateNumber(user_id_toFollow)) { lst_AlreadyExist = DB.SelectUnFollowedUsername_List(Username); bool isAlreadyExist = lst_AlreadyExist.Exists(s => (s == user_id_toFollow)); if (isAlreadyExist) { Log("[ " + DateTime.Now + " ] => [ " + user_id_toFollow + " Is already Unfollowed before from " + Username + " ]"); continue; } } } #endregion ///Counter For Follow NoOfFollowCounter++; //Check if user_id_toFollow is already being followed or not #region user_id_toFollow is already being followed or not bool isAlreadyFollowed = false; Log("[ " + DateTime.Now + " ] => [ Checking For Already Followed For " + user_id_toFollow + " From " + Username + " ]"); if (frmMain_NewUI.IsFollowerScreenName) { lst_AlreadyUserName = queryManager.SelectFollowDUsername_List(Username); isAlreadyFollowed = lst_AlreadyUserName.Exists(s => (s == user_id_toFollow)); Screen_name = user_id_toFollow; } else if (frmMain_NewUI.IsfollowerUserId && BaseLib.NumberHelper.ValidateNumber(user_id_toFollow)) { lst_AlreadyUserid = queryManager.SelectFollowDUsernameID_List(Username); isAlreadyFollowed = lst_AlreadyUserid.Exists(s => (s == user_id_toFollow)); user_id = user_id_toFollow; } else { Log("[ " + DateTime.Now + " ] => [ UserId/ScreenName Not In Correct Format :- " + user_id_toFollow + " ]"); return; } #endregion if (!isAlreadyFollowed) //If not already being followed, follow now { ///Use FollowingsFollowers Ratio Filter if (UseRatioFilter) { int FollowingsFollowersRatio_user_id = 0; //Check FollowingsFollowers Ratio of this user_id try { string returnstatusFollower = string.Empty; string returnstatusFollowing = string.Empty; List<string> Following = dataScrapper.GetFollowings(user_id, out returnstatusFollowing); List<string> Follower = dataScrapper.GetFollowers(user_id, out returnstatusFollower); int count_Followings_user_id = Following.Count; int count_Followers_user_id = Follower.Count; FollowingsFollowersRatio_user_id = (count_Followings_user_id * 100) / count_Followers_user_id; } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingURLs() -- UseRatioFilter --> " + ex.Message, Globals.Path_FollowerErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- FollowUsingURLs() -- UseRatioFilter -- " + Username + " -- " + user_id_toFollow + " --> " + ex.Message, Globals.Path_TweetAccountManager); } if (!(FollowingsFollowersRatio_user_id >= FollowingsFollowersRatio)) //If FollowingsFollowersRatio_user_id is less than Required, continue with next user_id_toFollow { Log("[ " + DateTime.Now + " ] => [ Not Followed as FollowingsFollowersRatio : " + FollowingsFollowersRatio_user_id + " for " + user_id_toFollow + " with : " + Username + " ]"); continue; } } #region Old Unfollowed Before Code //if (UseUnfollowedBeforeFilter) //{ // try // { // List<string> lst_Followings_Current = dataScrapper.GetFollowings(user_id); // //lst_AlreadyFollowings // } // catch { } //} #endregion #region Old Tweet Last Day Code if (UseDateLastTweeted && !string.IsNullOrEmpty(user_id)) { try { string strLastTweetDate = dataScrapper.GetUserLastTweetDate(user_id); DateTime dt_LastTweetDate = DateTime.Parse(strLastTweetDate); DateTime dt_Now = DateTime.Now; TimeSpan dt_Difference = dt_Now.Subtract(dt_LastTweetDate); if (dt_Difference.Days >= LastTweetDays) { Log("[ " + DateTime.Now + " ] => [ Not Followed as Last Tweeted Day is greated than specified for :" + user_id_toFollow + " with : " + Username + " ]"); continue; } } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingURLs() -- Last Tweeted --> " + ex.Message, Globals.Path_FollowerErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- FollowUsingURLs() -- UseDateLastTweeted -- " + Username + " -- " + user_id_toFollow + " --> " + ex.Message, Globals.Path_TweetAccountManager); } } #endregion #region Check Profile Picture if (IscontainPicture) { Log("[ " + DateTime.Now + " ] => [ Checking Profile Image For : " + user_id_toFollow + " ]"); string containsIamge = TwitterDataScrapper.GetPhotoFromUsername_New(Screen_name); Thread.Sleep(1000); if (containsIamge == "true") { Log("[ " + DateTime.Now + " ] => [ " + user_id_toFollow + " Contains Image ]"); } else if (containsIamge == "false") { Log("[ " + DateTime.Now + " ] => [ " + user_id_toFollow + " Not Contains Image So Not Following ]"); continue; } else if (containsIamge == "Rate limit exceeded") { Log("[ " + DateTime.Now + " ] => [ Cannot Make Request. Rate limit exceeded ]"); Log("[ " + DateTime.Now + " ] => [ Please Try After Some Time ]"); Thread.Sleep(5000); } } #endregion #region Checking Tweet in the last xx days. if (IsTweetedInXdays) { Log("[ " + DateTime.Now + " ] => [checking tweeted in the last " + daysTweetedInxdays + " days for User :"******" ]"); try { string PageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + user_id_toFollow), "", ""); string dateoflastTweet = globusHttpHelper.getBetween(PageSource, "ProfileTweet-timestamp js-permalink js-nav js-tooltip", ">").Replace("\"","").Trim(); try { dateoflastTweet = dateoflastTweet.Split('-')[1].Trim(); DateTime dt_LastTweetDate = DateTime.Parse(dateoflastTweet); DateTime dt_Now = DateTime.Now; TimeSpan dt_Difference = dt_Now.Subtract(dt_LastTweetDate); if (dt_Difference.Days >= Convert.ToInt32(daysTweetedInxdays)) { Log("[ " + DateTime.Now + " ] => [ Not Followed as Last Tweeted Day is greated than specified for :" + user_id_toFollow + " with : " + Username + " ]"); continue; } } catch { } } catch (Exception ex) { } } #endregion int delay = 10 * 1000; int delay1 = 10 * 1000; try { if (Globals.IsGlobalDelay && Globals.IsCheckValueOfDelay) { if (Globals.FollowerRunningText == "FollowerModule" && Globals.TweetRunningText == "TweetModule") { delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); delay1 = RandomNumberGenerator.GenerateRandom(Globals.MinGlobalDelay, Globals.MaxGlobalDelay); } else { delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); } } else { delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); } } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingURLs() -- delay --> " + ex.Message, Globals.Path_FollowerErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- FollowUsingURLs() -- delay -- " + Username + " -- " + user_id_toFollow + " --> " + ex.Message, Globals.Path_TweetAccountManager); } if (Globals.IsCampaign) { lock (locker_que_Follower) { if (string.IsNullOrEmpty(user_id)) { try { string PageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/" + user_id), "", ""); int startindex = PageSource.IndexOf("data-user-id=\""); string start = PageSource.Substring(startindex).Replace("data-user-id=\"", ""); int endindex = start.IndexOf("\""); string end = start.Substring(0, endindex); user_id = end; } catch (Exception ex) { } } if (string.IsNullOrEmpty(Screen_name)) { try { string PageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/account/redirect_by_id?id=" + user_id), "", ""); int startindex = PageSource.IndexOf("user-style-"); string start = PageSource.Substring(startindex).Replace("user-style-", ""); int endindex = start.IndexOf("\""); string end = start.Substring(0, endindex); Screen_name = end; } catch (Exception ex) { } } string strQuery = "Select * from tb_CampaignReport Where Follower = '" + user_id + "' OR ScreenName = '" + Screen_name + "' AND Campaign_Name = '" + Globals.Campaign_Name + "' "; DataSet ds = DataBaseHandler.SelectQuery(strQuery, "tb_CampaignReport"); if (ds.Tables[0].Rows.Count > 0 && Globals.IsCampaign) { Log("[ " + DateTime.Now + " ] => [ Already Followed Userid : " + user_id + " >>>> ScreenName : " + Screen_name + " ]"); } else { follower.FollowUsingProfileID_New(ref globusHttpHelper, pgSrc_Profile, postAuthenticityToken, user_id_toFollow, out followStatus); string Screen_Name = string.Empty; string userid = string.Empty; if (NumberHelper.ValidateNumber(user_id)) { userid = user_id; } else { Screen_name = user_id; } Log("[ " + DateTime.Now + " ] => [ Followed Userid : " + user_id + " >>>> ScreenName : " + Screen_name + " ]"); Log("[ " + DateTime.Now + " ] => [ Adding Follower in DataBase ]"); string query = "INSERT INTO tb_CampaignReport (Campaign_Name, UserName, Follower , ScreenName) VALUES ('" + Globals.Campaign_Name + "', '" + Username + "', '" + user_id + "' , '" + Screen_name + "')"; DataBaseHandler.InsertQuery(query, "tb_CampaignReport"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + user_id + ":" + Screen_name + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword, Globals.path_SuccessfullyFollowAccounts); } } } else { follower.FollowUsingProfileID_New(ref globusHttpHelper, pgSrc_Profile, postAuthenticityToken, user_id_toFollow, out followStatus); if (followStatus == "followed") { Globals.totalcountFollower++; counterChecktotlaFollowr++; Log("[ " + DateTime.Now + " ] => [ >> Followed >> " + user_id_toFollow + " by " + Username + " ]"); //Adding in text File FOr SuccessFull Paths GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + user_id_toFollow + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword, Globals.path_SuccessfullyFollowAccounts); try { string username = string.Empty; string userid = string.Empty; if (NumberHelper.ValidateNumber(user_id_toFollow)) { username = TwitterSignup.TwitterSignup_TwitterDataScrapper.GetUserNameFromUserId(user_id_toFollow); userid = user_id_toFollow; } else { string outStatus = string.Empty; userid = TwitterSignup.TwitterSignup_TwitterDataScrapper.GetUserIDFromUsername(user_id_toFollow, out outStatus); username = user_id_toFollow; } queryManager.InsertUpdateFollowTable(Username, userid, username); } catch (Exception) { } try { RemoveFollwerFromTxtFile(FileFollowUrlPath, user_id_toFollow); } catch { } } else if (followStatus == "Already Followed") { Globals.totalcountFollower++; Log("[ " + DateTime.Now + " ] => [ >> Already Followed >> " + user_id_toFollow + " by " + Username + " ]"); try { RemoveFollwerFromTxtFile(FileFollowUrlPath, user_id_toFollow); } catch { } } else { Log("[ " + DateTime.Now + " ] => [ >> Couldn't Follow >> " + user_id_toFollow + " by " + Username + " ]"); //Adding in text File for Failed Followed Paths GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + user_id + ":" + Screen_name + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword, Globals.path_FailedToFollowAccounts); } //if user is check fast follow option then delay is not working on that condition ...!! if (!frmMain_NewUI.IsFastfollow) { if (Globals.IsGlobalDelay && Globals.IsCheckValueOfDelay) { if (Globals.FollowerRunningText == "FollowerModule" && Globals.TweetRunningText == "TweetModule") { //delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); Log("[ " + DateTime.Now + " ] => [ Follow Delayed for " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); //delay1 = RandomNumberGenerator.GenerateRandom(Globals.MinGlobalDelay, Globals.MaxGlobalDelay); Log("[ " + DateTime.Now + " ] => [ Follow Global Delayed for " + delay1 + " Seconds ]"); Thread.Sleep(delay1 * 1000); } else { Log("[ " + DateTime.Now + " ] => [ Follow Delayed for " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); } } else { Log("[ " + DateTime.Now + " ] => [ Follow Delayed for " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); } } if (OtherUser) { counter++; if (counter == noOFFollows) { break; } } } } else //Already Being Followed { Log("[ " + DateTime.Now + " ] => [ Already Followed : " + user_id_toFollow + " with : " + Username + " ]"); try { RemoveFollwerFromTxtFile(FileFollowUrlPath, user_id_toFollow); } catch { } } } } else { Log("[ " + DateTime.Now + " ] => [ Sorry No User To Follow"); return; } } else { Log("[ " + DateTime.Now + " ] => [ >> Couldn't Login with>> " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword, Globals.path_FailedLoginAccounts); } } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> FollowUsingURLs() --> " + ex.Message, Globals.Path_FollowerErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- FollowUsingURLs() -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } finally { Log("[ " + DateTime.Now + " ] => [ Finished Following All Users For Username : "******" ]"); Log("------------------------------------------------------------------------------------------------------------------------------------------"); GlobusFileHelper.AppendStringToTextfileNewLine("Module Follow count : " + counterChecktotlaFollowr + " using UserName: " + Username, Globals.path_CountNoOfProcessDone); } }