|
1 | 1 | import logging |
2 | 2 | import random |
3 | 3 | import time |
4 | | -from typing import Dict, Tuple |
| 4 | +from typing import Tuple |
5 | 5 |
|
6 | 6 | from tor.core.config import ( |
7 | 7 | SLACK_COC_ACCEPTED_CHANNEL_ID, |
|
48 | 48 | ] |
49 | 49 |
|
50 | 50 |
|
| 51 | +def modchat_blocked_user_ping(username: str, blossom_submission: dict, cfg: Config) -> None: |
| 52 | + user_url = i18n["urls"]["reddit_url"].format(f"/u/{username}") |
| 53 | + send_to_modchat( |
| 54 | + f":no_entry_sign: Blocked user <{user_url}|u/{username}> is trying to transcribe." |
| 55 | + f" <{blossom_submission['tor_url']}|Thread link>", |
| 56 | + cfg, |
| 57 | + ) |
| 58 | + |
| 59 | + |
51 | 60 | @beeline.traced(name="process_coc") |
52 | 61 | def process_coc( |
53 | | - username: str, context: str, blossom_submission: Dict, cfg: Config |
| 62 | + username: str, context: str, blossom_submission: dict, cfg: Config |
54 | 63 | ) -> Tuple: |
55 | 64 | """ |
56 | 65 | Process the acceptation of the CoC by the specified user. |
@@ -93,7 +102,7 @@ def process_coc( |
93 | 102 |
|
94 | 103 | @beeline.traced(name="process_claim") |
95 | 104 | def process_claim( |
96 | | - username: str, blossom_submission: Dict, cfg: Config, first_time=False |
| 105 | + username: str, blossom_submission: dict, cfg: Config, first_time=False |
97 | 106 | ) -> Tuple: |
98 | 107 | """ |
99 | 108 | Process a claim request. |
@@ -138,8 +147,9 @@ def process_claim( |
138 | 147 | message = coc_not_accepted.format(get_wiki_page("codeofconduct", cfg)) |
139 | 148 | cfg.blossom.create_user(username=username) |
140 | 149 |
|
141 | | - elif response.status == BlossomStatus.blacklisted: |
142 | | - message = i18n["responses"]["general"]["blacklisted"] |
| 150 | + elif response.status == BlossomStatus.blocked: |
| 151 | + message = i18n["responses"]["general"]["blocked"] |
| 152 | + modchat_blocked_user_ping(username, blossom_submission, cfg) |
143 | 153 |
|
144 | 154 | elif response.status == BlossomStatus.already_claimed: |
145 | 155 | claimed_by = response.data["username"] |
@@ -167,7 +177,7 @@ def process_claim( |
167 | 177 | @beeline.traced(name="process_done") |
168 | 178 | def process_done( |
169 | 179 | user: Redditor, |
170 | | - blossom_submission: Dict, |
| 180 | + blossom_submission: dict, |
171 | 181 | comment: Comment, |
172 | 182 | cfg: Config, |
173 | 183 | override=False, |
@@ -289,15 +299,16 @@ def process_done( |
289 | 299 | elif done_response.status == BlossomStatus.missing_prerequisite: |
290 | 300 | message = done_messages["not_claimed_by_user"] |
291 | 301 |
|
292 | | - elif done_response.status == BlossomStatus.blacklisted: |
293 | | - message = i18n["responses"]["general"]["blacklisted"] |
| 302 | + elif done_response.status == BlossomStatus.blocked: |
| 303 | + message = i18n["responses"]["general"]["blocked"] |
| 304 | + modchat_blocked_user_ping(user.name, blossom_submission, cfg) |
294 | 305 |
|
295 | 306 | return message, return_flair |
296 | 307 |
|
297 | 308 |
|
298 | 309 | @beeline.traced(name="process_unclaim") |
299 | 310 | def process_unclaim( |
300 | | - username: str, blossom_submission: Dict, submission: Submission, cfg: Config |
| 311 | + username: str, blossom_submission: dict, submission: Submission, cfg: Config |
301 | 312 | ) -> Tuple: |
302 | 313 | """ |
303 | 314 | Process an unclaim request. |
@@ -331,8 +342,9 @@ def process_unclaim( |
331 | 342 | message = unclaim_messages["claimed_other_user"] |
332 | 343 | elif response.status == BlossomStatus.already_completed: |
333 | 344 | message = unclaim_messages["post_already_completed"] |
334 | | - elif response.status == BlossomStatus.blacklisted: |
335 | | - message = i18n["responses"]["general"]["blacklisted"] |
| 345 | + elif response.status == BlossomStatus.blocked: |
| 346 | + message = i18n["responses"]["general"]["blocked"] |
| 347 | + modchat_blocked_user_ping(username, blossom_submission, cfg) |
336 | 348 | else: |
337 | 349 | message = unclaim_messages["still_unclaimed"] |
338 | 350 | return message, return_flair |
|
0 commit comments