Esempio n. 1
0
 private void PrepareChatsPics()
 {
     Log.Push($"[Поток {login}]: Загрузка на сервер аватаров бесед");
     Directory.GetFiles("Images");
     foreach (ChatsTarget current in chTargets)
     {
         string text = "Images\\" + current.setPhoto;
         if (text != null && !(text == "Ничего") && !(text == "Удалять"))
         {
             string str;
             if (Path.GetExtension(text) == ".png")
             {
                 str = "png";
             }
             else
             {
                 if (!(Path.GetExtension(text) == ".jpg") && !(Path.GetExtension(text) == ".jpeg"))
                 {
                     continue;
                 }
                 str = "jpeg";
             }
             string text2 = StrWrk.GetBetween(VKserver.APIRequest("photos.getChatUploadServer", "chat_id=" + current.chatID, token, ""), "\"upload_url\":\"", "\"");
             text2 = Network.HttpUploadFile(text2.Replace("\\/", "/"), text, "photo", "image/" + str);
             text2 = StrWrk.GetBetween(text2, "\"response\":\"", "\"");
             current.uploadedPhoto = text2;
         }
     }
 }
Esempio n. 2
0
        public void AsyncWorker()
        {
            id = VKserver.APIRequest("users.get", "", token, "");
            id = StrWrk.GetBetween(id, "\"id\":", ",");

            if (enabledAsAA)
            {
                new Task(() => WorkUntilStopAsAA()).Start();
            }

            if (enabledAsFL)
            {
                new Task(() => WorkUntilStopAsFLText()).Start();

                new Task(() => WorkUntilStopAsFLPic()).Start();
            }

            if (enabledAsCH)
            {
                PrepareChatsPics();
                new Task(() => WorkUntilStopAsCH()).Start();
            }

            if (enabledAsGE)
            {
                new Task(() => WorkUntilStopAsGE()).Start();
            }
        }
Esempio n. 3
0
        private void ProcGenerator()
        {
            string text = generatorTarget;

            if (text == "" || MainForm.generatorMessages.Length == 0)
            {
                Log.Push($"[{login}]: Генерация сообщений...");
                text = StrWrk.qSubstr(text, "im?sel=c", false);
                JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                string        input = StrWrk.GetBetween(VKserver.APIRequest("messages.getChat", "chat_id=" + text, token, ""), "\"users\":", "]") + "]";
                List <string> list  = javaScriptSerializer.Deserialize <List <string> >(input);
                list.Remove(id);

                if (list.Count == 0)
                {
                    Log.Push("[" + login + "]: В чате нет людей");
                }
                else
                {
                    Random random = new Random();
                    string text2  = list[random.Next(0, list.Count)];
                    string text3  = VKserver.APIRequest("users.get", "user_ids=" + text2, token, "");
                    text3 = StrWrk.GetBetween(text3, "\"first_name\":\"", "\",");
                    string str = string.Format("*id{0} ({1})", text2, text3) + " - " + MainForm.generatorMessages[random.Next(0, MainForm.generatorMessages.Length)];
                    VKserver.APIRequest("messages.send", "chat_id=" + text + "&message=" + str, token, "");
                }
            }
        }
Esempio n. 4
0
        public int CheckToken()
        {
            token_status = false;
            if (token == null)
            {
                return(-1);
            }
            int result;

            try
            {
                VKserver.APIRequest("friends.getRequests", "", token, "");
                token_status = true;
                result       = 0;
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("could not get application"))
                {
                    result = 1;
                }
                else
                {
                    Log.Push("[Ошибка уровня API]: " + ex.Message);
                    result = 2;
                }
            }
            return(result);
        }
        private void ForceExecute()
        {
            string text = "code=";

            foreach (string current in execs)
            {
                text += current;
            }
            text += "return 0;";
            VKserver.APIRequest("execute", text, token, "");
            execs.Clear();
        }
Esempio n. 6
0
        private void ProcChats()
        {
            if (chTargets.Count == 0)
            {
                Log.Push($"[{login}]: Обработка чатов...");
                JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
                string text = "";
                foreach (ChatsTarget current in chTargets)
                {
                    text = text + current.chatID + ",";
                }
                text = text.Substring(0, text.Length - 1);
                string text2 = StrWrk.qSubstr(VKserver.APIRequest("messages.getChat", "chat_ids=" + text, token, ""), "\"response\":", false);
                text2 = text2.Substring(0, text2.Length - 1);
                List <ChatInfo> .Enumerator    enumerator2 = javaScriptSerializer.Deserialize <List <ChatInfo> >(text2).GetEnumerator();
                List <ChatsTarget> .Enumerator enumerator3 = chTargets.GetEnumerator();
                ExecuteManager executeManager = new ExecuteManager(token);
                while (enumerator2.MoveNext() && enumerator3.MoveNext())
                {
                    if (enumerator3.Current.setPhoto == "Удалять" && enumerator2.Current.photo_50 != null)
                    {
                        executeManager.Add("API.messages.deleteChatPhoto({\"chat_id\":" + enumerator3.Current.chatID + "});");
                    }

                    if (enumerator3.Current.setPhoto != "" && enumerator3.Current.setPhoto != "Удалять" && enumerator3.Current.setPhoto != "Ничего" && (floodPicsCH || enumerator2.Current.photo_50 != enumerator3.Current.ourPic50))
                    {
                        string text3 = StrWrk.qSubstr(VKserver.APIRequest("messages.setChatPhoto", "file=" + enumerator3.Current.uploadedPhoto, token, ""), "\"response\":", false);
                        text3 = text3.Substring(0, text3.Length - 1);
                        text3 = StrWrk.qSubstr(text3, "\"chat\":", false);
                        text3 = text3.Substring(0, text3.Length - 1);
                        ChatInfo chatInfo = javaScriptSerializer.Deserialize <ChatInfo>(text3);
                        enumerator3.Current.ourPic50 = chatInfo.photo_50;
                    }
                    if (enumerator3.Current.capChangeTo != "" && enumerator3.Current.capChangeTo != enumerator2.Current.title)
                    {
                        executeManager.Add(string.Concat(new string[]
                        {
                            "API.messages.editChat({\"chat_id\":",
                            enumerator3.Current.chatID,
                            ", \"title\":\"",
                            enumerator3.Current.capChangeTo.Replace("\"", "\\\""),
                            "\"});"
                        }));
                    }
                }
                executeManager.Execute();
            }
        }
Esempio n. 7
0
        private void PicToRandomDistFL(string pic)
        {
            int    index  = rnd.Next(0, picsTargetsFL.Count);
            string target = picsTargetsFL[index].target;
            string text   = "";

            if (picsTargetsFL[index].name != null)
            {
                text = picsTargetsFL[index].name;
            }
            if (commentPhotos)
            {
                text += ((MainForm.photoComments.Length != 0) ? MainForm.photoComments[rnd.Next(0, MainForm.photoComments.Length)] : "");
            }
            text = text + "&attachment=" + pic;
            Log.Push(string.Concat(new string[]
            {
                "[Поток ",
                login,
                "]: постинг ",
                pic,
                " в ",
                target
            }));
            try
            {
                if (target.StartsWith("im?sel=c"))
                {
                    string str = StrWrk.qSubstr(target, "im?sel=c", false);
                    VKserver.APIRequest("messages.send", "chat_id=" + str + "&message=" + text, token, "");
                }
                else if (target.StartsWith("im?sel="))
                {
                    string str = StrWrk.qSubstr(target, "im?sel=", false);
                    VKserver.APIRequest("messages.send", "user_id=" + str + "&message=" + text, token, "");
                }
                else
                {
                    Log.Push($"[{login}]: \"{target}\" — неверный формат");
                }
            }
            catch (Exception ex)
            {
                Log.Push("[Ошибка уровня API]: " + ex.Message);
            }
        }
Esempio n. 8
0
        public void SendVoiceMessage(string dist, string message, string voice, string emotion, string speed)
        {
            Log.Push($"[Поток {login}]: Отправка голосового сообщения в " + dist);
            new WebClient().DownloadFile(string.Format("https://tts.voicetech.yandex.net/generate?text={0}&format=mp3&lang=ru-RU&speaker={1}&emotion={2}&speed={3}&key=9ae121de-59ba-4145-a0cb-bdbdec107297", new object[]
            {
                message,
                voice,
                emotion,
                speed
            }), "temp.mp3");
            string str  = Network.HttpUploadFile(StrWrk.GetBetween(VKserver.APIRequest("docs.getUploadServer", "type=audio_message", token, ""), "\"upload_url\":\"", "\"}").Replace("\\/", "/"), "temp.mp3", "file", "audio/MP3");
            string text = VKserver.APIRequest("docs.save", "file=" + StrWrk.GetBetween(str, "\"file\":\"", "\"}"), token, "");
            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

            text = StrWrk.GetBetween(text, "\"resplonse\":\"[", "]}");
            UploadResult uploadResult = javaScriptSerializer.Deserialize <UploadResult>(text);

            if (dist.StartsWith("im?sel=c"))
            {
                string arg = StrWrk.qSubstr(dist, "im?sel=c", false);
                VKserver.APIRequest("messages.send", string.Format("chat_id={0}&attachment=doc{1}_{2}", arg, uploadResult.owner_id, uploadResult.id), token, "");
            }
            else
            {
                if (dist.StartsWith("im?sel="))
                {
                    string arg2 = StrWrk.qSubstr(dist, "im?sel=", false);
                    VKserver.APIRequest("messages.send", string.Format("user_id={0}&attachment=doc{1}_{2}", arg2, uploadResult.owner_id, uploadResult.id), token, "");
                }
                else
                {
                    Log.Push(string.Concat(new string[]
                    {
                        "[Поток ",
                        login,
                        "]: ",
                        dist,
                        " - неверный формат"
                    }));
                }
            }
        }
Esempio n. 9
0
 private void WorkUntilStopAsAA()
 {
     while (Working && enabledAsAA)
     {
         try
         {
             JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();
             string text = StrWrk.qSubstr(VKserver.APIRequest("messages.get", "count=100", token, ""), "\"items\":", false);
             text = text.Substring(0, text.Length - 2);
             msgs = javaScriptSerializer.Deserialize <List <Message> >(text);
             ProcAnsMessages();
             ProcAnsEverythingWithPics();
         }
         catch (Exception ex)
         {
             Log.Push($"[Поток {login}]: " + ex.Message);
         }
         Thread.Sleep(autoansDelay);
     }
 }
Esempio n. 10
0
        private void PhraseToRandomDistFL(string msg, int index)
        {
            //int index = rnd.Next(0, phrasesTargetsFL.Count);
            string target = phrasesTargetsFL[index].target;

            if (phrasesTargetsFL[index].name != null)
            {
                msg = phrasesTargetsFL[index].name + msg;
            }
            Log.Push(string.Concat(new string[]
            {
                "[Поток ",
                login,
                "]: постинг \"",
                msg,
                "\" в ",
                target
            }));
            try
            {
                if (target.StartsWith("im?sel=c"))
                {
                    string str = StrWrk.qSubstr(target, "im?sel=c", false);
                    VKserver.APIRequest("messages.send", "chat_id=" + str + "&message=" + msg, token, "");
                }
                else if (target.StartsWith("im?sel="))
                {
                    string str2 = StrWrk.qSubstr(target, "im?sel=", false);
                    VKserver.APIRequest("messages.send", "user_id=" + str2 + "&message=" + msg, token, "");
                }
                else
                {
                    Log.Push($"[{login}]: \"{target}\" — неверный формат");
                }
            }
            catch (Exception ex)
            {
                Log.Push("[Ошибка уровня API]: " + ex.Message);
            }
        }