From 31976fb2d19be13fb87d835ea8578356cafaa7db Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 30 Jul 2021 05:35:33 +0200 Subject: 4chan: longer slider, dont try to post immediately when going back to posting mode --- TODO | 3 ++- src/QuickMedia.cpp | 21 ++++++++++----------- src/plugins/Fourchan.cpp | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/TODO b/TODO index 0cc1b9a..77cc63c 100644 --- a/TODO +++ b/TODO @@ -184,4 +184,5 @@ Exclude users that are already in the room from room invite gui. Sort users in matrix users list (efficiently and only once!). Optimize matrix insert position for room sorting (and user sorting). Cache solved 4chan captcha solution (and challenge id) on disk. ttl is (always?) 120 seconds so restarting quickmedia under that period should use the already solved captcha. -Posting on bant doesn't work for some reason. The request is sent successfully but the comment never appears on the website. \ No newline at end of file +Posting on bant doesn't work for some reason. The request is sent successfully but the comment never appears on the website. +4chan_pass cookie is needed to get captcha without slider. How to get this without an account? 4chan website sets this for anon too. \ No newline at end of file diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index a48234e..1f7372a 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -3766,11 +3766,12 @@ namespace QuickMedia { if(get_image_board_last_posted_filepath(plugin_name, last_posted_time_filepath)) file_overwrite_atomic(last_posted_time_filepath, std::to_string(last_posted_time)); } else if(post_result == PostResult::TRY_AGAIN) { - show_notification("QuickMedia", "Please wait before you post again"); - navigation_stage = NavigationStage::SOLVING_POST_CAPTCHA; + show_notification("QuickMedia", "Please wait before posting again"); + navigation_stage = NavigationStage::VIEWING_COMMENTS; } else if(post_result == PostResult::INVALID_CAPTCHA) { show_notification("QuickMedia", "Invalid captcha, please try again"); - navigation_stage = NavigationStage::SOLVING_POST_CAPTCHA; + navigation_stage = NavigationStage::REQUESTING_CAPTCHA; + // TODO: Need to wait before requesting need captcha? } else if(post_result == PostResult::BANNED) { show_notification("QuickMedia", "Failed to post comment because you are banned", Urgency::CRITICAL); navigation_stage = NavigationStage::VIEWING_COMMENTS; @@ -3798,7 +3799,7 @@ namespace QuickMedia { bool frame_skip_text_entry = false; - comment_input.on_submit_callback = [&frame_skip_text_entry, &comment_input, &navigation_stage, &comment_to_post, &captcha_post_id, &selected_file_for_upload, &thread_page, &has_post_timeout, &seconds_until_post_again, &last_posted_time](std::string text) -> bool { + comment_input.on_submit_callback = [&frame_skip_text_entry, &comment_input, &navigation_stage, &comment_to_post, &selected_file_for_upload, &thread_page, &has_post_timeout, &seconds_until_post_again, &last_posted_time](std::string text) -> bool { if(text.empty() && selected_file_for_upload.empty()) return false; @@ -3810,10 +3811,10 @@ namespace QuickMedia { assert(navigation_stage == NavigationStage::REPLYING); comment_to_post = std::move(text); - if(!captcha_post_id.empty() || !thread_page->get_pass_id().empty()) { - navigation_stage = NavigationStage::POSTING_COMMENT; - } else if(thread_page->get_pass_id().empty()) { + if(thread_page->get_pass_id().empty()) { navigation_stage = NavigationStage::REQUESTING_CAPTCHA; + } else { + navigation_stage = NavigationStage::POSTING_COMMENT; } return false; }; @@ -4245,10 +4246,8 @@ namespace QuickMedia { auto image_size = captcha_bg_texture_size_f; image_size.x *= image_scale.x; image_size.y *= image_scale.y; - const float width_diff = captcha_bg_texture_size_f.x - captcha_texture_size_f.x; - const float left_opening = 0.15f; - const float right_opening = 0.25f; - captcha_bg_sprite.setPosition(std::floor(captcha_sprite.getPosition().x + captcha_image_size.x * left_opening - captcha_slide * (width_diff + right_opening * captcha_image_size.x)), std::floor(captcha_sprite.getPosition().y)); + const float width_diff = image_size.x - captcha_image_size.x; + captcha_bg_sprite.setPosition(std::floor(captcha_sprite.getPosition().x + width_diff*1.0f - captcha_slide*(width_diff + width_diff*2.0f)), std::floor(captcha_sprite.getPosition().y)); window.draw(captcha_bg_sprite); image_height = std::max(image_height, (int)image_size.y); diff --git a/src/plugins/Fourchan.cpp b/src/plugins/Fourchan.cpp index 24886c6..c1d7d6a 100644 --- a/src/plugins/Fourchan.cpp +++ b/src/plugins/Fourchan.cpp @@ -539,14 +539,14 @@ namespace QuickMedia { return PostResult::OK; if(response.find("banned") != std::string::npos) return PostResult::BANNED; - if(response.find("try again") != std::string::npos) - return PostResult::TRY_AGAIN; - if(response.find("No valid captcha") != std::string::npos) + if(response.find("mistyped the CAPTCHA") != std::string::npos || response.find("No valid captcha") != std::string::npos) return PostResult::INVALID_CAPTCHA; if(response.find("Audio streams are not allowed") != std::string::npos) return PostResult::FILE_TYPE_NOT_ALLOWED; if(response.find("Error: Upload failed") != std::string::npos) return PostResult::UPLOAD_FAILED; + if(response.find("try again") != std::string::npos) + return PostResult::TRY_AGAIN; return PostResult::ERR; } -- cgit v1.2.3