private void start2() { StreamReader sr = new StreamReader("Messages.txt"); VkNetAddition vna = new VkNetAddition(); List<string> toMes = vna.downloadMessages(sr); string[] messages = toMes.ToArray(); sr.Close(); sr = new StreamReader("Login_pass.txt"); int count = 0; if (sr.ReadLine().Contains(";")) count++; sr.Close(); sr = new StreamReader("Login_pass.txt"); List<VkApi> apis = vna.botAutorization(sr, count, appId); sr.Close(); sr = new StreamReader("Profiles.txt"); List<long> userIds = new List<long>(); while (!sr.EndOfStream) { long id; if (long.TryParse(sr.ReadLine(), out id)) userIds.Add(id); } sr.Close(); sr = new StreamReader("Confige.txt"); int globalTimeout = int.Parse(sr.ReadLine()); int globalMessage = int.Parse(sr.ReadLine()); int globalFriend = int.Parse(sr.ReadLine()); VkApiBot[] bots = new VkApiBot[apis.Count]; int i = 0; foreach (var bot in apis) { bots[i++] = (new VkApiBot(bot, globalMessage, globalFriend)); } count = i; i = 0; globalMessage *= count; globalFriend *= count; radProgressBar1.Maximum = globalFriend + globalMessage; radProgressBar1.Value1 = 0; // try { if (!bots[i].api.Users.Get("21378590").CanWritePrivateMessage) { Thread.Sleep(1500); bots[i].api.Messages.Send(21378590, false, messages[bots[i].numberOfMessages++]); } bots[i].api.Messages.Send(21378590, false, messages[bots[i].numberOfMessages]); // } // catch (VkNet.Exception.VkApiException) { }; }
private void start() { startButton.Invoke(new delegateVoid((a) => startButton.Enabled = a), false); VkNetAddition vna = new VkNetAddition(); StreamReader sr = new StreamReader("Messages.txt"); List<string> toMes = vna.downloadMessages(sr); string[] messages = toMes.ToArray(); sr.Close(); sr = new StreamReader("Login_pass.txt"); int count = 0; if (sr.ReadLine().Contains(";")) count++; sr.Close(); sr = new StreamReader("Login_pass.txt"); List<VkApi> apis = vna.botAutorization(sr, count, appId); sr.Close(); sr = new StreamReader("Profiles.txt"); List<long> userIds = new List<long>(); while (!sr.EndOfStream) { long id; if (long.TryParse(sr.ReadLine(), out id)) userIds.Add(id); } sr.Close(); sr = new StreamReader("Confige.txt"); int globalTimeout = int.Parse(sr.ReadLine()); int globalMessage = int.Parse(sr.ReadLine()); int globalFriend = int.Parse(sr.ReadLine()); VkApiBot[] bots = new VkApiBot[apis.Count]; int i = 0; foreach (var bot in apis) { bots[i++] = (new VkApiBot(bot, globalMessage, globalFriend)); } count = i; i = 0; globalMessage *= count; globalFriend *= count; radProgressBar1.Maximum = globalFriend + globalMessage; radProgressBar1.Value1 = 0; List<long> newIds = new List<long>(); foreach (var id in userIds) { if (!bots[i].api.Users.Get(id).CanWritePrivateMessage && bots[i].requiredMessages > 0) { try { bots[i].api.Messages.Send(id, false, messages[bots[i].numberOfMessages++ % messages.Length]); } catch (Exception e) { using (StreamWriter sw = File.AppendText("Error.txt")) { sw.WriteLine(e); } } radProgressBar1.Value1++; bots[i].requiredMessages--; globalMessage--; } else if (bots[i].requiredFriends > 0) { if (id == bots[i].api.UserId) break; try { bots[i].api.Friends.Add(id); } catch (VkNet.Exception.CaptchaNeededException e) { CaptchaForm cf = new CaptchaForm(e.Img, e.Sid); cf.ShowDialog(); Console.WriteLine(bots[i].api.Friends.Add(id, "", e.Sid, Captcha.textCaptcha).ToString()); } bots[i].requiredFriends--; globalFriend--; radProgressBar1.Value1++; } else { newIds.Add(id); } i++; if (globalFriend == 0 && globalMessage == 0 && i == count) { i = 0; continue; } if (globalFriend == 0 && globalMessage == 0) { continue; } if (i == count) { i = 0; Thread.Sleep(globalTimeout); } } using (StreamWriter sw = new StreamWriter("Profiles.txt")) { foreach (var id in newIds) { sw.WriteLine(id); } } startButton.Invoke(new delegateVoid((a) => startButton.Enabled = a), true); }
private void AddProfiles() { radWaitingBar1.Invoke(new del((a)=>radWaitingBar1.Visible =a),true); radWaitingBar1.Invoke(new del((a) => radWaitingBar1.StartWaiting()), true); // AddProfilesButton1.Visible = false; int fromAge = 0; int toAge = 99999; int withPhoto = withPhotoCheckBox1.Checked == true ? 1 : 0; int country = countryList1.SelectedIndex == 1 ? 1 : 0; ; int city = cityList1.SelectedIndex == 1 ? 60 : 0; int status = statusList1.SelectedIndex; int sex = sexList1.SelectedIndex; int offset = 0; int.TryParse(fromTextBox.Text, out fromAge); int.TryParse(toTextBox.Text, out toAge); int.TryParse(offsetTextBox1.Text, out offset); StreamReader sr = new StreamReader("Login_pass.txt"); string[] loginPass = sr.ReadLine().Split(';'); sr.Close(); VkApi api = new VkApi(); try { api.Authorize(APP_ID, loginPass[0], loginPass[1], VkNet.Enums.Filters.Settings.All); // авторизуемся } catch (VkNet.Exception.VkApiAuthorizationException) { MessageBox.Show("Проблема с авторизацией"); return; } VkNetAddition vkSearch = new VkNetAddition(); Dictionary<string, string> parameters = new Dictionary<string, string>(); if (country != 0) parameters.Add("country", country.ToString()); if (city != 0) parameters.Add("city", city.ToString()); if (country != 0) parameters.Add("sex", sex.ToString()); if (status != -1) parameters.Add("status", status.ToString()); parameters.Add("has_photo", withPhoto.ToString()); if (fromAge != 0) parameters.Add("age_from", fromAge.ToString()); if (toAge != 0) parameters.Add("age_to", toAge.ToString()); int count; var users = vkSearch.Search(api, out count, qTextBox1.Text, 1000, offset, parameters); Dictionary<long, bool> map = new Dictionary<long, bool>(); foreach (var user in users) { map[user.Id] = false; } using (sr = new StreamReader("Profiles.txt")) { while (!sr.EndOfStream) { string str = sr.ReadLine(); if (!string.IsNullOrEmpty(str)) map[long.Parse(str)] = true; } sr.Close(); } using (StreamWriter sw = File.AppendText("Profiles.txt")) { foreach (var user in map) { if (user.Value == false) sw.WriteLine(user.Key); } } radWaitingBar1.Invoke(new del((a) => radWaitingBar1.Visible = a), false); // AddProfilesButton1.Visible = true; }