Checks if it should comment on the image
(browser, username, comments, blacklist, logger, logfolder)
| 68 | |
| 69 | |
| 70 | def comment_image(browser, username, comments, blacklist, logger, logfolder): |
| 71 | """Checks if it should comment on the image""" |
| 72 | # check action availability |
| 73 | if quota_supervisor("comments") == "jump": |
| 74 | return False, "jumped" |
| 75 | |
| 76 | rand_comment = random.choice(comments).format(username) |
| 77 | rand_comment = emoji.demojize(rand_comment) |
| 78 | rand_comment = emoji.emojize(rand_comment, use_aliases=True) |
| 79 | |
| 80 | open_comment_section(browser, logger) |
| 81 | # wait, to avoid crash |
| 82 | sleep(3) |
| 83 | comment_input = get_comment_input(browser) |
| 84 | |
| 85 | try: |
| 86 | if len(comment_input) > 0: |
| 87 | # wait, to avoid crash |
| 88 | sleep(2) |
| 89 | comment_input = get_comment_input(browser) |
| 90 | # below, an extra space is added to force |
| 91 | # the input box to update the reactJS core |
| 92 | comment_to_be_sent = rand_comment |
| 93 | |
| 94 | # wait, to avoid crash |
| 95 | sleep(2) |
| 96 | # click on textarea/comment box and enter comment |
| 97 | ( |
| 98 | ActionChains(browser) |
| 99 | .move_to_element(comment_input[0]) |
| 100 | .click() |
| 101 | .send_keys(comment_to_be_sent) |
| 102 | .perform() |
| 103 | ) |
| 104 | # wait, to avoid crash |
| 105 | sleep(2) |
| 106 | # post comment / <enter> |
| 107 | ( |
| 108 | ActionChains(browser) |
| 109 | .move_to_element(comment_input[0]) |
| 110 | .send_keys(Keys.ENTER) |
| 111 | .perform() |
| 112 | ) |
| 113 | |
| 114 | update_activity( |
| 115 | browser, |
| 116 | action="comments", |
| 117 | state=None, |
| 118 | logfolder=logfolder, |
| 119 | logger=logger, |
| 120 | ) |
| 121 | |
| 122 | if blacklist["enabled"] is True: |
| 123 | action = "commented" |
| 124 | add_user_to_blacklist( |
| 125 | username, blacklist["campaign"], action, logger, logfolder |
| 126 | ) |
| 127 | else: |
no test coverage detected