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 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) { }; }