reddit-moderator-toolbox icon indicating copy to clipboard operation
reddit-moderator-toolbox copied to clipboard

Add several token placeholders for mod macros

Open dequeued0 opened this issue 3 years ago • 5 comments

Could you please add several token placeholders?

  • {permalink}
  • {content} - comment body, submission body if selfpost, or submission link if link post (similar to {{body}} in AutoModerator, but might as well fill it in with the destination link if it's a link post so some macros can be more general purpose)
  • {link_flair_text} - link flair text for submissions (only Post context)
  • {link_flair_css_class} - link flair css class for submissions (only Post context)

Thanks!

dequeued0 avatar Apr 24 '22 21:04 dequeued0

Some of those are already available, just not documented all that well at times.

{permalink}

Is already a thing. Also available is

{content}

Also already a thing, in fact you can choose between

  • body - Will give the body as a quote
  • raw_body - Just the body
  • uri_body - The body uri encoded

Basically the following tokens might be available (depending on context)

  • {subreddit}
  • {user}
  • {author}
  • {permalink}
  • {url}
  • {domain}
  • {id}
  • {body}
  • {raw_body}
  • {uri_body}
  • {approved_by}
  • {title}
  • {uri_title}
  • {kind}
  • {postlink}
  • {link}
  • {banned_by}
  • {spam}
  • {ham}
  • {rules}
  • {sidebar}
  • {wiki}
  • {mod}

Also as a fyi, they should be available not just with macros but also within removal reasons and such. Some of them are not documented as they are not that useful as tokens. However the info object they are provided by is also used elsewhere.

creesch avatar Apr 25 '22 12:04 creesch

Seperate comment for the remaining two

{link_flair_text}

This one I can see a use case for I suppose. I am not sure if it is something we can easily fetch at all times. For context, on old reddit we scrape the page rather than doing an API call. In general listings like your frontpage and profiles flairs are not shown so also not something we can easily implement there. So if we wanted to implement this we would need to switch everything over to making use of an API call to fetch that data.

{link_flair_css_class}

Same limitation as the previous one. I am also curious what the use case for this one would be within the context of macros?

creesch avatar Apr 25 '22 12:04 creesch

Thanks for the response! I had no idea all of those existed.

1. {content}

The idea of {content} was to allow a placeholder for submission and comment removals that would always "just work" for the content of a submission or comment being removed regardless of it being a text submission, link submission, or comment. While you can use one of the link placeholders and one of the body placeholders, there's no way to get either. It might also be useful to provide a uri_content version if you like the idea. I think this is most likely to be used for submission removals in general. My experience is that there are cases where it's good to include a copy of the submission text if OP is likely to pull edit shenanigans (obviously, that's not an issue with link submissions, but it's good to just have a single macro for whatever the rule is).

For example:

Your {kind} has been removed.

submission: {permalink}

submission content:

---

{content}

2. link flair tokens

The main idea for these is if the link flair is related to the removal. For example, some subreddits restrict certain flairs to certain days of the week. Some subreddits also put a removal reason in the link flair and it might be useful to be able to mention the link flair in an associated mod macro comment (e.g., fast answers for people asking why a post was locked or removed, making an occasional removal as a human instead via a bot, etc.). I think the link flair text is probably the more useful token of the two, but I could see using the link flair css class in a modmail or message link (or something like that).

dequeued0 avatar Apr 25 '22 21:04 dequeued0

re: your {content} idea, can't you just do something like {body}{link} instead? {body} should be empty on link posts, and {link} should be empty on comments and other types of posts, so putting them together means you get one or the other depending on what's present.

eritbh avatar Apr 25 '22 22:04 eritbh

For a self post with the text of "The quick brown fox jumps over the lazy dog.", {body}{link} is replaced by the string "The quick brown fox jumps over the lazy dog./r/subredditname/comments/someid/some_title_string/".

dequeued0 avatar Apr 25 '22 23:04 dequeued0