v1.3.0: add options to flag all shows or specific shows as 18+
This commit is contained in:
parent
1528bf3d9a
commit
4ec1794403
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1219,7 +1219,7 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "screencap-bot"
|
name = "screencap-bot"
|
||||||
version = "1.2.0"
|
version = "1.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "screencap-bot"
|
name = "screencap-bot"
|
||||||
version = "1.2.0"
|
version = "1.3.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["xenofem <xenofem@xeno.science>"]
|
authors = ["xenofem <xenofem@xeno.science>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
@ -26,6 +26,9 @@ directory:
|
||||||
- `SCREENCAP_BOT_COHOST_PAGE`: the cohost page the bot should post from
|
- `SCREENCAP_BOT_COHOST_PAGE`: the cohost page the bot should post from
|
||||||
- `SCREENCAP_BOT_COHOST_DRAFT`: whether to create cohost posts as
|
- `SCREENCAP_BOT_COHOST_DRAFT`: whether to create cohost posts as
|
||||||
drafts, eg for testing (default: `false`)
|
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
|
- `RUST_LOG`: log levels, for the app as a whole and/or for specific
|
||||||
submodules/libraries. See
|
submodules/libraries. See
|
||||||
[`env_logger`](https://docs.rs/env_logger/latest/env_logger/)'s
|
[`env_logger`](https://docs.rs/env_logger/latest/env_logger/)'s
|
||||||
|
@ -50,6 +53,9 @@ MS IGLOO:
|
||||||
parts:
|
parts:
|
||||||
1: The Hidden One Year War
|
1: The Hidden One Year War
|
||||||
2: Apocalypse 0079
|
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
|
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.
|
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
|
- `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`.
|
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.
|
||||||
|
|
|
@ -14,6 +14,7 @@ pub struct Config {
|
||||||
pub cohost_password: String,
|
pub cohost_password: String,
|
||||||
pub cohost_page: String,
|
pub cohost_page: String,
|
||||||
pub cohost_draft: bool,
|
pub cohost_draft: bool,
|
||||||
|
pub eighteen_plus: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
const VAR_PREFIX: &str = "SCREENCAP_BOT_";
|
const VAR_PREFIX: &str = "SCREENCAP_BOT_";
|
||||||
|
@ -44,5 +45,6 @@ pub fn load() -> Config {
|
||||||
cohost_password: expect_var("COHOST_PASSWORD"),
|
cohost_password: expect_var("COHOST_PASSWORD"),
|
||||||
cohost_page: expect_var("COHOST_PAGE"),
|
cohost_page: expect_var("COHOST_PAGE"),
|
||||||
cohost_draft: parse_var("COHOST_DRAFT").unwrap_or(false),
|
cohost_draft: parse_var("COHOST_DRAFT").unwrap_or(false),
|
||||||
|
eighteen_plus: parse_var("18PLUS").unwrap_or(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ async fn post_random_screencap<R: Rng>(
|
||||||
attachments: vec![attachment],
|
attachments: vec![attachment],
|
||||||
tags,
|
tags,
|
||||||
draft: conf.cohost_draft,
|
draft: conf.cohost_draft,
|
||||||
adult_content: false,
|
adult_content: show.eighteen_plus.unwrap_or(conf.eighteen_plus),
|
||||||
headline: String::new(),
|
headline: String::new(),
|
||||||
markdown: String::new(),
|
markdown: String::new(),
|
||||||
metadata: None,
|
metadata: None,
|
||||||
|
|
|
@ -22,6 +22,8 @@ pub struct Show {
|
||||||
pub parts: HashMap<u32, String>,
|
pub parts: HashMap<u32, String>,
|
||||||
#[serde(default = "default_weight")]
|
#[serde(default = "default_weight")]
|
||||||
pub weight: f32,
|
pub weight: f32,
|
||||||
|
#[serde(default, rename = "18+")]
|
||||||
|
pub eighteen_plus: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_weight() -> f32 {
|
fn default_weight() -> f32 {
|
||||||
|
|
Loading…
Reference in a new issue