Skip to content

Commit

Permalink
Batch fixes: vector update, template/autobot fixes (#159)
Browse files Browse the repository at this point in the history
* Fix template and bot conditional issues

* Update vector.toml for latest vector

And update supervisor.conf for latest vector

* Spell 'reapproval' correctly everywhere

* Update fly.*.toml files for new services
  • Loading branch information
leikahing authored May 13, 2024
1 parent f0dd2cd commit fb2fc1b
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 23 deletions.
3 changes: 2 additions & 1 deletion autobot/autobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def reject_by_timelimit(self, post: praw.models.Submission) -> bool:
}
logger.info("Rejecting post and notifying author", **log_params)
msg = self.msg_bld.create_post_a_day_msg(
post.shortlink,
human_fmt,
self.reddit.create_modmail_link()
)
Expand Down Expand Up @@ -244,7 +245,7 @@ def prepare_delete_message(
modmail_link = self.reddit.create_modmail_link()

if post_meta.invalid_tags:
reapproval_msg = self.msg_build.create_title_approval_msg(post.shortlink)
reapproval_msg = self.msg_bld.create_title_approval_msg(post.shortlink)
else:
reapproval_msg = self.msg_bld.create_approval_msg(post.shortlink)

Expand Down
12 changes: 9 additions & 3 deletions autobot/util/messages/templater.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class MessageBuilder:
TEMPLATES = {
"repproval": "reapproval.template",
"reapproval": "reapproval.template",
"series-pm": "series_message.md.template",
"series-comment": "series_comment.md.template",
"post-a-day": "post_a_day.md.template",
Expand All @@ -20,18 +20,24 @@ def _render(self, template: str, **kwargs) -> str:
return t.render(**kwargs)

def create_approval_msg(self, post_url: str) -> str:
return self._render("repproval", post_url=post_url)
return self._render("reapproval", post_url=post_url)

def create_title_approval_msg(self, post_url: str) -> str:
return self._render("repproval", post_url=post_url, is_title_repproval=True)
return self._render(
"reapproval",
post_url=post_url,
is_title_reapproval=True
)

def create_post_a_day_msg(
self,
post_url: str,
remaining: str,
modmail_link: str
) -> str:
return self._render(
"post-a-day",
post_url=post_url,
time_remaining=remaining,
modmail_link=modmail_link
)
Expand Down
14 changes: 6 additions & 8 deletions autobot/util/messages/templates/post_removed.md.template
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Hi there! [Your post](${post_url}) has been automatically [removed](https://www.reddit.com/r/NoSleepAuthors/comments/z93asr/comment/jfigj88/) from /r/nosleep for the following reason(s):

% if invalid_tags:
* **[Title Contains Invalid Tags](https://www.reddit.com/r/NoSleepAuthors/comments/zav2k9/comment/iynq9g1)/**
* **[Title Contains Invalid Tags](https://www.reddit.com/r/NoSleepAuthors/comments/zav2k9/comment/iynq9g1)**

The following invalid tags were found in your title: **${invalid_tags}**.

The following invalid tags were found in your title: **${invalid_tags}**.

**[Don't delete this post.](https://www.reddit.com/r/NoSleepAuthors/comments/z93asr/nosleep_indepth_modmail_removals_and_reposts/jfiggh0/)** Titles can't be edited on Reddit, so please [message the NoSleep moderators](${reapproval_modmail}) ONCE with [the link](https://www.reddit.com/r/NoSleepAuthors/comments/13men0r/guide_to_getting_a_commentpost_link/) to this post and your proposed new title. _Please be patient_ and don't take any further action until the mods reply. This means **don't delete and/or repost.**
% endif

Expand All @@ -16,22 +16,20 @@ Hi there! [Your post](${post_url}) has been automatically [removed](https://www.
Titles can't be edited on Reddit, so you may repost this story **one time only** with a corrected title, but it will still be reviewed by human moderators and may be removed again if it breaks [other NoSleep rules](https://www.reddit.com/r/nosleep/wiki/index/).
% endif

% if long_paragraphs:
% if long_paragraphs:
* **[Long Paragraphs (Over 350 Words)](https://www.reddit.com/r/NoSleepAuthors/comments/zav2k9/comment/iynqcom/)**

You have one or more paragraphs containing more than 350 words. Please break up your story into smaller paragraphs. You can create paragraphs by pressing `Enter` twice at the end of a line.

**[Don't delete this post.](https://www.reddit.com/r/NoSleepAuthors/comments/z93asr/nosleep_indepth_modmail_removals_and_reposts/jfiggh0/)** You may [edit it](https://www.reddit.com/r/NoSleepAuthors/comments/z93asr/comment/jfigt8d/), then [message the NoSleep moderators](${reapproval_modmail}) ONCE to ask for a review. Be sure to include [the link](https://www.reddit.com/r/NoSleepAuthors/comments/13men0r/guide_to_getting_a_commentpost_link/) to this post. _Please be patient_ and don't take any further action until the mods reply. This means **don't delete and/or repost.**
% endif
% endif

% if has_codeblocks:
% if has_codeblocks:
* **[Indents/Spaces at the Start of Paragraphs](https://www.reddit.com/r/NoSleepAuthors/comments/zav2k9/comment/iynqcom/)**

You have one or more paragraphs beginning with a tab or four or more spaces. On Reddit, lines beginning with a tab or four or more spaces are treated as blocks of code and can make your story unreadable. Please remove tabs or spaces at the beginning of paragraphs/lines. You can create paragraphs by pressing `Enter` twice at the end of a line.

**[Don't delete this post.](https://www.reddit.com/r/NoSleepAuthors/comments/z93asr/nosleep_indepth_modmail_removals_and_reposts/jfiggh0/)** You may [edit it](https://www.reddit.com/r/NoSleepAuthors/comments/z93asr/comment/jfigt8d/) to remove the indents, then [message the NoSleep moderators](${reapproval_modmail}) ONCE to ask for a review. Be sure to include [the link](https://www.reddit.com/r/NoSleepAuthors/comments/13men0r/guide_to_getting_a_commentpost_link/) to this post. _Please be patient_ and don't take any further action until the mods reply. This means **don't delete and/or repost.**

% endif
% endif

**See also:** [NoSleep Posting Guidelines](http://www.reddit.com/r/nosleep/wiki/index) | [NoSleepAuthors](https://www.reddit.com/r/NoSleepAuthors/comments/z0qnxx/introduction_to_nosleepauthors/) | [Similar Subreddits](https://www.reddit.com/r/nosleep/wiki/similarsubreddits) | [Author FAQ](https://www.reddit.com/r/NoSleepAuthors/comments/13hku3x/nosleep_faq_authors/) | [Beginner's Guide to Reddit](https://www.reddit.com/r/NoSleepAuthors/comments/10lw4z9/a_beginners_guide_to_reddit/) | [If you use the Reddit app](https://www.reddit.com/r/NoSleepOOC/comments/x2t7ur/reddit_app_users_please_read/)
Expand Down
4 changes: 2 additions & 2 deletions autobot/util/messages/templates/reapproval.template
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
% if is_title_reapproval:
[My post](${post_url}) to /r/NoSleep was removed for title issues. My proposed new title is [TITLE HERE].
% else
% else:
[My post](${post_url}) to /r/NoSleep was removed for formatting issues. I have fixed those issues and am now requesting re-approval.

_Note to moderation team: if this story is eligible for re-approval, remember to remove the bot's comment from it._
% endif
19 changes: 13 additions & 6 deletions deploy/vector/vector.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[api]
enabled = true
address = "0.0.0.0:8686"
address = "[::]:8686"

[sources.fly_log_metrics]
type = "internal_metrics"

[sources.nats]
type = "nats"
url = "nats://[fdaa::3]:4223"
url = "nats://[${NETWORK:fdaa}::3]:4223"
queue = "${QUEUE-}"
subject = "${SUBJECT-logs.>}"
auth.strategy = "user_password"
Expand All @@ -25,19 +25,26 @@
[sinks.fly_log_metrics_prometheus]
type = "prometheus_exporter" # required
inputs = ["fly_log_metrics"] # required
address = "0.0.0.0:9598" # required
address = "[::]:9598" # required
default_namespace = "fly-logs" # optional, no default

[sinks.blackhole]
type = "blackhole"
inputs = ["log_json"]
print_interval_secs = 100000

[transforms.remap_better_stack_timestamp]
type = "remap"
inputs = ["log_json"]
source = '''
.dt = del(.timestamp)
'''

[sinks.logtail]
type = "http"
inputs = ["log_json"]
uri = "https://in.logtail.com"
inputs = ["remap_better_stack_timestamp"]
uri = "https://in.logs.betterstack.com"
encoding.codec = "json"
auth.strategy = "bearer"
auth.token = "${LOGTAIL_TOKEN}"
auth.token = "${BETTER_STACK_SOURCE_TOKEN:-LOGTAIL_TOKEN}"

6 changes: 5 additions & 1 deletion fly.prod.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ processes = []
[build]
dockerfile = "Dockerfile"

[[services]]
http_checks = []
internal_port = 8686

[env]
AUTOBOT_IGNORE_OLD_POSTS = "true"
AUTOBOT_IGNORE_OLDER_THAN = "43200"
AUTOBOT_POST_TIMELIMIT = "86400"
AUTOBOT_ENFORCE_TIMELIMIT = "true"
AUTOBOT_SUBREDDIT = "nosleep"
AUTOBOT_USER_AGENT = "/r/nosleep AutoBot v20230224 (by /u/SofaAssassin)"
AUTOBOT_USER_AGENT = "/r/nosleep AutoBot v20240512 (by /u/SofaAssassin)"
DEVELOPMENT_MODE = "false"
ORG="sofaworks"

Expand Down
2 changes: 1 addition & 1 deletion fly.staging.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ processes = []
AUTOBOT_POST_TIMELIMIT = "3600"
AUTOBOT_ENFORCE_TIMELIMIT = "true"
AUTOBOT_SUBREDDIT = "caneles"
AUTOBOT_USER_AGENT = "/r/nosleep AutoBot v20230224 (by /u/SofaAssassin)"
AUTOBOT_USER_AGENT = "/r/nosleep AutoBot v20240512 (by /u/SofaAssassin)"
DEVELOPMENT_MODE = "false"
ORG="sofaworks"

Expand Down
2 changes: 1 addition & 1 deletion supervisor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ directory=/zeus
autorestart=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
command=vector -c /etc/vector/vector.toml
command=vector --config /etc/vector/vector.toml

0 comments on commit fb2fc1b

Please sign in to comment.