Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

WIP Slack Ping For Transcripts on Tor Posts #357

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tor/core/inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@

log = logging.getLogger(__name__)

THINK_EMOTES = [
":thinking_party:",
":think-rotate:",
":monoclethink:",
":eggplant-think:",
":thinking-screensaver:"
]
erenbektas marked this conversation as resolved.
Show resolved Hide resolved


def extract_sub_from_url(url: str) -> str:
"""returns the sub name from the given url without "r/" at the start."""
Expand Down Expand Up @@ -73,10 +81,21 @@ def process_reply(reply: Comment, cfg: Config) -> None:
if "image transcription" in r_body or is_comment_transcription(reply, cfg):
post_link = reply.submission.url
sub_name = extract_sub_from_url(post_link)
user_url = i18n["urls"]["reddit_url"].format(f"/u/{username}")
post_url = i18n["urls"]["reddit_url"].format(context)
tor_post = submission.tor_url
itsthejoker marked this conversation as resolved.
Show resolved Hide resolved
emote = random.choice(THINK_EMOTES)
message = i18n["responses"]["general"]["transcript_on_tor_post"].format(
sub_name=sub_name,
post_link=post_link,
)
send_to_modchat(
f"<{user_url}|u/{username}> posted a "
f"<{post_url}|transcription> on "
f"<{tor_post}|ToR post> instead of posting it on "
f"<{post_link}|r/{sub_name}>. {emote}"
erenbektas marked this conversation as resolved.
Show resolved Hide resolved
cfg,
)
elif matches := [
match.group()
for match in [regex.search(reply.body) for regex in MOD_SUPPORT_PHRASES]
Expand Down