Skip to content

Commit

Permalink
Merge branch 'GrafeasGroup:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erenbektas authored Aug 25, 2022
2 parents 0cbe674 + f99bd16 commit e76aa06
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
## [UNRELEASED]

- Track timestamp of last reddit post processed before sending to mod chat (credit: @crhopkins)
- Add missing backslash in unescaped heading string (credit: @MurdoMaclachlan)

## [4.2.4] - 2021-04-05

Expand Down
12 changes: 11 additions & 1 deletion tor/core/inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
log = logging.getLogger(__name__)


def extract_sub_from_url(url: str) -> str:
"""returns the sub name from the given url without "r/" at the start."""
return url.split("/")[4]


@beeline.traced(name="forward_to_slack")
def forward_to_slack(item: InboxableMixin, cfg: Config) -> None:
username = str(item.author.name)
Expand All @@ -66,7 +71,12 @@ def process_reply(reply: Comment, cfg: Config) -> None:
r_body = reply.body.lower() # cache that thing

if "image transcription" in r_body or is_comment_transcription(reply, cfg):
message = i18n["responses"]["general"]["transcript_on_tor_post"]
post_link = reply.submission.url
sub_name = extract_sub_from_url(post_link)
message = i18n["responses"]["general"]["transcript_on_tor_post"].format(
sub_name=sub_name,
post_link=post_link,
)
elif matches := [
match.group()
for match in [regex.search(reply.body) for regex in MOD_SUPPORT_PHRASES]
Expand Down
5 changes: 2 additions & 3 deletions tor/strings/en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ responses:
[Hey, you're welcome!]({})
transcript_on_tor_post: |
⚠️ Hi there! I might be wrong, but I think you just posted a transcription in reply to me.
The transcription should be made as a **top-level comment** on the post that you're working on transcribing.
For example, if the content is on r\/nicegirls, then the transcription should be commented as a reply to that submission on r\/nicegirls.
The transcription should be made as a **top-level comment** on the [post on r\/{sub_name}]({post_link}).
After you've commented there, come back to me and reply with `done` and I can process it!
Do you need assistance? Reply to me with `help` to summon a moderator!
Expand Down Expand Up @@ -331,7 +330,7 @@ formatting_issues:
#Text
To fix this, add a backslash in front of the `#` like so: `#Text`. If you meant for it to render as a heading, please add a space after the `#` to avoid this warning. i.e. `# Text`."
To fix this, add a backslash in front of the `#` like so: `\\#Text`. If you meant for it to render as a heading, please add a space after the `#` to avoid this warning. i.e. `# Text`."
invalid_header: "**Invalid header**: It looks like your header doesn't contain a proper type (Image, Video, or Audio), is missing italics, and/or is not at the start of your transcription. Please make sure your post contains a proper header at the start of your transcription. For example if it's an Image Transcription, it should be the following at the start of your transcription:
Expand Down

0 comments on commit e76aa06

Please sign in to comment.