Added console publisher, added console selector (very poorly!) and non-implemented telegram selector

This commit is contained in:
Emile 2021-06-28 19:57:06 +01:00
parent a64d52cc12
commit 21fd9fe968
6 changed files with 618 additions and 35 deletions

500
Cargo.lock generated
View File

@ -15,6 +15,21 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "aho-corasick"
version = "0.7.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
dependencies = [
"memchr",
]
[[package]]
name = "ascii"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97be891acc47ca214468e09425d02cef3af2c94d0d82081cd02061f996802f14"
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "0.1.7" version = "0.1.7"
@ -67,6 +82,12 @@ version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7"
[[package]]
name = "base64"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.2.1" version = "1.2.1"
@ -94,6 +115,22 @@ dependencies = [
"byte-tools", "byte-tools",
] ]
[[package]]
name = "buf_redux"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b953a6887648bb07a535631f2bc00fbdb2a2216f135552cb3f534ed136b9c07f"
dependencies = [
"memchr",
"safemem",
]
[[package]]
name = "bumpalo"
version = "3.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631"
[[package]] [[package]]
name = "byte-tools" name = "byte-tools"
version = "0.3.1" version = "0.3.1"
@ -189,6 +226,18 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "chunked_transfer"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "498d20a7aaf62625b9bf26e637cf7736417cde1d0c99f1d04d1170229a85cf87"
[[package]]
name = "chunked_transfer"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fff857943da45f546682664a79488be82e69e43c1a7a2307679ab9afb3a66d2e"
[[package]] [[package]]
name = "cloudabi" name = "cloudabi"
version = "0.0.3" version = "0.0.3"
@ -217,7 +266,7 @@ dependencies = [
"cookie", "cookie",
"failure", "failure",
"idna 0.1.5", "idna 0.1.5",
"log", "log 0.4.14",
"publicsuffix", "publicsuffix",
"serde", "serde",
"serde_json", "serde_json",
@ -342,7 +391,7 @@ dependencies = [
"doc-comment", "doc-comment",
"hyper-old-types", "hyper-old-types",
"isolang", "isolang",
"log", "log 0.4.14",
"reqwest", "reqwest",
"serde", "serde",
"serde_derive", "serde_derive",
@ -373,7 +422,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc" checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"version_check", "version_check 0.9.3",
] ]
[[package]] [[package]]
@ -447,6 +496,19 @@ dependencies = [
"percent-encoding 2.1.0", "percent-encoding 2.1.0",
] ]
[[package]]
name = "frankenstein"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92ecce8fc4d7ca2bf5c34f81342d527ee0c47de27c13c8b57df7f5431589e156"
dependencies = [
"mime_guess 2.0.3",
"multipart",
"serde",
"serde_json",
"ureq",
]
[[package]] [[package]]
name = "fuchsia-cprng" name = "fuchsia-cprng"
version = "0.1.1" version = "0.1.1"
@ -528,6 +590,12 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "groupable"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32619942b8be646939eaf3db0602b39f5229b74575b67efc897811ded1db4e57"
[[package]] [[package]]
name = "h2" name = "h2"
version = "0.1.26" version = "0.1.26"
@ -540,7 +608,7 @@ dependencies = [
"futures", "futures",
"http 0.1.21", "http 0.1.21",
"indexmap", "indexmap",
"log", "log 0.4.14",
"slab", "slab",
"string", "string",
"tokio-io", "tokio-io",
@ -601,6 +669,25 @@ version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68"
[[package]]
name = "hyper"
version = "0.10.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273"
dependencies = [
"base64 0.9.3",
"httparse",
"language-tags",
"log 0.3.9",
"mime 0.2.6",
"num_cpus",
"time",
"traitobject",
"typeable",
"unicase 1.4.2",
"url 1.7.2",
]
[[package]] [[package]]
name = "hyper" name = "hyper"
version = "0.12.36" version = "0.12.36"
@ -616,7 +703,7 @@ dependencies = [
"httparse", "httparse",
"iovec", "iovec",
"itoa", "itoa",
"log", "log 0.4.14",
"net2", "net2",
"rustc_version", "rustc_version",
"time", "time",
@ -641,11 +728,11 @@ dependencies = [
"bytes 0.4.12", "bytes 0.4.12",
"httparse", "httparse",
"language-tags", "language-tags",
"log", "log 0.4.14",
"mime", "mime 0.3.16",
"percent-encoding 1.0.1", "percent-encoding 1.0.1",
"time", "time",
"unicase", "unicase 2.6.0",
] ]
[[package]] [[package]]
@ -656,7 +743,7 @@ checksum = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f"
dependencies = [ dependencies = [
"bytes 0.4.12", "bytes 0.4.12",
"futures", "futures",
"hyper", "hyper 0.12.36",
"native-tls", "native-tls",
"tokio-io", "tokio-io",
] ]
@ -711,6 +798,22 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "iron"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6d308ca2d884650a8bf9ed2ff4cb13fbb2207b71f64cda11dc9b892067295e8"
dependencies = [
"hyper 0.10.16",
"log 0.3.9",
"mime_guess 1.8.8",
"modifier",
"num_cpus",
"plugin",
"typemap",
"url 1.7.2",
]
[[package]] [[package]]
name = "isolang" name = "isolang"
version = "1.0.0" version = "1.0.0"
@ -732,12 +835,23 @@ checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
name = "izzilis" name = "izzilis"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"chrono",
"elefren", "elefren",
"frankenstein",
"rand 0.8.4", "rand 0.8.4",
"serde", "serde",
"serde_json", "serde_json",
] ]
[[package]]
name = "js-sys"
version = "0.3.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062"
dependencies = [
"wasm-bindgen",
]
[[package]] [[package]]
name = "kernel32-sys" name = "kernel32-sys"
version = "0.2.2" version = "0.2.2"
@ -775,6 +889,15 @@ dependencies = [
"scopeguard", "scopeguard",
] ]
[[package]]
name = "log"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
dependencies = [
"log 0.4.14",
]
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.14" version = "0.4.14"
@ -811,20 +934,41 @@ dependencies = [
"autocfg 1.0.1", "autocfg 1.0.1",
] ]
[[package]]
name = "mime"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0"
dependencies = [
"log 0.3.9",
]
[[package]] [[package]]
name = "mime" name = "mime"
version = "0.3.16" version = "0.3.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
[[package]]
name = "mime_guess"
version = "1.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "216929a5ee4dd316b1702eedf5e74548c123d370f47841ceaac38ca154690ca3"
dependencies = [
"mime 0.2.6",
"phf",
"phf_codegen",
"unicase 1.4.2",
]
[[package]] [[package]]
name = "mime_guess" name = "mime_guess"
version = "2.0.3" version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" checksum = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212"
dependencies = [ dependencies = [
"mime", "mime 0.3.16",
"unicase", "unicase 2.6.0",
] ]
[[package]] [[package]]
@ -849,7 +993,7 @@ dependencies = [
"iovec", "iovec",
"kernel32-sys", "kernel32-sys",
"libc", "libc",
"log", "log 0.4.14",
"miow", "miow",
"net2", "net2",
"slab", "slab",
@ -868,6 +1012,44 @@ dependencies = [
"ws2_32-sys", "ws2_32-sys",
] ]
[[package]]
name = "modifier"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41f5c9112cb662acd3b204077e0de5bc66305fa8df65c8019d5adb10e9ab6e58"
[[package]]
name = "multipart"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00dec633863867f29cb39df64a397cdf4a6354708ddd7759f70c7fb51c5f9182"
dependencies = [
"buf_redux",
"httparse",
"hyper 0.10.16",
"iron",
"log 0.4.14",
"mime 0.3.16",
"mime_guess 2.0.3",
"nickel",
"quick-error",
"rand 0.8.4",
"safemem",
"tempfile",
"tiny_http",
"twoway",
]
[[package]]
name = "mustache"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51956ef1c5d20a1384524d91e616fb44dfc7d8f249bf696d49c97dd3289ecab5"
dependencies = [
"log 0.3.9",
"serde",
]
[[package]] [[package]]
name = "native-tls" name = "native-tls"
version = "0.2.7" version = "0.2.7"
@ -876,7 +1058,7 @@ checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4"
dependencies = [ dependencies = [
"lazy_static", "lazy_static",
"libc", "libc",
"log", "log 0.4.14",
"openssl", "openssl",
"openssl-probe", "openssl-probe",
"openssl-sys", "openssl-sys",
@ -897,6 +1079,27 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "nickel"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5061a832728db2dacb61cefe0ce303b58f85764ec680e71d9138229640a46d9"
dependencies = [
"groupable",
"hyper 0.10.16",
"lazy_static",
"log 0.3.9",
"modifier",
"mustache",
"plugin",
"regex",
"serde",
"serde_json",
"time",
"typemap",
"url 1.7.2",
]
[[package]] [[package]]
name = "num-integer" name = "num-integer"
version = "0.1.44" version = "0.1.44"
@ -1063,6 +1266,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0"
dependencies = [ dependencies = [
"siphasher", "siphasher",
"unicase 1.4.2",
] ]
[[package]] [[package]]
@ -1071,6 +1275,15 @@ version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c"
[[package]]
name = "plugin"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a6a0dc3910bc8db877ffed8e457763b317cf880df4ae19109b9f77d277cf6e0"
dependencies = [
"typemap",
]
[[package]] [[package]]
name = "ppv-lite86" name = "ppv-lite86"
version = "0.2.10" version = "0.2.10"
@ -1104,9 +1317,15 @@ checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"memchr", "memchr",
"unicase", "unicase 2.6.0",
] ]
[[package]]
name = "quick-error"
version = "1.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.9" version = "1.0.9"
@ -1327,6 +1546,23 @@ dependencies = [
"bitflags", "bitflags",
] ]
[[package]]
name = "regex"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]] [[package]]
name = "remove_dir_all" name = "remove_dir_all"
version = "0.5.3" version = "0.5.3"
@ -1350,11 +1586,11 @@ dependencies = [
"flate2", "flate2",
"futures", "futures",
"http 0.1.21", "http 0.1.21",
"hyper", "hyper 0.12.36",
"hyper-tls", "hyper-tls",
"log", "log 0.4.14",
"mime", "mime 0.3.16",
"mime_guess", "mime_guess 2.0.3",
"native-tls", "native-tls",
"serde", "serde",
"serde_json", "serde_json",
@ -1370,6 +1606,21 @@ dependencies = [
"winreg", "winreg",
] ]
[[package]]
name = "ring"
version = "0.16.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc"
dependencies = [
"cc",
"libc",
"once_cell",
"spin",
"untrusted",
"web-sys",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.20" version = "0.1.20"
@ -1385,6 +1636,19 @@ dependencies = [
"semver 0.9.0", "semver 0.9.0",
] ]
[[package]]
name = "rustls"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7"
dependencies = [
"base64 0.13.0",
"log 0.4.14",
"ring",
"sct",
"webpki",
]
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.5" version = "1.0.5"
@ -1422,6 +1686,16 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "sct"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce"
dependencies = [
"ring",
"untrusted",
]
[[package]] [[package]]
name = "security-framework" name = "security-framework"
version = "2.3.1" version = "2.3.1"
@ -1594,6 +1868,12 @@ dependencies = [
"maybe-uninit", "maybe-uninit",
] ]
[[package]]
name = "spin"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
[[package]] [[package]]
name = "string" name = "string"
version = "0.2.1" version = "0.2.1"
@ -1656,6 +1936,19 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "tiny_http"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e22cb179b63e5fc2d0b5be237dc107da072e2407809ac70a8ce85b93fe8f562"
dependencies = [
"ascii",
"chrono",
"chunked_transfer 0.3.1",
"log 0.4.14",
"url 1.7.2",
]
[[package]] [[package]]
name = "tinyvec" name = "tinyvec"
version = "1.2.0" version = "1.2.0"
@ -1729,7 +2022,7 @@ checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674"
dependencies = [ dependencies = [
"bytes 0.4.12", "bytes 0.4.12",
"futures", "futures",
"log", "log 0.4.14",
] ]
[[package]] [[package]]
@ -1741,7 +2034,7 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
"futures", "futures",
"lazy_static", "lazy_static",
"log", "log 0.4.14",
"mio", "mio",
"num_cpus", "num_cpus",
"parking_lot", "parking_lot",
@ -1786,7 +2079,7 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
"futures", "futures",
"lazy_static", "lazy_static",
"log", "log 0.4.14",
"num_cpus", "num_cpus",
"slab", "slab",
"tokio-executor", "tokio-executor",
@ -1813,6 +2106,12 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "traitobject"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079"
[[package]] [[package]]
name = "try-lock" name = "try-lock"
version = "0.2.3" version = "0.2.3"
@ -1840,7 +2139,7 @@ dependencies = [
"http 0.2.4", "http 0.2.4",
"httparse", "httparse",
"input_buffer", "input_buffer",
"log", "log 0.4.14",
"native-tls", "native-tls",
"rand 0.7.3", "rand 0.7.3",
"sha-1", "sha-1",
@ -1848,6 +2147,30 @@ dependencies = [
"utf-8", "utf-8",
] ]
[[package]]
name = "twoway"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59b11b2b5241ba34be09c3cc85a36e56e48f9888862e19cedf23336d35316ed1"
dependencies = [
"memchr",
]
[[package]]
name = "typeable"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887"
[[package]]
name = "typemap"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6"
dependencies = [
"unsafe-any",
]
[[package]] [[package]]
name = "typenum" name = "typenum"
version = "1.13.0" version = "1.13.0"
@ -1860,13 +2183,22 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
[[package]]
name = "unicase"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33"
dependencies = [
"version_check 0.1.5",
]
[[package]] [[package]]
name = "unicase" name = "unicase"
version = "2.6.0" version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
dependencies = [ dependencies = [
"version_check", "version_check 0.9.3",
] ]
[[package]] [[package]]
@ -1893,6 +2225,37 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "unsafe-any"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f"
dependencies = [
"traitobject",
]
[[package]]
name = "untrusted"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]]
name = "ureq"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2475a6781e9bc546e7b64f4013d2f4032c8c6a40fcffd7c6f4ee734a890972ab"
dependencies = [
"base64 0.13.0",
"chunked_transfer 1.4.0",
"log 0.4.14",
"once_cell",
"rustls",
"url 2.2.2",
"webpki",
"webpki-roots",
]
[[package]] [[package]]
name = "url" name = "url"
version = "1.7.2" version = "1.7.2"
@ -1937,6 +2300,12 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version_check"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.3" version = "0.9.3"
@ -1961,7 +2330,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230"
dependencies = [ dependencies = [
"futures", "futures",
"log", "log 0.4.14",
"try-lock", "try-lock",
] ]
@ -1977,6 +2346,89 @@ version = "0.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "wasm-bindgen"
version = "0.2.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd"
dependencies = [
"cfg-if 1.0.0",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900"
dependencies = [
"bumpalo",
"lazy_static",
"log 0.4.14",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f"
[[package]]
name = "web-sys"
version = "0.3.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "webpki"
version = "0.21.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea"
dependencies = [
"ring",
"untrusted",
]
[[package]]
name = "webpki-roots"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aabe153544e473b775453675851ecc86863d2a81d786d741f6b76778f2a48940"
dependencies = [
"webpki",
]
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.2.8" version = "0.2.8"

View File

@ -7,7 +7,9 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
chrono = "0.4.19"
elefren = { version = "0.22.0", features = ["toml"] } elefren = { version = "0.22.0", features = ["toml"] }
frankenstein = "0.4.0"
rand = "0.8.4" rand = "0.8.4"
serde = "1.0.126" serde = "1.0.126"
serde_json = "1.0.64" serde_json = "1.0.64"

View File

@ -1,40 +1,57 @@
use rand::Rng; use rand::Rng;
use std::{error::Error, io}; use std::{error::Error, io};
use crate::{generator, model, publish}; use crate::{
generator, model, publish,
selection::{self, Selector},
};
pub struct IzzilisBot<T: model::SampleModel, U: publish::Publisher> { pub struct IzzilisBot<T: model::SampleModel, U: publish::Publisher, V: selection::Selector> {
generator: generator::Generator<T>, generator: generator::Generator<T>,
publisher: U, // One day I'll figure out how to make this a vector with differing Publisher types publisher: U, // One day I'll figure out how to make this a vector with differing Publisher types
selector: V,
loaded_samples: Vec<String>, loaded_samples: Vec<String>,
} }
impl<T, U> IzzilisBot<T, U> impl<T, U, V> IzzilisBot<T, U, V>
where where
T: model::SampleModel, T: model::SampleModel,
U: publish::Publisher, U: publish::Publisher,
V: selection::Selector,
{ {
pub fn new(generator: generator::Generator<T>, publisher: U) -> IzzilisBot<T, U> { pub fn new(
generator: generator::Generator<T>,
publisher: U,
selector: V,
) -> IzzilisBot<T, U, V> {
Self { Self {
generator, generator,
publisher, publisher,
loaded_samples: Vec::new(), loaded_samples: Vec::new(),
selector: selector,
} }
} }
fn generate_samples(&mut self) -> Option<io::Error> { pub fn generate_samples(&mut self) -> Option<io::Error> {
let lines_result = self.generator.generate_sample_lines(); let lines_result = self.generator.generate_sample_lines();
let lines = match lines_result { let lines = match lines_result {
Ok(res) => res, Ok(res) => res,
Err(err) => return Some(err), Err(err) => return Some(err),
}; };
self.loaded_samples = lines; // wtf happens to the original self.loaded_samples??????? for line in lines {
match self.selector.send_for_review(line) {
Some(err) => panic!("Failed selector read, yes shit error I know, help me"), // Yes, I know this is *abysmal* but idk how to deal with errors
// yet, so for the time being I have to suffer through this bad shit. Please help me, looking at this is suffering. I want it to end.
None => (),
}
}
self.loaded_samples = self.selector.collect_selected_samples(); // wtf happens to the original self.loaded_samples???????
None None
} }
pub fn publish(&mut self) -> Option<Box<dyn Error>> { pub fn publish(&mut self) -> Option<Box<dyn Error>> {
if self.loaded_samples.len() < 5 { if self.loaded_samples.len() == 0 {
// Refresh samples. Either none have been generated so far, // Refresh samples. Either none have been generated so far,
// or generated ones are stale. // or generated ones are stale.
// //

View File

@ -1,12 +1,16 @@
use std::{error::Error, process, thread, time::Duration}; use std::{error::Error, process, thread, time::Duration};
use chrono::Local;
use rand::Rng; use rand::Rng;
use crate::publish::ConsolePublisher;
mod bot; mod bot;
mod config; mod config;
mod generator; mod generator;
mod model; mod model;
mod publish; mod publish;
mod selection;
const CONFIG_PATH: &str = "bot_config.json"; const CONFIG_PATH: &str = "bot_config.json";
@ -41,18 +45,22 @@ fn main() -> Result<(), Box<dyn Error>> {
"1".to_string(), "1".to_string(),
], ],
); );
let publisher = publish::FediversePublisher::new(cfg.fediverse_base_url())?; // let publisher = publish::FediversePublisher::new(cfg.fediverse_base_url())?;
let publisher = ConsolePublisher::new();
let gen = generator::Generator::new(gpt_model); let gen = generator::Generator::new(gpt_model);
let mut bot = bot::IzzilisBot::new(gen, publisher); let console_selector = selection::ConsoleSelector::new();
let mut bot = bot::IzzilisBot::new(gen, publisher, console_selector);
bot.generate_samples();
let cfg_interval = cfg.interval_seconds(); let cfg_interval = cfg.interval_seconds();
loop { loop {
let wait_seconds = rand::thread_rng().gen_range(cfg_interval.min()..cfg_interval.max()); let wait_seconds = rand::thread_rng().gen_range(cfg_interval.min()..cfg_interval.max());
let wait_time = Duration::from_secs(wait_seconds); let wait_time = Duration::from_secs(wait_seconds);
println!("Next post is in {} seconds", wait_seconds); let now = Local::now();
println!("[{}] Next post is in [{}] seconds", now, wait_seconds);
thread::sleep(wait_time); thread::sleep(wait_time);
match bot.publish() { match bot.publish() {
Some(err) => println!("Got error from publish: {}; continuing", err), Some(err) => println!("Got error from publish: [{}]; continuing", err),
None => println!("publish() call successful"), None => println!("publish() call successful"),
} }
} }

View File

@ -17,6 +17,21 @@ pub struct FediversePublisher {
client: Mastodon, client: Mastodon,
} }
pub struct ConsolePublisher;
impl Publisher for ConsolePublisher {
fn publish(&self, content: String) -> Option<Box<dyn Error>> {
println!("Publishing content to stdout: {}", content);
None
}
}
impl ConsolePublisher {
pub fn new() -> ConsolePublisher {
ConsolePublisher {}
}
}
impl FediversePublisher { impl FediversePublisher {
pub fn new(fedi_url: String) -> Result<FediversePublisher, Box<dyn Error>> { pub fn new(fedi_url: String) -> Result<FediversePublisher, Box<dyn Error>> {
let fedi = if let Ok(data) = toml::from_file(FEDIVERSE_TOML_PATH.to_string()) { let fedi = if let Ok(data) = toml::from_file(FEDIVERSE_TOML_PATH.to_string()) {

89
src/selection.rs Normal file
View File

@ -0,0 +1,89 @@
use frankenstein::{
Api, GetUpdatesParams, KeyboardButton, ReplyKeyboardMarkup, ReplyMarkup, TelegramApi,
};
use std::{error::Error, io, thread::JoinHandle};
pub trait Selector {
fn send_for_review(&mut self, message: String) -> Option<Box<dyn Error>>;
fn collect_selected_samples(&mut self) -> Vec<String>;
}
pub struct TelegramSelector {
client: frankenstein::Api,
dest_chat_id: String,
listener_handle: Option<JoinHandle<()>>,
}
pub struct ConsoleSelector {
selected_samples: Vec<String>,
}
impl Selector for ConsoleSelector {
fn send_for_review(&mut self, message: String) -> Option<Box<dyn Error>> {
println!("generated sample [y+enter to accept]: {}", &message);
let mut choice = String::new();
io::stdin().read_line(&mut choice).expect("cum");
if choice.to_lowercase().contains("y") {
println!("accepted");
self.selected_samples.push(message);
}
return None;
}
fn collect_selected_samples(&mut self) -> Vec<String> {
let cloned_samples = self.selected_samples.to_owned();
self.selected_samples = Vec::new();
cloned_samples
}
}
impl ConsoleSelector {
pub fn new() -> ConsoleSelector {
Self {
selected_samples: Vec::new(),
}
}
}
const KEEP_BUTTON: &str = "Keep";
const TOSS_BUTTON: &str = "Toss";
impl Selector for TelegramSelector {
fn send_for_review(&mut self, message: String) -> Option<Box<dyn Error>> {
todo!();
if !self.listener_handle.is_none() {
todo!();
}
let mut message_def = frankenstein::SendMessageParams::new(
frankenstein::ChatId::String(self.dest_chat_id.clone()),
message,
);
message_def.reply_markup = Some(ReplyMarkup::ReplyKeyboardMarkup(
ReplyKeyboardMarkup::new(vec![
KeyboardButton::new(KEEP_BUTTON.to_string()),
KeyboardButton::new(TOSS_BUTTON.to_string()),
]),
));
let result = match self.client.send_message(&message_def) {
Ok(_) => None,
Err(_) => todo!(),
};
result
}
fn collect_selected_samples(&mut self) -> Vec<String> {
todo!()
}
}
impl TelegramSelector {
pub fn new(token: String, dest_chat_id: String) -> TelegramSelector {
let api = Api::new(&token);
Self {
client: api,
dest_chat_id: dest_chat_id,
listener_handle: None,
}
}
}