v1.3.0: add options to flag all shows or specific shows as 18+

main
xenofem 2023-07-11 12:20:40 -04:00
parent 1528bf3d9a
commit 4ec1794403
6 changed files with 16 additions and 3 deletions

2
Cargo.lock generated
View File

@ -1219,7 +1219,7 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "screencap-bot"
version = "1.2.0"
version = "1.3.0"
dependencies = [
"anyhow",
"dotenvy",

View File

@ -1,6 +1,6 @@
[package]
name = "screencap-bot"
version = "1.2.0"
version = "1.3.0"
edition = "2021"
authors = ["xenofem <xenofem@xeno.science>"]
license = "MIT"

View File

@ -26,6 +26,9 @@ directory:
- `SCREENCAP_BOT_COHOST_PAGE`: the cohost page the bot should post from
- `SCREENCAP_BOT_COHOST_DRAFT`: whether to create cohost posts as
drafts, eg for testing (default: `false`)
- `SCREENCAP_BOT_18PLUS`: whether posts should be flagged as
containing 18+ content (default: `false`). this can be overridden
for individual shows, see below.
- `RUST_LOG`: log levels, for the app as a whole and/or for specific
submodules/libraries. See
[`env_logger`](https://docs.rs/env_logger/latest/env_logger/)'s
@ -50,6 +53,9 @@ MS IGLOO:
parts:
1: The Hidden One Year War
2: Apocalypse 0079
Gundam 0069:
path: /home/user/media/Gundam 0069
18+: true
```
each top-level key is a show title, which will be used in spoiler
@ -66,3 +72,6 @@ warnings on posts and in image alt text. each show has two keys:
this is a map rather than a list, since show season numbers may be 1-indexed or 0-indexed.
- `weight`: an optional weight for this show in the random sampling of
shows. each show without a weight specified has a weight of `1.0`.
- `18+`: an optional setting for whether screencaps from this show
should be flagged as containing 18+ content. if present, this takes
precedence over the `SCREENCAP_BOT_18PLUS` environment variable.

View File

@ -14,6 +14,7 @@ pub struct Config {
pub cohost_password: String,
pub cohost_page: String,
pub cohost_draft: bool,
pub eighteen_plus: bool,
}
const VAR_PREFIX: &str = "SCREENCAP_BOT_";
@ -44,5 +45,6 @@ pub fn load() -> Config {
cohost_password: expect_var("COHOST_PASSWORD"),
cohost_page: expect_var("COHOST_PAGE"),
cohost_draft: parse_var("COHOST_DRAFT").unwrap_or(false),
eighteen_plus: parse_var("18PLUS").unwrap_or(false),
}
}

View File

@ -138,7 +138,7 @@ async fn post_random_screencap<R: Rng>(
attachments: vec![attachment],
tags,
draft: conf.cohost_draft,
adult_content: false,
adult_content: show.eighteen_plus.unwrap_or(conf.eighteen_plus),
headline: String::new(),
markdown: String::new(),
metadata: None,

View File

@ -22,6 +22,8 @@ pub struct Show {
pub parts: HashMap<u32, String>,
#[serde(default = "default_weight")]
pub weight: f32,
#[serde(default, rename = "18+")]
pub eighteen_plus: Option<bool>,
}
fn default_weight() -> f32 {