/// <summary> /// Не рекомендуется использовать извне. /// </summary> public ChatMessage ReadMessageAt(int msgNum) { InitJs(); string jsResText = CustomBrowser.ExJsWithResult( JsFor_GetMessageAt(msgNum) ).Trim(); if (string.IsNullOrWhiteSpace(jsResText) || CustomBrowser.CheckJsResult_IsUndefined(jsResText) || jsResText == "msgError") { ThrowInvalidJsResultExeption("JsFor_GetMessageAt", jsResText); } string jsResBool = CustomBrowser.ExJsWithResult( JsFor_CheckIfCompanionsMessageAt(msgNum) ).Trim(); if (!CustomBrowser.CheckJsResult_WhiteList(jsResBool, new string[] { "1", "0" })) { ThrowInvalidJsResultExeption("JsFor_CheckIfCompanionsMessageAt", jsResBool); } jsResText = jsResText.Replace("<br>", "\n"); ChatMessage res = new ChatMessage( jsResText, jsResBool == "1" ); return(res); }
private async void Enter() { Request.IsEntered = false; Browser = CustomBrowser.Create(); try { var locale = await Browser.RequestAsync(Request); Response.Headers = locale.Headers; Response.Response = locale.Response; Response.StatusCode = locale.StatusCode; Request.IsEntered = true; } catch (ArgumentNullException ex) { WindowsManager.Message("ApiDog", ex.Message); } catch (Exception ex) { WindowsManager.Message("ApiDog", ex.Message); } finally { Browser.Abort(); } }
public void SendMessage(string text) { InitJs(); CustomBrowser.ExJs(JsFor_ClearTextArea); CustomBrowser.ExJs(JsFor_SetMessageBoxText(text)); CustomBrowser.ExJs(JsFor_ClickSendMessageButton); }
public CustomBrowserSettingWindow(CustomBrowser browser) { InitializeComponent(); currentCustomBrowser = browser; DataContext = new CustomBrowser { Name = browser.Name, DataDirectoryPath = browser.DataDirectoryPath }; }
public bool GetWithUpdate_IsBotFuncsInitialized() { string jsRes = Convert.ToString(CustomBrowser.ExJsWithResult(JsFor_GetIsBotFuncsInitialized)).Trim(); if (!CustomBrowser.CheckJsResult_WhiteList(jsRes, new string[] { "1", "0" })) { ThrowInvalidJsResultExeption("JsFor_GetIsBotFuncsInitialized", jsRes); } return(jsRes == "1"); }
public bool GetWithUpdate_CheckCaptcha() { InitJs(); string jsRes = Convert.ToString(CustomBrowser.ExJsWithResult(JsFor_CheckCaptcha)).Trim(); if (!CustomBrowser.CheckJsResult_WhiteList(jsRes, new string[] { "1", "0" })) { ThrowInvalidJsResultExeption("JsFor_CheckCaptcha", jsRes); } return(jsRes == "1"); }
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(); }
/// <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); }
public bool GetWithUpdate_IsStillTalking() { InitJs(); string jsRes = Convert.ToString(CustomBrowser.ExJsWithResult(JsFor_CheckIfStillTalking)).Trim(); if (!CustomBrowser.CheckJsResult_WhiteList(jsRes, new string[] { "1", "0" })) { ThrowInvalidJsResultExeption("JsFor_CheckIfStillTalking", jsRes); } isStillTalking = jsRes == "1"; return(isStillTalking); }
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); }
public bool GetWithUpdate_IsSearchingCompanion() { isSearchingCompanion = false; return(isSearchingCompanion); string jsRes = CustomBrowser.ExJsWithResult(JsFor_CheckIfSearchingCompanion).Trim(); if (!CustomBrowser.CheckJsResult_WhiteList(jsRes, new string[] { "1", "0" })) { ThrowInvalidJsResultExeption("JsFor_CheckIfSearchingCompanion", jsRes); } isSearchingCompanion = jsRes == "1"; return(isSearchingCompanion); }
/// <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); }
/// <summary> /// Не рекомендуется использовать извне. /// </summary> public int ReadMessagesCount() { InitJs(); int?jsRes = null; try { jsRes = Convert.ToInt32(CustomBrowser.ExJsWithResult( JsFor_GetCountOfMessages )); return((int)jsRes); } catch { ThrowInvalidJsResultExeption("JsFor_GetCountOfMessages", "null"); return(-9999); } }
public CustomChromiumBookmarkLoader(CustomBrowser browser) { BrowserName = browser.Name; BrowserDataPath = browser.DataDirectoryPath; }
public void WriteToBrowserLog(string text) { CustomBrowser.WriteToLog(text); }
public void FinishConversation() { InitJs(); CustomBrowser.ExJs(JsFor_FinishConversation); SynchronizationHelper.Pause(300); }