示例#1
0
 public void SendMessage(string text)
 {
     InitJs();
     CustomBrowser.ExJs(JsFor_ClearTextArea);
     CustomBrowser.ExJs(JsFor_SetMessageBoxText(text));
     CustomBrowser.ExJs(JsFor_ClickSendMessageButton);
 }
示例#2
0
        void FindCompanion(int countOfTryes)
        {
            if (countOfTryes <= 0)
            {
                throw new Exception("Out of tryes to find companion.");
            }
            chatMessagesList = new List <ChatMessage>();

            /*companionSearchSettings != null && previousCompanionSearchSettings == companionSearchSettings &&*/
            if (RestartConversationIfCan())
            {
                return;
            }

            CustomBrowser.LoadPage(chatStartUrl);
            InitJs();
            try
            {
                GetWithUpdate_IsStillTalking();
            }
            catch
            {
                throw new Exception("Page load exception!");
            }

            //SynchronizationHelper.Pause(500);
            //string scriptToSetSettings = JsFor_SetSearchSettings(companionSearchSettings);
            //CustomBrowser.ExJs(scriptToSetSettings);
            SynchronizationHelper.Pause(200);
            CustomBrowser.ExJs(JsFor_ClickSearchButtononStartUrl);
            InitJs();

            //SynchronizationHelper.WaitFor(
            //    GetWithUpdate_IsSearchingCompanion, 20000);
            SynchronizationHelper.WaitFor(
                () => {
                if (GetWithUpdate_IsStillTalking())
                {
                    return(true);
                }
                SynchronizationHelper.Pause(250);
                return(false);
            },
                10000);

            //previousCompanionSearchSettings = companionSearchSettings;
            if (!GetWithUpdate_IsStillTalking())
            {
                FindCompanion(countOfTryes - 1);
            }
            CheckCaptchaAndWait();
        }
示例#3
0
        /// <summary>
        /// Не используется и, возможно, никогда не будет.
        /// </summary>
        public void SimulateWriting(int timeMS)
        {
            int waiInOneLoop = 200;

            while (timeMS > 0)
            {
                CustomBrowser.ExJs(JsFor_SimulateWriting);
                SynchronizationHelper.Pause(waiInOneLoop);
                timeMS -= waiInOneLoop;
            }
            CustomBrowser.ExJs(JsFor_ClearTextArea);
            SynchronizationHelper.Pause(50);
        }
示例#4
0
 void InitJs()
 {
     if (GetWithUpdate_IsBotFuncsInitialized())
     {
         return;
     }
     CustomBrowser.ExJs(ResourcesAndConsts.Instance().JsLib_JqueryKeypressSimulator);
     CustomBrowser.ExJs(JsFor_InitCheckIfStillTalking);
     CustomBrowser.ExJs(JsFor_InitGetCountOfMessages);
     CustomBrowser.ExJs(JsFor_InitCheckIfCompanionsMessageAt);
     CustomBrowser.ExJs(JsFor_InitCheckCaptcha);
     CustomBrowser.ExJs(JsFor_InitClickSearchNewCompanionButton);
     CustomBrowser.ExJs(JsFor_SetIsBotFuncsInitialized);
 }
示例#5
0
        /// <summary>
        /// Return true if conversation restarted.
        /// </summary>
        /// <returns></returns>
        bool RestartConversationIfCan()
        {
            bool res = false;

            try
            {
                CustomBrowser.ExJs(JsFor_ClickSearchNewCompanionButton);
                SynchronizationHelper.Pause(200);

                SynchronizationHelper.WaitFor(
                    GetWithUpdate_IsSearchingCompanion, 20000);
                SynchronizationHelper.WaitFor(
                    () => { return(!GetWithUpdate_IsStillTalking()); }, 15000);
                res = GetWithUpdate_IsStillTalking();
            }
            catch { }
            return(res);
        }
示例#6
0
 public void FinishConversation()
 {
     InitJs();
     CustomBrowser.ExJs(JsFor_FinishConversation);
     SynchronizationHelper.Pause(300);
 }