Fediverse publisher

This commit is contained in:
Izzy Swart 2021-07-05 19:13:51 -07:00
parent 97f84dd49b
commit 9bb93a8a51
7 changed files with 231 additions and 479 deletions

525
Cargo.lock generated
View File

@ -185,16 +185,6 @@ dependencies = [
"rustc-demangle",
]
[[package]]
name = "base64"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643"
dependencies = [
"byteorder",
"safemem",
]
[[package]]
name = "base64"
version = "0.10.1"
@ -204,39 +194,12 @@ dependencies = [
"byteorder",
]
[[package]]
name = "base64"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "block-buffer"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
dependencies = [
"block-padding",
"byte-tools",
"byteorder",
"generic-array",
]
[[package]]
name = "block-padding"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
dependencies = [
"byte-tools",
]
[[package]]
name = "blocking"
version = "1.0.2"
@ -257,18 +220,6 @@ version = "3.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631"
[[package]]
name = "byte-tools"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
[[package]]
name = "bytecount"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72feb31ffc86498dacdbd0fcebb56138e7177a8cc5cea4516031d15ae85a742e"
[[package]]
name = "byteorder"
version = "1.4.3"
@ -304,28 +255,6 @@ version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba"
[[package]]
name = "cargo-platform"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0226944a63d1bf35a3b5f948dd7c59e263db83695c9e8bffc4037de02e30f1d7"
dependencies = [
"serde",
]
[[package]]
name = "cargo_metadata"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7714a157da7991e23d90686b9524b9e12e0407a108647f52e9328f4b3d51ac7f"
dependencies = [
"cargo-platform",
"semver 0.11.0",
"semver-parser 0.10.2",
"serde",
"serde_json",
]
[[package]]
name = "cc"
version = "1.0.68"
@ -334,9 +263,9 @@ checksum = "4a72c244c1ff497a746a7e1fb3d14bd08420ecda70c8f25c7112f2781652d787"
[[package]]
name = "cfg-if"
version = "0.1.10"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
checksum = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
[[package]]
name = "cfg-if"
@ -447,7 +376,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace"
dependencies = [
"autocfg 1.0.1",
"cfg-if 0.1.10",
"cfg-if 0.1.9",
"crossbeam-utils 0.7.2",
"lazy_static",
"maybe-uninit",
@ -461,7 +390,7 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570"
dependencies = [
"cfg-if 0.1.10",
"cfg-if 0.1.9",
"crossbeam-utils 0.7.2",
"maybe-uninit",
]
@ -473,7 +402,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8"
dependencies = [
"autocfg 1.0.1",
"cfg-if 0.1.10",
"cfg-if 0.1.9",
"lazy_static",
]
@ -497,21 +426,6 @@ dependencies = [
"syn",
]
[[package]]
name = "data-encoding"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57"
[[package]]
name = "digest"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
dependencies = [
"generic-array",
]
[[package]]
name = "doc-comment"
version = "0.3.3"
@ -530,31 +444,6 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]]
name = "elefren"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba08a959d3824df696d49c2ec023f45851f663c47b57b2de933aab749104cd18"
dependencies = [
"chrono",
"doc-comment",
"hyper-old-types",
"isolang",
"log 0.4.14",
"reqwest",
"serde",
"serde_derive",
"serde_json",
"serde_qs",
"serde_urlencoded 0.6.1",
"skeptic",
"tap-reader",
"toml",
"try_from",
"tungstenite",
"url 1.7.2",
]
[[package]]
name = "encoding_rs"
version = "0.8.28"
@ -564,16 +453,6 @@ dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "error-chain"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc"
dependencies = [
"backtrace",
"version_check 0.9.3",
]
[[package]]
name = "event-listener"
version = "2.5.1"
@ -602,12 +481,6 @@ dependencies = [
"synstructure",
]
[[package]]
name = "fake-simd"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
[[package]]
name = "fastrand"
version = "1.4.1"
@ -813,26 +686,6 @@ dependencies = [
"slab",
]
[[package]]
name = "generic-array"
version = "0.12.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
dependencies = [
"typenum",
]
[[package]]
name = "getrandom"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
dependencies = [
"cfg-if 1.0.0",
"libc",
"wasi 0.9.0+wasi-snapshot-preview1",
]
[[package]]
name = "getrandom"
version = "0.2.3"
@ -841,7 +694,7 @@ checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
dependencies = [
"cfg-if 1.0.0",
"libc",
"wasi 0.10.2+wasi-snapshot-preview1",
"wasi",
]
[[package]]
@ -850,12 +703,6 @@ version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e4075386626662786ddb0ec9081e7c7eeb1ba31951f447ca780ef9f5d568189"
[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "gloo-timers"
version = "0.2.1"
@ -968,9 +815,9 @@ dependencies = [
[[package]]
name = "httparse"
version = "1.4.1"
version = "1.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68"
checksum = "bc35c995b9d93ec174cf9a27d425c7892722101e14993cd227fdb51d70cf9589"
[[package]]
name = "httpdate"
@ -1032,23 +879,6 @@ dependencies = [
"want 0.3.0",
]
[[package]]
name = "hyper-old-types"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6896be51ecf3966c0fa14ff2da3233dbb9aef57ccea1be1afe55f105f4d4c9c4"
dependencies = [
"base64 0.9.3",
"bytes 0.4.12",
"httparse",
"language-tags",
"log 0.4.14",
"mime 0.3.16",
"percent-encoding 1.0.1",
"time",
"unicase 2.6.0",
]
[[package]]
name = "hyper-tls"
version = "0.3.2"
@ -1075,6 +905,25 @@ dependencies = [
"tokio-tls",
]
[[package]]
name = "hyperx"
version = "0.15.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad5125567a8328ced412a29a52a3ca0a2520c617d40a8bee62d12d877eec236c"
dependencies = [
"base64",
"bytes 0.4.12",
"cfg-if 0.1.9",
"http 0.1.21",
"httparse",
"language-tags",
"log 0.4.14",
"mime 0.3.16",
"percent-encoding 1.0.1",
"time",
"unicase 2.5.1",
]
[[package]]
name = "idna"
version = "0.1.5"
@ -1107,15 +956,6 @@ dependencies = [
"hashbrown",
]
[[package]]
name = "input_buffer"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19a8a95243d5a0398cae618ec29477c6e3cb631152be5c19481f80bc71559754"
dependencies = [
"bytes 0.5.6",
]
[[package]]
name = "instant"
version = "0.1.9"
@ -1134,17 +974,6 @@ dependencies = [
"libc",
]
[[package]]
name = "isolang"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "265ef164908329e47e753c769b14cbb27434abf0c41984dca201484022f09ce5"
dependencies = [
"phf",
"phf_codegen",
"serde",
]
[[package]]
name = "itoa"
version = "0.4.7"
@ -1157,14 +986,14 @@ version = "0.1.0"
dependencies = [
"anyhow",
"async-std",
"chrono",
"elefren",
"futures 0.3.15",
"futures-timer",
"mammut",
"rand 0.8.4",
"serde",
"serde_json",
"telegram-bot",
"thiserror",
"tokio 0.2.25",
"uuid 0.8.2",
]
@ -1243,6 +1072,23 @@ dependencies = [
"value-bag",
]
[[package]]
name = "mammut"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1771d6ce236f93ec0bc3086945a189c94953e59edc0a6908fae36019d53c8220"
dependencies = [
"chrono",
"doc-comment",
"hyperx",
"log 0.4.14",
"reqwest",
"serde",
"serde_derive",
"serde_json",
"url 1.7.2",
]
[[package]]
name = "matches"
version = "0.1.8"
@ -1304,7 +1150,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212"
dependencies = [
"mime 0.3.16",
"unicase 2.6.0",
"unicase 2.5.1",
]
[[package]]
@ -1323,7 +1169,7 @@ version = "0.6.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4"
dependencies = [
"cfg-if 0.1.10",
"cfg-if 0.1.9",
"fuchsia-zircon",
"fuchsia-zircon-sys",
"iovec",
@ -1417,7 +1263,7 @@ version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae"
dependencies = [
"cfg-if 0.1.10",
"cfg-if 0.1.9",
"libc",
"winapi 0.3.9",
]
@ -1466,12 +1312,6 @@ version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
[[package]]
name = "opaque-debug"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
[[package]]
name = "openssl"
version = "0.10.35"
@ -1537,7 +1377,7 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b"
dependencies = [
"cfg-if 0.1.10",
"cfg-if 0.1.9",
"cloudabi",
"libc",
"redox_syscall 0.1.57",
@ -1558,15 +1398,6 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "pest"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53"
dependencies = [
"ucd-trie",
]
[[package]]
name = "phf"
version = "0.7.24"
@ -1700,17 +1531,6 @@ dependencies = [
"url 2.2.2",
]
[[package]]
name = "pulldown-cmark"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8"
dependencies = [
"bitflags",
"memchr",
"unicase 2.6.0",
]
[[package]]
name = "quote"
version = "1.0.9"
@ -1739,19 +1559,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "rand"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
"getrandom 0.1.16",
"libc",
"rand_chacha 0.2.2",
"rand_core 0.5.1",
"rand_hc 0.2.0",
]
[[package]]
name = "rand"
version = "0.8.4"
@ -1774,16 +1581,6 @@ dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "rand_chacha"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
dependencies = [
"ppv-lite86",
"rand_core 0.5.1",
]
[[package]]
name = "rand_chacha"
version = "0.3.1"
@ -1809,22 +1606,13 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]]
name = "rand_core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
"getrandom 0.1.16",
]
[[package]]
name = "rand_core"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
dependencies = [
"getrandom 0.2.3",
"getrandom",
]
[[package]]
@ -1836,15 +1624,6 @@ dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "rand_hc"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
dependencies = [
"rand_core 0.5.1",
]
[[package]]
name = "rand_hc"
version = "0.3.1"
@ -1946,7 +1725,7 @@ version = "0.9.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f88643aea3c1343c804950d7bf983bd2067f5ab59db6d613a08e05572f2714ab"
dependencies = [
"base64 0.10.1",
"base64",
"bytes 0.4.12",
"cookie",
"cookie_store",
@ -1962,7 +1741,7 @@ dependencies = [
"native-tls",
"serde",
"serde_json",
"serde_urlencoded 0.5.5",
"serde_urlencoded",
"time",
"tokio 0.1.22",
"tokio-executor",
@ -1986,7 +1765,7 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
dependencies = [
"semver 0.9.0",
"semver",
]
[[package]]
@ -1995,21 +1774,6 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "safemem"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "schannel"
version = "0.1.19"
@ -2055,17 +1819,7 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
"semver-parser 0.7.0",
]
[[package]]
name = "semver"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
dependencies = [
"semver-parser 0.10.2",
"serde",
"semver-parser",
]
[[package]]
@ -2074,15 +1828,6 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "semver-parser"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7"
dependencies = [
"pest",
]
[[package]]
name = "serde"
version = "1.0.126"
@ -2124,18 +1869,6 @@ dependencies = [
"serde",
]
[[package]]
name = "serde_qs"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35965fa1d2413717053d67c2df1f5c3e1763fbf77200ea7e767523707bd5a0af"
dependencies = [
"data-encoding",
"error-chain",
"percent-encoding 1.0.1",
"serde",
]
[[package]]
name = "serde_urlencoded"
version = "0.5.5"
@ -2148,30 +1881,6 @@ dependencies = [
"url 1.7.2",
]
[[package]]
name = "serde_urlencoded"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97"
dependencies = [
"dtoa",
"itoa",
"serde",
"url 2.2.2",
]
[[package]]
name = "sha-1"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
dependencies = [
"block-buffer",
"digest",
"fake-simd",
"opaque-debug",
]
[[package]]
name = "signal-hook"
version = "0.3.9"
@ -2197,21 +1906,6 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
[[package]]
name = "skeptic"
version = "0.13.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "188b810342d98f23f0bb875045299f34187b559370b041eb11520c905370a888"
dependencies = [
"bytecount",
"cargo_metadata",
"error-chain",
"glob",
"pulldown-cmark",
"tempfile",
"walkdir",
]
[[package]]
name = "slab"
version = "0.4.3"
@ -2280,12 +1974,6 @@ dependencies = [
"unicode-xid",
]
[[package]]
name = "tap-reader"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f13fc301d415a8cd4529ba679720c59f07369bcff573618a6e8d5afebefb6f3"
[[package]]
name = "telegram-bot"
version = "0.8.0"
@ -2330,6 +2018,26 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "thiserror"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "time"
version = "0.1.43"
@ -2547,15 +2255,6 @@ dependencies = [
"tokio 0.2.25",
]
[[package]]
name = "toml"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa"
dependencies = [
"serde",
]
[[package]]
name = "tower-service"
version = "0.3.1"
@ -2617,41 +2316,9 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b"
dependencies = [
"cfg-if 0.1.10",
"cfg-if 0.1.9",
]
[[package]]
name = "tungstenite"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfea31758bf674f990918962e8e5f07071a3161bd7c4138ed23e416e1ac4264e"
dependencies = [
"base64 0.11.0",
"byteorder",
"bytes 0.5.6",
"http 0.2.4",
"httparse",
"input_buffer",
"log 0.4.14",
"native-tls",
"rand 0.7.3",
"sha-1",
"url 2.2.2",
"utf-8",
]
[[package]]
name = "typenum"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06"
[[package]]
name = "ucd-trie"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
[[package]]
name = "unicase"
version = "1.4.2"
@ -2663,11 +2330,11 @@ dependencies = [
[[package]]
name = "unicase"
version = "2.6.0"
version = "2.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
checksum = "2e2e6bd1e59e56598518beb94fd6db628ded570326f0a98c679a304bd9f00150"
dependencies = [
"version_check 0.9.3",
"version_check 0.1.5",
]
[[package]]
@ -2717,12 +2384,6 @@ dependencies = [
"percent-encoding 2.1.0",
]
[[package]]
name = "utf-8"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "uuid"
version = "0.7.4"
@ -2738,7 +2399,7 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
dependencies = [
"getrandom 0.2.3",
"getrandom",
]
[[package]]
@ -2775,17 +2436,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
[[package]]
name = "walkdir"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
dependencies = [
"same-file",
"winapi 0.3.9",
"winapi-util",
]
[[package]]
name = "want"
version = "0.2.0"
@ -2807,12 +2457,6 @@ dependencies = [
"try-lock",
]
[[package]]
name = "wasi"
version = "0.9.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
[[package]]
name = "wasi"
version = "0.10.2+wasi-snapshot-preview1"
@ -2932,15 +2576,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"

View File

@ -6,8 +6,6 @@ edition = "2018"
[dependencies]
async-std = { version = "1.9.0", features = ["unstable"] }
chrono = "0.4.19"
elefren = { version = "0.22.0", features = ["toml"] }
futures = "0.3.15"
futures-timer = "3.0.2"
rand = "0.8.4"
@ -17,3 +15,5 @@ tokio = { version = "0.2", features = ["full"] }
telegram-bot = "0.8.0"
uuid = { version = "0.8.2", features = ["v4"] }
anyhow = "1.0.41"
mammut = "0.13.0"
thiserror = "1.0.26"

View File

@ -14,6 +14,8 @@ pub struct Config {
pub interval_seconds: MinMax,
pub bot_token: String,
pub chat_ref: ChatId,
pub fediverse_oauth_token: String,
pub post_buffer: u32,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
@ -35,6 +37,8 @@ impl Default for Config {
min: 60 * 30,
max: 60 * 90,
},
post_buffer: 5,
fediverse_oauth_token: "".to_owned(),
bot_token: "".to_owned(),
chat_ref: ChatId::new(0),
}

View File

@ -1,14 +1,25 @@
use std::{convert::Infallible, error::Error, sync::Arc};
use std::{convert::Infallible, error::Error, sync::Arc, time::Duration};
use async_std::io::stdin;
use futures_timer::Delay;
use mammut::{
apps::{AppBuilder, Scopes},
Registration,
};
use rand::Rng;
use telegram_bot::{Api, ChatRef};
use crate::selection::{telegram::get_chat_ref, SelectorExt, TelegramSelector};
use crate::{
publish::MastodonPublisher,
selection::{telegram::get_chat_ref, SelectorExt, TelegramSelector},
};
use futures::{sink::unfold, StreamExt};
use model::{EmptyModel, SampleModelExt};
use futures::{channel::mpsc::channel, sink::unfold, SinkExt, StreamExt, TryStreamExt};
use model::SampleModelExt;
mod config;
mod model;
mod publish;
mod selection;
const CONFIG_PATH: &str = "bot_config.json";
@ -27,25 +38,33 @@ async fn main() -> Result<(), Box<dyn Error>> {
}
}?;
// let mut gpt_model = ConsoleSelector.filter(
// model::GPTSampleModel::new(
// cfg.python_path(),
// cfg.gpt_code_path(),
// vec![
// "generate_unconditional_samples.py".to_string(),
// "--model_name".to_string(),
// cfg.model_name(),
// "--temperature".to_string(),
// cfg.temperature(),
// "--top_k".to_string(),
// cfg.top_k(),
// "--nsamples".to_string(),
// "1".to_string(),
// ],
// )
// .into_stream()
// .take(10),
// );
let app = AppBuilder {
client_name: "izzilis",
redirect_uris: "urn:ietf:wg:oauth:2.0:oob",
scopes: Scopes::Write,
website: None,
};
let mut registration = Registration::new(cfg.fediverse_base_url.clone());
registration.register(app)?;
let token = if cfg.fediverse_oauth_token.is_empty() {
let url = registration.authorise()?;
println!("{}", url);
let mut buffer = String::new();
stdin().read_line(&mut buffer).await?;
cfg.fediverse_oauth_token = buffer.clone();
cfg.save(CONFIG_PATH)?;
buffer
} else {
cfg.fediverse_oauth_token.clone()
};
let mastodon = registration.create_access_token(token)?;
let publisher = MastodonPublisher::new(mastodon);
let api = Arc::new(Api::new(
std::env::var("TELEGRAM_BOT_KEY").expect("bot key not present"),
@ -62,8 +81,11 @@ async fn main() -> Result<(), Box<dyn Error>> {
cfg.save(CONFIG_PATH)?;
}
let (sender, receiver) = channel(cfg.post_buffer as usize);
let cfg_clone = cfg.clone();
let mut gpt_model = TelegramSelector::new(
let mut model = TelegramSelector::new(
api,
chat,
Box::pin(unfold((), move |_, chat_ref| {
@ -77,12 +99,52 @@ async fn main() -> Result<(), Box<dyn Error>> {
}
})),
)
.filter(EmptyModel.into_stream())
.take(5);
.filter(
model::GPTSampleModel::new(
cfg.python_path.clone(),
cfg.gpt_code_path.clone(),
vec![
"generate_unconditional_samples.py".to_string(),
"--model_name".to_string(),
cfg.model_name.clone(),
"--temperature".to_string(),
cfg.temperature.clone(),
"--top_k".to_string(),
cfg.top_k.clone(),
"--nsamples".to_string(),
"1".to_string(),
],
)
.into_stream(),
)
.map_err(|e| Box::new(e) as Box<dyn Error>);
while let Some(Ok(sample)) = gpt_model.next().await {
println!("{}", sample);
}
tokio::spawn(async move {
sender
.sink_map_err(|e| Box::new(e) as Box<dyn Error>)
.send_all(&mut model)
.await
.expect("Broken buffer");
});
publisher
.sink_map_err(|e| Box::new(e) as Box<dyn Error>)
.send_all(
&mut receiver
.then(|item| {
let interval_seconds = cfg.interval_seconds.clone();
Box::pin(async move {
Delay::new(Duration::from_millis(
rand::thread_rng()
.gen_range(interval_seconds.min..interval_seconds.max),
))
.await;
item
})
})
.map(Ok),
)
.await?;
return Ok(());
}

40
src/publish/mastodon.rs Normal file
View File

@ -0,0 +1,40 @@
use std::{
pin::Pin,
task::{Context, Poll},
};
use futures::Sink;
use mammut::{status_builder::Visibility, Mastodon, StatusBuilder};
pub struct MastodonPublisher {
mastodon: Mastodon,
}
impl MastodonPublisher {
pub fn new(mastodon: Mastodon) -> Self {
Self { mastodon }
}
}
impl Sink<String> for MastodonPublisher {
type Error = mammut::Error;
fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn start_send(self: Pin<&mut Self>, item: String) -> Result<(), Self::Error> {
let mut post = StatusBuilder::new(item);
post.visibility = Some(Visibility::Direct);
self.mastodon.new_status(post)?;
Ok(())
}
fn poll_flush(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn poll_close(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
}

2
src/publish/mod.rs Normal file
View File

@ -0,0 +1,2 @@
mod mastodon;
pub use mastodon::MastodonPublisher;

View File

@ -1,4 +1,6 @@
use futures::{stream::BoxStream, Future, Stream, TryStreamExt};
use std::fmt::Debug;
use thiserror::Error;
mod console;
pub mod telegram;
@ -12,24 +14,31 @@ pub trait Selector {
fn review(&self, data: String) -> Self::Response;
}
pub trait SelectorExt<E, S: Stream<Item = Result<String, E>>>: Selector {
pub trait SelectorExt<E: Debug, S: Stream<Item = Result<String, E>>>: Selector
where
Self::Error: Debug,
{
type Stream: Stream<Item = Result<String, FilterError<E, Self::Error>>>;
fn filter(self, stream: S) -> Self::Stream;
}
pub enum FilterError<T, U> {
#[derive(Debug, Error)]
pub enum FilterError<T: Debug, U: Debug> {
#[error("model sampling failed: {0:?}")]
Model(T),
#[error("filtering failed: {0:?}")]
Filter(U),
}
impl<
E: 'static,
E: Debug + 'static,
T: Selector + Sync + Send + Clone + 'static,
S: Send + Stream<Item = Result<String, E>> + 'static,
> SelectorExt<E, S> for T
where
T::Response: Send,
T::Error: Debug,
{
type Stream = BoxStream<'static, Result<String, FilterError<E, Self::Error>>>;