public string DirectMessage(string Screen_name) { string ReturnString = string.Empty; try { string MessageText = string.Empty; string PostedMessage = string.Empty; lock (locker_DirectMessage) { if (que_DirectMessage.Count > 0) { MessageText = que_DirectMessage.Dequeue(); } else { Log("[ " + DateTime.Now + " ] => [All Loaded Reply Messages Used ]"); } } string PageSource = globusHttpHelper.getHtmlfromUrl(new Uri("https://twitter.com/#!/followers"), "", ""); string PostAuthenticityToken = string.Empty; try { int startIndex = PageSource.IndexOf("\"postAuthenticityToken\""); if (startIndex > 0) { string Start = PageSource.Substring(startIndex); int endIndex = Start.IndexOf("\"})"); string End = Start.Substring(0, endIndex).Replace("\"postAuthenticityToken\"", "").Replace(":", "").Replace("\"", ""); PostAuthenticityToken = End; } startIndex = PageSource.IndexOf("formAuthenticityToken"); if (startIndex > 0) { string start = PageSource.Substring(startIndex).Replace("formAuthenticityToken", ""); int endIndex = start.IndexOf("\","); string end = start.Substring(0, endIndex).Replace("\"", "").Replace(":", ""); PostAuthenticityToken = end; } } catch (Exception ex) { ReturnString = "Error"; return ReturnString; } string Post = "https://api.twitter.com/1/direct_messages/new.json"; string PostData = string.Empty; if (!NumberHelper.ValidateNumber(Screen_name)) { PostData = "screen_name=" + Screen_name + "&text=" + MessageText; } else { PostData = "user_id=" + userID + "&text=" + MessageText; } string pageSource = globusHttpHelper.postFormData(new Uri(Post), PostData, "", string.Empty, "", "true", ""); if (pageSource.Contains("sender\":") && pageSource.Contains(MessageText)) { ReturnString = "Success: " + MessageText; clsDBQueryManager DataBase = new clsDBQueryManager(); string dbTweetMessage = StringEncoderDecoder.Encode(MessageText); string OtherUser = Screen_name; if (string.IsNullOrEmpty(Screen_name)) { OtherUser = userID; } DataBase.InsertMessageData(Username, "Message", OtherUser, dbTweetMessage); } } catch (Exception ex) { ReturnString = "Error"; Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- DirectMessage() --> " + ex.Message, Globals.Path_DMErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- DirectMessage() -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } return ReturnString; }
public void Tweet(List<string> lst_tweetMessage, int minDelay, int maxDelay) { //Login(); //if (true) if (!IsLoggedIn) { Login(); } if (IsNotSuspended) { if (IsLoggedIn) { int counter_Tweet = 0; #region <<Set delay time if Minimum or maximum delay time is not set >> //Set delay time if Minimum or maximum delay time is not set if (minDelay == 0 || maxDelay == 0) { try { if (minDelay == 0) { minDelay = 0; } if (maxDelay == 0) { maxDelay = 10; } } catch (Exception) { } } #endregion #region Separate Tweets per account if (!AllTweetsPerAccount) { while (que_TweetMessages.Count > 0) { if (!TweetPerDay) { if (counter_Tweet >= NoOfTweets) { break; } } else if (TweetPerDay) { if (AlreadyTweeted >= NoOfTweetPerDay) { Log("[ " + DateTime.Now + " ] => [ Already Tweeted " + AlreadyTweeted + " ]"); break; } } string tweetMessage = ""; string tweetStatus; #region commented //int delay = 10 * 1000; //int delay = 0; //try //{ // if (DelayTweet > 0) // { // //int SomeDelay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); // //delay = DelayTweet - SomeDelay; // //if (delay < 0) // //{ // // delay = RandomNumberGenerator.GenerateRandom(0, 20); // //} // //TimeSpan T = EndTime - DateTime.Now; // //if (T.TotalSeconds <= 0) // //{ // // Log("Time Completed Tweeting Stopped For " + Username); // // break; // //} // if (DelayTweet > 0) // { // int SomeDelay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); // delay = DelayTweet - SomeDelay; // TimeSpan T = EndTime - DateTime.Now; // if (T.TotalSeconds <= 0) // { // Log("[ " + DateTime.Now + " ] => [ Time Completed Tweeting Stopped For " + Username + " ]"); // break; // } // } // else // { // delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); // } // } // else // { // delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); // } //} //catch (Exception ex) //{ // GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Tweet() -- DelayTweet --> " + ex.Message, Globals.Path_TweetingErroLog); // GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- Tweet() --> " + ex.Message, Globals.Path_TweetAccountManager); //} #endregion lock (locker_que_TweetMessage) { if (que_TweetMessages.Count > 0) { try { tweetMessage = que_TweetMessages.Dequeue(); } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> StartTweetingMultithreaded() -- locker_que_TweetMessage --> " + ex.Message, Globals.Path_TweetingErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- Tweet() --> " + ex.Message, Globals.Path_TweetAccountManager); } } else { Log("[ " + DateTime.Now + " ] => [ All Loaded Tweet Messages Used ]"); //break; } } if (UseHashTags) { lock (locker_que_hashtags) { if (que_TweetMessages_Hashtags.Count > 0) { try { Hashtags = que_TweetMessages_Hashtags.Dequeue(); } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> StartTweetingMultithreaded() -- Tweet -- que_TweetMessages_Hashtags --> " + ex.Message, Globals.Path_TweetingErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- Tweet -- que_TweetMessages_Hashtags --> " + ex.Message, Globals.Path_TweetAccountManager); } } else { Log("[ " + DateTime.Now + " ] => [ All Loaded Hash Tags Are Used ]"); //break; } } } if (!string.IsNullOrEmpty(Hashtags)) { tweetMessage = Hashtags + " " + tweetMessage; } tweeter.Tweet(ref globusHttpHelper, postAuthenticityToken, tweetMessage, out tweetStatus); if (tweetStatus == "posted") { try { Log("[ " + DateTime.Now + " ] => [ >> Tweeted >> " + tweetMessage + " by " + Username + " ]"); clsDBQueryManager DataBase = new clsDBQueryManager(); string dbTweetMessage = StringEncoderDecoder.Encode(tweetMessage); DataBase.InsertMessageData(Username, "Tweet", "null", dbTweetMessage); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword + ":" + tweetMessage, Globals.path_SuccessfullyTweetAccounts); //Log("[ " + DateTime.Now + " ] => [ Tweet Delayed for " + delay + " Seconds ]"); try { RemoveFollwerFromTxtFile(FileTweetPath, tweetMessage); } catch { } //Thread.Sleep(delay * 1000); counter_Tweet++; AlreadyTweeted++; Globals.totalcountTweet++; } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> StartTweetingMultithreaded() -- tweetStatus --> " + ex.Message, Globals.Path_TweetingErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- Tweet() -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } } else { if (UseHashTags) { que_TweetMessages_Hashtags.Enqueue(Hashtags); que_TweetMessages.Enqueue(tweetMessage); } else { que_TweetMessages.Enqueue(tweetMessage); } Log("[ " + DateTime.Now + " ] => [ >>Couldn't Post >> " + tweetMessage + " by " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword + ":" + tweetMessage, Globals.path_FailedToTweetAccounts); //Thread.Sleep(delay * 1000); //delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); //Thread.Sleep(delay * 1000); //Log("[ " + DateTime.Now + " ] => [ Tweet Delayed for " + delay + " Seconds ]"); } //int delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); 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); Log("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); Log("[ " + DateTime.Now + " ] => [ Global Delay for Tweet: " + delay1 + " Seconds ]"); Thread.Sleep(delay1 * 1000); } else { delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); Log("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); } } else { delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); Log("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); } } catch { } //Log("[ " + DateTime.Now + " ] => [ Delay for : " + delay + " Seconds ]"); //Thread.Sleep(delay * 1000); } } #endregion #region All Tweets per account else { while (que_TweetMessages_PerAccount.Count > 0) { //if (!TweetPerDay) //{ // if (counter_Tweet >= NoOfTweets) // { // break; // } //} //else if (TweetPerDay) //{ // if (AlreadyTweeted >= NoOfTweetPerDay) // { // Log("Already Tweeted " + AlreadyTweeted); // break; // } //} string tweetMessage = ""; string tweetStatus; int delay = 0; int delay1 = 0; try { if (DelayTweet > 0) { //int SomeDelay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); int SomeDelay = 10 * 1000; try { if (Globals.IsGlobalDelay && Globals.IsCheckValueOfDelay) { SomeDelay = RandomNumberGenerator.GenerateRandom(Globals.MinGlobalDelay, Globals.MaxGlobalDelay); } else { SomeDelay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); } } catch { } delay = DelayTweet - SomeDelay; TimeSpan T = EndTime - DateTime.Now; if (T.TotalSeconds <= 0) { Log("[ " + DateTime.Now + " ] => [ Time Completed Tweeting Stopped For " + Username + " ]"); break; } } else { delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); } } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Tweet() -- DelayTweet --> " + ex.Message, Globals.Path_TweetingErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- Tweet() --> " + ex.Message, Globals.Path_TweetAccountManager); } lock (locker_que_TweetMessage) { if (que_TweetMessages_PerAccount.Count > 0) { try { tweetMessage = que_TweetMessages_PerAccount.Dequeue(); } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> StartTweetingMultithreaded() -- locker_que_TweetMessage --> " + ex.Message, Globals.Path_TweetingErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- Tweet() --> " + ex.Message, Globals.Path_TweetAccountManager); } } else { Log("[ " + DateTime.Now + " ] => [ All Loaded Tweet Messages Used ]"); //break; } } if (UseHashTags) { lock (locker_que_hashtags) { if (que_TweetMessages_Hashtags.Count > 0) { try { Hashtags = que_TweetMessages_Hashtags.Dequeue(); } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> StartTweetingMultithreaded() -- Tweet -- que_TweetMessages_Hashtags --> " + ex.Message, Globals.Path_TweetingErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- Tweet -- que_TweetMessages_Hashtags --> " + ex.Message, Globals.Path_TweetAccountManager); } } else { Log("[ " + DateTime.Now + " ] => [ All Loaded Hash Tags Are Used ]"); //break; } } } if (!string.IsNullOrEmpty(Hashtags)) { tweetMessage = Hashtags + " " + tweetMessage; } tweeter.Tweet(ref globusHttpHelper, postAuthenticityToken, tweetMessage, out tweetStatus); if (tweetStatus == "posted") { try { Log("[ " + DateTime.Now + " ] => [ >> Tweeted >> " + tweetMessage + " by " + Username + " ]"); clsDBQueryManager DataBase = new clsDBQueryManager(); string dbTweetMessage = StringEncoderDecoder.Encode(tweetMessage); DataBase.InsertMessageData(Username, "Tweet", "null", dbTweetMessage); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword + ":" + tweetMessage, Globals.path_SuccessfullyTweetAccounts); //Log("[ " + DateTime.Now + " ] => [ Tweet Delayed for " + delay + " Seconds ]"); //Thread.Sleep(delay * 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); Log("[ " + DateTime.Now + " ] => [ Tweet Delayed for " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); Log("[ " + DateTime.Now + " ] => [ Global Delay for Tweet: " + delay1 + " Seconds ]"); Thread.Sleep(delay1 * 1000); } else { delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); Log("[ " + DateTime.Now + " ] => [ Tweet Delayed for " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); } } else { delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); Log("[ " + DateTime.Now + " ] => [ Tweet Delayed for " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); } } catch { } counter_Tweet++; AlreadyTweeted++; Globals.totalcountTweet++; } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> StartTweetingMultithreaded() -- tweetStatus --> " + ex.Message, Globals.Path_TweetingErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- Tweet() -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } try { RemoveFollwerFromTxtFile(FileTweetPath, tweetMessage); } catch { } } else { Log("[ " + DateTime.Now + " ] => [ >>Couldn't Post >> " + tweetMessage + " by " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword + ":" + tweetMessage, Globals.path_FailedToTweetAccounts); //Thread.Sleep(delay * 1000); //Log("[ " + DateTime.Now + " ] => [ Tweet Delayed for " + delay + " Seconds ]"); 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); Log("[ " + DateTime.Now + " ] => [ Tweet Delayed for " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); Log("[ " + DateTime.Now + " ] => [ Global Delay for Tweet: " + delay1 + " Seconds ]"); Thread.Sleep(delay1 * 1000); } else { delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); Log("[ " + DateTime.Now + " ] => [ Tweet Delayed for " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); } } else { delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); Log("[ " + DateTime.Now + " ] => [ Tweet Delayed for " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); } } catch { } } } } #endregion GlobusFileHelper.AppendStringToTextfileNewLine("Module Tweet count : " + counter_Tweet + " using UserName: "******"[ " + DateTime.Now + " ] => [ Finished Tweeting with : " + Username + " ]"); Log("------------------------------------------------------------------------------------------------------------------------------------------"); } else { Log("[ " + DateTime.Now + " ] => [ Couldn't log in with " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword, Globals.path_FailedLoginAccounts); } } else if (Globals.proxyNotWorking) { Globals.proxyNotWorking = false; Log("[ " + DateTime.Now + " ] => [ " + Username + ">>Error in Login. ]"); return; } else { clsDBQueryManager database = new clsDBQueryManager(); database.UpdateSuspendedAcc(Username); Log("[ " + DateTime.Now + " ] => [ " + Username + ">>Account Suspended ]"); return; } }
public void StartWaitAndReply(string tweetKeyword) { List<string> lstTweetImages = new List<string>(); try { if (!IsLoggedIn) { Login(); } int counterDataScraped = 0; if (IsLoggedIn) { if (IsNotSuspended) { TwitterDataScrapper tweetScrapper = new TwitterDataScrapper(); lst_Struct_TweetData = tweetScrapper.GetTweetData_WaitReply(tweetKeyword); Log("[ " + DateTime.Now + " ] => [ Extracted " + lst_Struct_TweetData.Count + " Tweet Ids ]"); if (IsTweetWithImage) { if (!Directory.Exists(ImageFolderPath)) { Log("[ " + DateTime.Now + " ] => [ Image Folder Does't Exist. ]"); return; } ///Load Image ... lstTweetImages = GetImagePathFromFolder(ImageFolderPath); if (lstTweetImages.Count != 0) { if (lstTweetImages.Count < listTweetMessages.Count) { int remaining = listTweetMessages.Count - lstTweetImages.Count; for (int i = 0; i < remaining; i++) { string Imagepath = string.Empty; try { Imagepath = lstTweetImages[i]; } catch (Exception ex) { i = 0; Imagepath = lstTweetImages[i]; } lstTweetImages.Add(Imagepath); } } else { ///if images is greater than messages. } } else { Log("[ " + DateTime.Now + " ] => [ Please Folder is Empty. Please add images in :- " + ImageFolderPath + " ]"); return; } ///print number of Images ... Log("[ " + DateTime.Now + " ] => [ " + lstTweetImages.Count() + " Images uploaded. ]"); foreach (string item in lstTweetImages) { que_ImagePath_WaitAndReply.Enqueue(item); } } while (que_TweetMessages_WaitAndReply.Count > 0) { if (que_ReplyMessages_WaitAndReply.Count <= 0) { break; } if (que_TweetMessages_WaitAndReply.Count <= 0) { break; } #region MyRegion ////Tweet ////listTweetMessages = Randomiser.Shuffle(listTweetMessages).ToList(); //foreach (string item in listTweetMessages) //{ // que_TweetMessages.Enqueue(item); //} ////listTweetMessages = Randomiser.Shuffle(listTweetMessages).ToList(); //foreach (string item in listReplyMessages) //{ // que_ReplyMessages.Enqueue(item); //} #endregion int countTweetsSent = 0; int interval = WaitAndReplyInterval; while (countTweetsSent < noOfTweetsPerReply) { //Tweet string tweetStatus; string tweetMessage = ""; string ImagePath=""; #region MyRegion //if (que_TweetMessages.Count == 0) //{ // //listTweetMessages = Randomiser.Shuffle(listTweetMessages).ToList(); // foreach (string item in listTweetMessages) // { // que_TweetMessages.Enqueue(item); // } //} #endregion lock (locker_que_TweetMessages_WaitAndReply) { if (que_TweetMessages_WaitAndReply.Count > 0) { try { tweetMessage = que_TweetMessages_WaitAndReply.Dequeue(); ImagePath = que_ImagePath_WaitAndReply.Dequeue(); } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- locker_que_TweetMessages_WaitAndReply -- --> " + ex.Message, Globals.Path_WaitNreplyErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- StartWaitAndReply() -- locker_que_TweetMessages_WaitAndReply -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } } else { Log("[ " + DateTime.Now + " ] => [All Loaded Tweet Messages Used ]"); break; } } if (IsTweetWithImage) { tweeter.TweetMessageWithImage(ref globusHttpHelper, postAuthenticityToken, tweetMessage, ImagePath, out tweetStatus); if (tweetStatus == "posted") { Log("[ " + DateTime.Now + " ] => [ Tweeted : " + tweetMessage + " with image:"+ImagePath+" by " + Username + " ]"); clsDBQueryManager DataBase = new clsDBQueryManager(); string dbTweetMessage = StringEncoderDecoder.Encode(tweetMessage); DataBase.InsertMessageData(Username, "Tweet", "", dbTweetMessage); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword+":"+tweetMessage, Globals.path_SuccessfullyTweetAccounts); countTweetsSent++; if (!waitAndReplyIsIntervalInsec) { Log("[ " + DateTime.Now + " ] => [ Delay For : " + TimeSpan.FromMilliseconds(interval).Minutes + " Minutes ]"); Thread.Sleep(interval); } else { try { interval = RandomNumberGenerator.GenerateRandom(waitAndReplyMinInterval, waitAndReplyMaxInterval); } catch { } Log("[ " + DateTime.Now + " ] => [ Delay For : " + interval + " seconds. ]"); interval = interval * 1000; Thread.Sleep(interval); } } else { Log("[ " + DateTime.Now + " ] => [ Couldn't Post : " + tweetMessage + " with image:"+ImagePath+" by " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword + ":" + tweetMessage, Globals.path_FailedToTweetAccounts); countTweetsSent++; //Log("[ " + DateTime.Now + " ] => [ Delay For : " + TimeSpan.FromMilliseconds(interval).Minutes + " Minutes ]"); //Thread.Sleep(interval); if (!waitAndReplyIsIntervalInsec) { Log("[ " + DateTime.Now + " ] => [ Delay For : " + TimeSpan.FromMilliseconds(interval).Minutes + " Minutes ]"); Thread.Sleep(interval); } else { try { interval = RandomNumberGenerator.GenerateRandom(waitAndReplyMinInterval, waitAndReplyMaxInterval); } catch { } Log("[ " + DateTime.Now + " ] => [ Delay For : " + interval + " seconds. ]"); interval = interval * 1000; Thread.Sleep(interval); } } } else { tweeter.Tweet(ref globusHttpHelper, postAuthenticityToken, tweetMessage, out tweetStatus); if (tweetStatus == "posted") { Log("[ " + DateTime.Now + " ] => [ Tweeted : " + tweetMessage + " by " + Username + " ]"); clsDBQueryManager DataBase = new clsDBQueryManager(); string dbTweetMessage = StringEncoderDecoder.Encode(tweetMessage); DataBase.InsertMessageData(Username, "Tweet", "", dbTweetMessage); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword + ":" + tweetMessage, Globals.path_SuccessfullyTweetAccounts); countTweetsSent++; //Log("[ " + DateTime.Now + " ] => [ Delay For : " + TimeSpan.FromMilliseconds(interval).Minutes + " Minutes ]"); //Thread.Sleep(interval); if (!waitAndReplyIsIntervalInsec) { Log("[ " + DateTime.Now + " ] => [ Delay For : " + TimeSpan.FromMilliseconds(interval).Minutes + " Minutes ]"); Thread.Sleep(interval); } else { try { interval = RandomNumberGenerator.GenerateRandom(waitAndReplyMinInterval, waitAndReplyMaxInterval); } catch { } Log("[ " + DateTime.Now + " ] => [ Delay For : " + interval + " seconds. ]"); interval = interval * 1000; Thread.Sleep(interval); } } else { Log("[ " + DateTime.Now + " ] => [ Couldn't Post : " + tweetMessage + " by " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword + ":" + tweetMessage, Globals.path_FailedToTweetAccounts); countTweetsSent++; //Log("[ " + DateTime.Now + " ] => [ Delay For : " + TimeSpan.FromMilliseconds(interval).Minutes + " Minutes ]"); //Thread.Sleep(interval); if (!waitAndReplyIsIntervalInsec) { Log("[ " + DateTime.Now + " ] => [ Delay For : " + TimeSpan.FromMilliseconds(interval).Minutes + " Minutes ]"); Thread.Sleep(interval); } else { try { interval = RandomNumberGenerator.GenerateRandom(waitAndReplyMinInterval, waitAndReplyMaxInterval); } catch { } Log("[ " + DateTime.Now + " ] => [ Delay For : " + interval + " seconds. ]"); interval = interval * 1000; Thread.Sleep(interval); } } } } //Reply if (lst_Struct_TweetData.Count == 0) { lst_Struct_TweetData = tweetScrapper.GetTweetData_New(tweetKeyword); } if (lst_Struct_TweetData.Count != 0) { int counter_Reply = 1; //foreach (TwitterDataScrapper.StructTweetIDs item in lst_Struct_TweetData) //{ while (countTweetsSent == counter_Reply * noOfTweetsPerReply && que_ReplyMessages_WaitAndReply.Count > 0) { string replyStatus; string replyMessage = ""; #region MyRegion //if (counter_Reply >= 1) //{ // break; //} //if (que_ReplyMessages.Count == 0) //{ // //listReplyMessages = Randomiser.Shuffle(listReplyMessages).ToList(); // foreach (string ReplyMessage in listReplyMessages) // { // que_ReplyMessages.Enqueue(ReplyMessage); // } //} #endregion lock (locker_que_ReplyMessage_WaitAndReply) { if (que_ReplyMessages_WaitAndReply.Count > 0) { try { //replyMessage = listReplyMessages[RandomNumberGenerator.GenerateRandom(0, listReplyMessages.Count - 1)]; replyMessage = que_ReplyMessages_WaitAndReply.Dequeue(); } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- locker_que_ReplyMessage_WaitAndReply -- --> " + ex.Message, Globals.Path_WaitNreplyErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- StartWaitAndReply() -- locker_que_ReplyMessage_WaitAndReply -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } } else { Log("[ " + DateTime.Now + " ] => [ All Loaded Reply Messages Used ]"); break; } } tweeter.Reply(ref globusHttpHelper, pgSrc_Profile, postAuthenticityToken, lst_Struct_TweetData[counterDataScraped].ID_Tweet, lst_Struct_TweetData[counterDataScraped].username__Tweet_User, replyMessage, out replyStatus); if (replyStatus == "posted") { counter_Reply++; clsDBQueryManager DataBase = new clsDBQueryManager(); string dbTweetMessage = StringEncoderDecoder.Encode(lst_Struct_TweetData[counterDataScraped].wholeTweetMessage); DataBase.InsertMessageData(Username, "Reply", lst_Struct_TweetData[counterDataScraped].ID_Tweet_User, lst_Struct_TweetData[counterDataScraped].wholeTweetMessage); Log("[ " + DateTime.Now + " ] => [ Replied : " + replyMessage + " by " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword + ":" + replyMessage, Globals.path_SuccessfullyRepliedAccounts); } else { counter_Reply++; Log("[ " + DateTime.Now + " ] => [ Couldn't Reply : " + replyMessage + " by " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword + ":" + replyMessage, Globals.path_FailedRepliedAccounts); } //Log("[ " + DateTime.Now + " ] => [ Delay For : " + TimeSpan.FromMilliseconds(interval).Minutes + " Minutes ]"); //Thread.Sleep(interval); if (!waitAndReplyIsIntervalInsec) { Log("[ " + DateTime.Now + " ] => [ Delay For : " + TimeSpan.FromMilliseconds(interval).Minutes + " Minutes ]"); Thread.Sleep(interval); } else { try { interval = RandomNumberGenerator.GenerateRandom(waitAndReplyMinInterval, waitAndReplyMaxInterval); } catch { } Log("[ " + DateTime.Now + " ] => [ Delay For : " + interval + " seconds. ]"); interval = interval * 1000; Thread.Sleep(interval); } counterDataScraped++; if (countTweetsSent <= noOfTweetsPerReply) { countTweetsSent = 0; break; } } } else { Log("[ " + DateTime.Now + " ] => [ Tweet Data is not available for Tweet Keyword:- " + tweetKeyword + " ]"); } } if (que_ReplyMessages_WaitAndReply.Count <= 0) { Log("[ " + DateTime.Now + " ] => [ Remaining Reply Message : " + que_ReplyMessages_WaitAndReply.Count + " ]"); Log("[ " + DateTime.Now + " ] => [ Finished Reply Messages ]"); Log("------------------------------------------------------------------------------------------------------------------------------------------"); } if (que_TweetMessages_WaitAndReply.Count <= 0) { Log("[ " + DateTime.Now + " ] => [ Remaining Tweet Message: " + que_TweetMessages_WaitAndReply.Count + " ]"); Log("[ " + DateTime.Now + " ] => [ Finished Tweet Messages ]"); Log("------------------------------------------------------------------------------------------------------------------------------------------"); } //Log("Finished Replying with : " + Username); } } else { Log("[ " + DateTime.Now + " ] => [ Couldn't log in with :" + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword, Globals.path_FailedLoginAccounts); } } catch (Exception ex) { //Log("[ " + DateTime.Now + " ] => [ >>Error :- TweetAccountManager (StartWaitAndReply)>> " + ex.Message + " ]"); Globussoft.GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- StartWaitAndReply --> " + ex.Message, Globals.Path_WaitNreplyErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- StartWaitAndReply() -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } }
public void ReTweetDivideRetweet(List<TwitterDataScrapper.StructTweetIDs> lst_DivideTweets, int minDelay, int maxDelay) { try { if (!IsLoggedIn) { Login(); } if (IsNotSuspended) { if (IsLoggedIn) { int counter_Retweet = 0; //TwitterDataScrapper.StructTweetIDs item = new TwitterDataScrapper.StructTweetIDs(); //while (que_lst_Struct_TweetData.Count > 0) foreach (var item in lst_DivideTweets) { //foreach (TwitterDataScrapper.StructTweetIDs item in static_lst_Struct_TweetData) //{ if (!RetweetPerDay) { if (counter_Retweet >= noOfRetweets) { Log("[ " + DateTime.Now + " ] => [ " + counter_Retweet + " ReTweets Done For " + Username + " ]"); break; } } else if (RetweetPerDay) { if (AlreadyRetweeted >= NoOFRetweetPerDay) { Log("[ " + DateTime.Now + " ] => [ Already Tweeted " + AlreadyRetweeted + " ]"); break; } } lock (locker_qque_lst_Struct_TweetData) { //if (que_lst_Struct_TweetData.Count > 0) //{ // item = que_lst_Struct_TweetData.Dequeue(); //} //else //{ //} } string tweetStatus; int delay = 10 * 1000; try { //delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); if (Globals.IsGlobalDelay && Globals.IsCheckValueOfDelay) { delay = RandomNumberGenerator.GenerateRandom(Globals.MinGlobalDelay, Globals.MaxGlobalDelay); } else { delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); } } catch (Exception ex) { delay = 10; GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- ReTweet() -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } tweeter.ReTweet(ref globusHttpHelper, pgSrc_Profile, postAuthenticityToken, item.ID_Tweet, "", out tweetStatus); if (tweetStatus == "posted") { counter_Retweet++; AlreadyRetweeted++; clsDBQueryManager DataBase = new clsDBQueryManager(); string dbTweetMessage = StringEncoderDecoder.Encode(item.wholeTweetMessage); DataBase.InsertMessageData(Username, "ReTweet", item.ID_Tweet, dbTweetMessage); Log("[ " + DateTime.Now + " ] => [ Retweeted " + counter_Retweet + ": >> " + item.username__Tweet_User + " by " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(item.username__Tweet_User + " by " + Username, Globals.path_RetweetInformation); } else { Log("[ " + DateTime.Now + " ] => [ >>Couldn't Retweet >> " + item.ID_Tweet_User + " by " + Username + " ]"); //GlobusFileHelper.AppendStringToTextfileNewLine("Retweeted " + counter_Retweet + ": >> " + item.username__Tweet_User + " by " + Username, Globals.path_RetweetInformation); } Log("[ " + DateTime.Now + " ] => [ Retweet Delayed for " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); } Log("[ " + DateTime.Now + " ] => [ Finished Retweeting with : " + Username + " ]"); Log("------------------------------------------------------------------------------------------------------------------------------------------"); } else { Log("[ " + DateTime.Now + " ] => [ Couldn't log in with " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword, Globals.path_FailedLoginAccounts); } } else { clsDBQueryManager database = new clsDBQueryManager(); database.UpdateSuspendedAcc(Username); Log("[ " + DateTime.Now + " ] => [ " + Username + ">>Account Suspended ]"); return; } } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager() - retweet --> " + ex.Message, Globals.Path_TweetingErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- ReTweet() -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } }
public void Reply(List<string> list_tweetMessages, int minDelay, int maxDelay) { //Login(); //if (true) if (!IsLoggedIn) { Login(); } if (IsNotSuspended) { if (IsLoggedIn) { int counter_Retweet = 0; foreach (TwitterDataScrapper.StructTweetIDs item in static_lst_Struct_TweetData) { if (counter_Retweet >= noOfRetweets) { //Log("Finished Replying with : " + Username); break; } string tweetStatus; int delay = 10 * 1000; try { delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); } catch { } string tweetMessage = ""; try { tweetMessage = list_tweetMessages[RandomNumberGenerator.GenerateRandom(0, list_tweetMessages.Count - 1)]; } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- Reply() -- tweetMessage -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } tweeter.Reply(ref globusHttpHelper, pgSrc_Profile, postAuthenticityToken, item.ID_Tweet, item.username__Tweet_User, tweetMessage, out tweetStatus); if (tweetStatus == "posted") { counter_Retweet++; clsDBQueryManager DataBase = new clsDBQueryManager(); string dbTweetMessage = string.Empty; try { dbTweetMessage = StringEncoderDecoder.Encode(tweetMessage); } catch { } DataBase.InsertMessageData(Username, "Reply", item.ID_Tweet, dbTweetMessage); Log("[ " + DateTime.Now + " ] => [ >> Replied : " + counter_Retweet + " : " + tweetMessage + " by " + Username + " ]"); //GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword, Globals.path_SuccessfullyFollowAccounts); } else { Log("[ " + DateTime.Now + " ] => [ >>Couldn't Reply >> " + tweetMessage + " by " + Username + " ]"); //GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword, Globals.path_FailedToFollowAccounts); } Log("[ " + DateTime.Now + " ] => [ Reply Delayed for " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); } Log("[ " + DateTime.Now + " ] => [ Finished Replying with : " + Username + " ]"); Log("------------------------------------------------------------------------------------------------------------------------------------------"); } else { Log("[ " + DateTime.Now + " ] => [ Couldn't log in with " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword, Globals.path_FailedLoginAccounts); } } }
public void Reply(string tweetMessage, int minDelay, int maxDelay) { //Login(); List<string> lstTemp = new List<string>(); //if (true) try { TwitterDataScrapper.StructTweetIDs TweeetData = new TwitterDataScrapper.StructTweetIDs(); if (!IsLoggedIn) { Login(); } if (IsNotSuspended) { if (IsLoggedIn) { int counter_Reply = 0; //foreach (TwitterDataScrapper.StructTweetIDs item in static_lst_Struct_TweetData) //{ // List_of_struct_Keydatafrom_tweetData_list.Enqueue(item); //TweeetData = List_of_struct_Keydatafrom_tweetData_list.Dequeue(); while (que_ReplyMessages.Count > 0) { int delay = 10 * 1000; int counter = 0; try { delay = RandomNumberGenerator.GenerateRandom(minDelay, maxDelay); } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Reply()-- delay --> " + ex.Message, Globals.Path_TweetingErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- Reply() -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } // Code for Sending unique Reply // By Puja lock (locker_que_ReplyTweetMessage) { //if (IsreplyUniqueTweet) { if (que_ReplyMessages.Count > 0) { try { tweetMessage = que_ReplyMessages.Dequeue(); } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Reply()-- locker_que_ReplyTweetMessage --> " + ex.Message, Globals.Path_TweetingErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- Reply()-- locker_que_ReplyTweetMessage -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } } else { Log("[ " + DateTime.Now + " ] => [ All Loaded Tweet Messages Used ]"); //break; } } //Code by Puja #region Code for Reply Per Tweet //if (IsReplyPerTweet) //{ // if (lstTemp.Count == 0) // { // foreach (string item in que_ReplyMessages) // { // lstTemp.Add(item); // } // } // if (counter > lstTemp.Count - 1) // { // counter = 0; // } // tweetMessage = lstTemp[counter]; // counter++; //} #endregion } lock (locker_que_keywyordStructData) { if (List_of_struct_Keydatafrom_tweetData_list.Count > 0) { try { TweeetData = List_of_struct_Keydatafrom_tweetData_list.Dequeue(); } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Reply()-- locker_que_ReplyTweetMessage --> " + ex.Message, Globals.Path_TweetingErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- Reply()-- locker_que_ReplyTweetMessage -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } } else { TwitterDataScrapper tweetScrapper = new TwitterDataScrapper(); TweetAccountManager.static_lst_Struct_TweetData = tweetScrapper.GetTweetData(ReplyKeyword); foreach (TwitterDataScrapper.StructTweetIDs item in TweetAccountManager.static_lst_Struct_TweetData) { TweetAccountManager.List_of_struct_Keydatafrom_tweetData_list.Enqueue(item); } TweeetData = List_of_struct_Keydatafrom_tweetData_list.Dequeue(); } } if (!ReplyPerDay) { if (counter_Reply >= noOfRetweets) { Log("[ " + DateTime.Now + " ] => [ Finished Replying with : " + Username + " ]"); Log("------------------------------------------------------------------------------------------------------------------------------------------"); break; } } else if (ReplyPerDay) { if (AlreadyReply >= NoOFReplyPerDay) { Log("[ " + DateTime.Now + " ] => [ Already Replied " + AlreadyReply + " ]"); break; } } //if (counter_Reply >= noOfRetweets) //{ // //Log("Finished Replying with : " + Username); // break; //} string tweetStatus; tweeter.Reply(ref globusHttpHelper, pgSrc_Profile, postAuthenticityToken, TweeetData.ID_Tweet, TweeetData.username__Tweet_User, tweetMessage, out tweetStatus); if (tweetStatus == "posted") { counter_Reply++; AlreadyReply++; clsDBQueryManager DataBase = new clsDBQueryManager(); string dbTweetMessage = string.Empty; try { dbTweetMessage = StringEncoderDecoder.Encode(TweeetData.wholeTweetMessage); } catch { } DataBase.InsertMessageData(Username, "Reply", TweeetData.ID_Tweet_User, dbTweetMessage); Log("[ " + DateTime.Now + " ] => [ >> Replied : " + counter_Reply + " : " + tweetMessage + " by " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine( tweetMessage + " by " + Username, Globals.path_ReplyInformation); } else { Log("[ " + DateTime.Now + " ] => [ >>Couldn't Reply >> " + tweetMessage + " by " + Username + " ]"); //GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword, Globals.path_FailedToFollowAccounts); } Log("[ " + DateTime.Now + " ] => [ Reply Delayed for " + delay + " Seconds ]"); Thread.Sleep(delay * 1000); if (ReplyPerDay) { if (AlreadyReply >= NoOFReplyPerDay) { Log("[ " + DateTime.Now + " ] => [ Finished Replying with : " + Username + " ]"); Log("------------------------------------------------------------------------------------------------------------------------------------------"); break; } } else if (que_ReplyMessages.Count <= 0) { Log("[ " + DateTime.Now + " ] => [ Finished Replying with : " + Username + " ]"); Log("------------------------------------------------------------------------------------------------------------------------------------------"); break; } } //Log("Finished Replying with : " + Username); } else { Log("[ " + DateTime.Now + " ] => [ Couldn't log in with " + Username + " ]"); GlobusFileHelper.AppendStringToTextfileNewLine(Username + ":" + Password + ":" + proxyAddress + ":" + proxyPort + ":" + proxyUsername + ":" + proxyPassword, Globals.path_FailedLoginAccounts); } } else { Log("[ " + DateTime.Now + " ] => [ " + Username + ">> Account Suspended ]"); } } catch (Exception ex) { GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> Reply() --> " + ex.Message, Globals.Path_TweetingErroLog); GlobusFileHelper.AppendStringToTextfileNewLine(DateTime.Now + " --> Error --> TweetAccountManager -- Reply() -- " + Username + " --> " + ex.Message, Globals.Path_TweetAccountManager); } }