commit 3ddea5bd6791b265af197cc49cbd7294866ccf69 Author: Brandon Thomas Date: Mon Sep 28 03:16:35 2020 -0400 Twitter Bot: tokio and futures are hard. Not yet working diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..783a495d9d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +input/ +output/ +target/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..d6f6584916 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*~ +.idea/ +input/ +output/ +run_cargo.sh +run_docker.sh +secret.yaml +secrets.yaml +target/ diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000000..4d8f7ce0f0 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1488 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "aho-corasick" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043164d8ba5c4c3035fec9bbee8647c0261d788f3474306f93bb65901cae0e86" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "anyhow" +version = "1.0.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b602bfe940d21c130f3895acd65221e8a61270debe89d628b9cb4e3ccb8569b" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" + +[[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.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" + +[[package]] +name = "cc" +version = "1.0.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "chrono" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d021fddb7bd3e734370acfa4a83f34095571d8570c039f1420d77540f68d5772" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "serde", + "time", + "winapi 0.3.9", +] + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "core-foundation" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" + +[[package]] +name = "cpuid-bool" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" + +[[package]] +name = "crossbeam" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69323bff1fb41c635347b8ead484a5ca6c3f11914d784170b158d8449ab07f8e" +dependencies = [ + "cfg-if", + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-epoch", + "crossbeam-queue", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-channel" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" +dependencies = [ + "crossbeam-utils", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-deque" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "lazy_static", + "maybe-uninit", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-queue" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg", + "cfg-if", + "lazy_static", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "derive_more" +version = "0.99.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dcfabdab475c16a93d669dddfc393027803e347d09663f524447f642fbb84ba" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "easyenv" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e342c743b9e85da31c9638894e9abef5f92cf3b16b482f6f97c90995f7e99868" +dependencies = [ + "env_logger", + "log", +] + +[[package]] +name = "egg-mode" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f877bc908325f50163ff1670a4733eabf87942511ccfd907fbef4e239c3f8aa" +dependencies = [ + "base64", + "chrono", + "derive_more", + "futures", + "hmac", + "hyper", + "hyper-tls", + "lazy_static", + "mime", + "native-tls", + "percent-encoding", + "rand", + "regex", + "serde", + "serde_json", + "sha-1", + "thiserror", + "tokio", + "url", +] + +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + +[[package]] +name = "futures" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e05b85ec287aac0dc34db7d4a569323df697f9c55b99b15d6b4ef8cde49f613" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" + +[[package]] +name = "futures-executor" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10d6bb888be1153d3abeb9006b11b02cf5e9b209fda28693c31ae1e4e012e314" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" + +[[package]] +name = "futures-macro" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0b5a30a4328ab5473878237c447333c093297bded83a4983d10f4deea240d39" +dependencies = [ + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" + +[[package]] +name = "futures-task" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" +dependencies = [ + "once_cell", +] + +[[package]] +name = "futures-util" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project", + "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", +] + +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "h2" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "993f9e0baeed60001cf565546b0d3dbe6a6ad23f2bd31644a133c641eccf6d53" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d63df3d41950fb462ed38308eea019113ad1508da725bbedcd0fa5a85ef5f7" + +[[package]] +name = "heck" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c30f6d0bc6b00693347368a67d41b58f2fb851215ff1da49e90fe2c5c667151" +dependencies = [ + "libc", +] + +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac", + "digest", +] + +[[package]] +name = "http" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "httparse" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" + +[[package]] +name = "httpdate" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" + +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + +[[package]] +name = "hyper" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f3afcfae8af5ad0576a31e768415edb627824129e8e5a29b8bfccb2f234e835" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-tls", +] + +[[package]] +name = "idna" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "itoa" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6" + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235" + +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "memchr" +version = "2.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" + +[[package]] +name = "memoffset" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +dependencies = [ + "autocfg", +] + +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + +[[package]] +name = "mio" +version = "0.6.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +dependencies = [ + "cfg-if", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "native-tls" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "net2" +version = "0.2.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" +dependencies = [ + "cfg-if", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "num-integer" +version = "0.1.43" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl" +version = "0.10.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "lazy_static", + "libc", + "openssl-sys", +] + +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" + +[[package]] +name = "openssl-sys" +version = "0.9.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pin-project" +version = "0.4.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f48fad7cfbff853437be7cf54d7b993af21f53be7f0988cbfe4a51535aa77205" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24c6d293bdd3ca5a1697997854c6cf7855e43fb6a0ba1c47af57a5bcafd158ae" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71f349a4f0e70676ffb2dbafe16d0c992382d02f0a952e3ddf584fc289dac6b3" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" + +[[package]] +name = "ppv-lite86" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598" + +[[package]] +name = "proc-macro-nested" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" + +[[package]] +name = "proc-macro2" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51ef7cd2518ead700af67bf9d1a658d90b6037d77110fd9c0445429d0ba1c6c9" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[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", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "regex" +version = "1.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", +] + +[[package]] +name = "regex-syntax" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +dependencies = [ + "lazy_static", + "winapi 0.3.9", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "security-framework" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.116" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f630a6370fd8e457873b4bd2ffdae75408bc291ba72be773772a4c2a065d9ae8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "164eacbdb13512ec2745fb09d51fd5b22b0d65ed294a1dcf7285a360c80a675c" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha-1" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "170a36ea86c864a3f16dd2687712dd6646f7019f301e57537c7f4dc9f5916770" +dependencies = [ + "block-buffer", + "cfg-if", + "cpuid-bool", + "digest", + "opaque-debug", +] + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" + +[[package]] +name = "socket2" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.9", +] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "structopt" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a33f6461027d7f08a13715659b2948e1602c31a3756aeae9378bfe7518c72e82" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c92e775028122a4b3dd55d58f14fc5120289c69bee99df1d117ae30f84b225c9" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "subprocess" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69b9ad6c3e1b525a55872a4d2f2d404b3c959b7bbcbfd83c364580f68ed157bd" +dependencies = [ + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "subtle" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd" + +[[package]] +name = "syn" +version = "1.0.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c51d92969d209b54a98397e1b91c8ae82d8c87a7bb87df0b29aa2ad81454228" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "tempfile" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" +dependencies = [ + "cfg-if", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi 0.3.9", +] + +[[package]] +name = "termcolor" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "time" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi 0.3.9", +] + +[[package]] +name = "tinyvec" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117" + +[[package]] +name = "tokio" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "iovec", + "lazy_static", + "memchr", + "mio", + "num_cpus", + "pin-project-lite", + "slab", + "tokio-macros", +] + +[[package]] +name = "tokio-macros" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower-service" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" + +[[package]] +name = "tracing" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d79ca061b032d6ce30c660fded31189ca0b9922bf483cd70759f13a2d86786c" +dependencies = [ + "cfg-if", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bcf46c1f1f06aeea2d6b81f3c863d0930a596c86ad1920d4e5bad6dd1d7119a" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" + +[[package]] +name = "twitter-vocodes-bot" +version = "0.0.1" +dependencies = [ + "anyhow", + "chrono", + "crossbeam", + "easyenv", + "egg-mode", + "env_logger", + "futures", + "log", + "serde", + "serde_derive", + "serde_json", + "structopt", + "subprocess", + "tokio", + "yansi", +] + +[[package]] +name = "typenum" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" + +[[package]] +name = "unicode-bidi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" +dependencies = [ + "matches", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb19cf769fa8c6a80a162df694621ebeb4dafb606470b2b2fce0be40a98a977" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "url" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" +dependencies = [ + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "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.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +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" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "yansi" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc79f4a1e39857fc00c3f662cbf2651c771f00e9c15fe2abc341806bd46bd71" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000000..802b952893 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "twitter-vocodes-bot" +edition = "2018" +version = "0.0.1" +authors = [ + "Brandon Thomas ", + "Brandon Thomas ", +] +publish = false + +[[bin]] +name = "twitter-vocodes-bot" +path = "src/main.rs" + +[dependencies] +anyhow = "1.0.31" +chrono = { version = "0.4", features = ["serde"] } +crossbeam = "0.7.3" +easyenv = "0.0.2" +egg-mode = "0.15" +env_logger = "0.7.1" +futures = "0.3" +log = "0.4.11" +serde = "1.0.104" +serde_derive = "1.0.104" +serde_json = "1.0.55" +subprocess = "0.2.6" +tokio = { version = "0.2.8", features = ["time", "rt-core", "macros", "blocking", "rt-threaded"] } + +# From egg-mode +yansi = "0.5.0" +structopt = "0.3.13" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..750227aee6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,43 @@ +FROM ubuntu:focal as build + +ARG DEBIAN_FRONTEND=noninteractive + +WORKDIR /tmp + +RUN apt-get update \ + && apt-get install -y \ + build-essential \ + curl \ + gdb \ + libssl-dev \ + libssl1.1 \ + pkg-config \ + unzip \ + vim \ + wget + +RUN apt-cache search libssl | grep libssl + +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ + | sh -s -- --default-toolchain stable -y + +COPY Cargo.toml . + +# Prefetch dependencies so code iteration is fast +RUN $HOME/.cargo/bin/cargo fetch + +# Pre-build the dependencies. +# Code changes won't make us rebuild them. +RUN set -x \ + && mkdir -p src \ + && echo 'fn main() { println!("rebuild me!"); }' > src/main.rs \ + && $HOME/.cargo/bin/cargo build + +COPY src/ src/ + +# If the timestamps are older on actual src/ files than +# cached "fake build" above, nothing gets built. +RUN touch src/main.rs + +RUN $HOME/.cargo/bin/cargo build + diff --git a/README.md b/README.md new file mode 100644 index 0000000000..e9449dda09 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +twitter-vocodes-bot +=================== +A bot for responding to tweets. diff --git a/src/common.rs b/src/common.rs new file mode 100644 index 0000000000..6772d9062f --- /dev/null +++ b/src/common.rs @@ -0,0 +1,230 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +//since this is going to get included in examples that might not use everything, clear out warnings +//that are unnecessary +#![allow(dead_code)] + +use egg_mode; +use std; +use std::io::{Read, Write}; + +pub use yansi::Paint; +use crate::Secrets; + +//This is not an example that can be built with cargo! This is some helper code for the other +//examples so they can load access keys from the same place. + +#[derive(Clone)] +pub struct Config { + pub token: egg_mode::Token, + pub user_id: u64, + pub screen_name: String, +} + +impl Config { + pub async fn load(secrets: Secrets) -> Self { + let a1 = Config::load_inner(secrets.clone()).await; + if let Some(conf) = a1 { + return conf; + } + + Config::load_inner(secrets.clone()).await.unwrap() + } + + /// This needs to be a separate function so we can retry after creating the + /// twitter_settings file. Idealy we would recurse, but that requires boxing + /// the output which doesn't seem worthwhile + async fn load_inner(secrets: Secrets) -> Option { + //IMPORTANT: make an app for yourself at apps.twitter.com and get your + //key/secret into these files; these examples won't work without them + //let consumer_key = include_str!("consumer_key").trim(); + //let consumer_secret = include_str!("consumer_secret").trim(); + + // TODO: DO NOT COMMIT + let consumer_key = &secrets.api_key; + let consumer_secret = &secrets.api_secret_key; + + + println!("Trying to get connection to Twitter - creating con_token"); + // "It works when I pass a Token with the Access variant instead of the Bearer variant." + let con_token = egg_mode::KeyPair::new(consumer_key.clone(), consumer_secret.clone()); + + println!("con_token created"); + + let mut config = String::new(); + let user_id: u64; + let username: String; + let token: egg_mode::Token; + + //look at all this unwrapping! who told you it was my birthday? + //if let Ok(mut f) = std::fs::File::open("twitter_settings") { + if true { + /*f.read_to_string(&mut config).unwrap(); + + let mut iter = config.split('\n'); + + username = iter.next().unwrap().to_string(); + user_id = u64::from_str_radix(&iter.next().unwrap(), 10).unwrap(); + let access_token = egg_mode::KeyPair::new( + iter.next().unwrap().to_string(), + iter.next().unwrap().to_string(), + ); + */ + + let accessToken = &secrets.access_token; + let accessTokenSecret = &secrets.access_token_secret; + + username = secrets.username.to_string(); + user_id = secrets.user_id; + + let access_token = egg_mode::KeyPair::new( + accessToken.to_string(), + accessTokenSecret.to_string(), + ); + + + token = egg_mode::Token::Access { + consumer: con_token, + access: access_token, + }; + + if let Err(err) = egg_mode::auth::verify_tokens(&token).await { + println!("We've hit an error using your old tokens: {:?}", err); + println!("We'll have to reauthenticate before continuing."); + std::fs::remove_file("twitter_settings").unwrap(); + } else { + println!("Welcome back, {}!\n", username); + } + } else { + let request_token = egg_mode::auth::request_token(&con_token, "oob").await.unwrap(); + + println!("Go to the following URL, sign in, and give me the PIN that comes back:"); + println!("{}", egg_mode::auth::authorize_url(&request_token)); + + let mut pin = String::new(); + std::io::stdin().read_line(&mut pin).unwrap(); + println!(""); + + let tok_result = egg_mode::auth::access_token(con_token, &request_token, pin) + .await + .unwrap(); + + token = tok_result.0; + user_id = tok_result.1; + username = tok_result.2; + + match token { + egg_mode::Token::Access { + access: ref access_token, + .. + } => { + config.push_str(&username); + config.push('\n'); + config.push_str(&format!("{}", user_id)); + config.push('\n'); + config.push_str(&access_token.key); + config.push('\n'); + config.push_str(&access_token.secret); + } + _ => unreachable!(), + } + + let mut f = std::fs::File::create("twitter_settings").unwrap(); + f.write_all(config.as_bytes()).unwrap(); + + println!("Welcome, {}, let's get this show on the road!", username); + } + + return Some(Config { + token: token, + user_id: user_id, + screen_name: username, + }); + + /*//TODO: Is there a better way to query whether a file exists? + if std::fs::metadata("twitter_settings").is_ok() { + Some(Config { + token: token, + user_id: user_id, + screen_name: username, + }) + } else { + None + }*/ + } +} + +pub fn print_tweet(tweet: &egg_mode::tweet::Tweet) { + if let Some(ref user) = tweet.user { + println!( + "{} (@{}) posted at {}", + Paint::blue(&user.name), + Paint::bold(Paint::blue(&user.screen_name)), + tweet.created_at.with_timezone(&chrono::Local) + ); + } + + if let Some(ref screen_name) = tweet.in_reply_to_screen_name { + println!("➜ in reply to @{}", Paint::blue(screen_name)); + } + + if let Some(ref status) = tweet.retweeted_status { + println!("{}", Paint::red("Retweet ➜")); + print_tweet(status); + return; + } else { + println!("{}", Paint::green(&tweet.text)); + } + + if let Some(source) = &tweet.source { + println!("➜ via {} ({})", source.name, source.url); + } + + if let Some(ref place) = tweet.place { + println!("➜ from: {}", place.full_name); + } + + if let Some(ref status) = tweet.quoted_status { + println!("{}", Paint::red("➜ Quoting the following status:")); + print_tweet(status); + } + + if !tweet.entities.hashtags.is_empty() { + println!("➜ Hashtags contained in the tweet:"); + for tag in &tweet.entities.hashtags { + println!(" {}", tag.text); + } + } + + if !tweet.entities.symbols.is_empty() { + println!("➜ Symbols contained in the tweet:"); + for tag in &tweet.entities.symbols { + println!(" {}", tag.text); + } + } + + if !tweet.entities.urls.is_empty() { + println!("➜ URLs contained in the tweet:"); + for url in &tweet.entities.urls { + if let Some(expanded_url) = &url.expanded_url { + println!(" {}", expanded_url); + } + } + } + + if !tweet.entities.user_mentions.is_empty() { + println!("➜ Users mentioned in the tweet:"); + for user in &tweet.entities.user_mentions { + println!(" {}", Paint::bold(Paint::blue(&user.screen_name))); + } + } + + if let Some(ref media) = tweet.extended_entities { + println!("➜ Media attached to the tweet:"); + for info in &media.media { + println!(" A {:?}", info.media_type); + } + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000000..7f0bdd2854 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,215 @@ +//! A Twitter bot for Vo.codes +//! Copyright 2020 Brandon Thomas + +mod common; +mod workers; + +use anyhow::bail; +use crate::workers::{spawn_workers, Workload}; +use crossbeam::Receiver; +use easyenv::{init_env_logger, get_env_num}; +use egg_mode::media::{media_types, upload_media, set_metadata, get_status, ProgressInfo, MediaHandle}; +use egg_mode::stream::StreamMessage; +use egg_mode::tweet::DraftTweet; +use futures::TryStreamExt; +use log::{warn, info, error}; +use std::{env, thread}; +use std::io::{stdout, Write}; +use std::path::PathBuf; +use std::time::Duration; +use tokio::time::delay_for; +use egg_mode::error::Error; +use tokio::runtime::Builder; + +pub type AnyhowResult = anyhow::Result; + +#[derive(Clone)] +pub struct Secrets { + pub api_key: String, + pub api_secret_key: String, + pub access_token: String, + pub access_token_secret: String, + pub username: String, + // Not sure where to get the user id, or what it's used for. + pub user_id: u64, +} + +impl Secrets { + pub fn load_from_env() -> AnyhowResult { + Ok(Secrets { + api_key: env::var("API_KEY")?, + api_secret_key: env::var("API_SECRET_KEY")?, + access_token: env::var("ACCESS_TOKEN")?, + access_token_secret: env::var("ACCESS_TOKEN_SECRET")?, + username: env::var("USERNAME")?, + user_id: get_env_num::("USER_ID", 0)?, + }) + } +} + +fn main() -> AnyhowResult<()> { + /*let mut runtime = Builder::new() + .build() + .unwrap() + .block_on(async { + main_2().await + });*/ + + let mut runtime = tokio::runtime::Builder::new() + .threaded_scheduler() + .enable_all() + .on_thread_start(|| { + println!("thread started"); + }) + .build() + .unwrap(); + + runtime.block_on(main_2()); + + + Ok(()) +} + +//#[tokio::main] +async fn main_2() -> AnyhowResult<()> { + + init_env_logger(None); + + let secrets = Secrets::load_from_env()?; + + info!("Loading configs and logging in..."); + + let config = common::Config::load(secrets.clone()).await; + + info!("Configs loaded. Spawning workers..."); + + let (sender, receiver) = crossbeam::bounded(5); + spawn_workers(config.clone(), receiver, 5).await; + + info!("Streaming tweets..."); + + thread::sleep(Duration::from_secs(10)); + + let stream = egg_mode::stream::filter() + .track(&["vocodesbot"]) + .language(&["en"]) + .start(&config.token) + .try_for_each(|m| { + if let StreamMessage::Tweet(tweet) = m { + common::print_tweet(&tweet); + println!("──────────────────────────────────────"); + + sender.send(Workload { info: tweet.text.clone() }); + + info!("Responding..."); + let fut = async { + let path = PathBuf::from("/home/bt/dev/voice/ffmpeg-server/output/out.mp4"); + + match respond_with_media(&config, "Hello, this is a response.", path, "some media").await { + Err(e) => warn!("An error: {:?}", e), + Ok(e) => info!("Response posted."), + } + }; + + } else { + println!("Not a message: {:?}", m); + } + + futures::future::ok(()) + }); + + + if let Err(e) = stream.await { + let e : egg_mode::error::Error = e; + error!("Stream error: {}", &e); + match e { + Error::BadUrl => {}, + Error::InvalidResponse(_, _) => {}, + Error::MissingValue(_) => {}, + Error::FutureAlreadyCompleted => {}, + Error::TwitterError(_, _) => {}, + Error::RateLimit(rate_limit) => { + error!("Rate limited. Will reopen at unix timestamp: {}", rate_limit); + }, + Error::MediaError(_) => {}, + Error::BadStatus(_) => {}, + Error::NetError(_) => {}, + Error::TlsError(_) => {}, + Error::IOError(_) => {}, + Error::DeserializeError(_) => {}, + Error::TimestampParseError(_) => {}, + Error::TimerShutdownError(_) => {}, + Error::HeaderParseError(_) => {}, + Error::HeaderConvertError(_) => {}, + } + error!("Disconnected") + } + + Ok(()) +} + +async fn respond_with_media( + config: &common::Config, + tweet_text: &str, + media_path: PathBuf, + media_alt_text: &str) -> Result<(), Box> +{ + let mut tweet = DraftTweet::new(tweet_text.to_string()); + + let handle = upload_media_to_twitter(config, media_path, media_alt_text).await?; + tweet.add_media(handle.id.clone()); + + tweet.send(&config.token).await?; + + Ok(()) +} + +async fn upload_media_to_twitter( + config: &common::Config, + media_path: PathBuf, + media_alt_text: &str) -> AnyhowResult +{ + println!("Uploading media from '{}'", media_path.display()); + + let typ = match media_path.extension().and_then(|os| os.to_str()).unwrap_or("") { + "jpg" | "jpeg" => media_types::image_jpg(), + "gif" => media_types::image_gif(), + "png" => media_types::image_png(), + "webp" => media_types::image_webp(), + "mp4" => media_types::video_mp4(), + _ => { + eprintln!("Format not recognized, must be one of [jpg, jpeg, gif, png, webp, mp4]"); + std::process::exit(1); + } + }; + + let bytes = std::fs::read(media_path)?; + let handle = upload_media(&bytes, &typ, &config.token).await?; + + set_metadata(&handle.id, media_alt_text, &config.token).await?; + + println!("Media uploaded"); + + // Wait 60 seconds for processing + println!("Waiting for media to finish processing..."); + + for ct in 0..=60u32 { + match get_status(handle.id.clone(), &config.token).await?.progress { + None | Some(ProgressInfo::Success) => { + println!("\nMedia sucessfully processed"); + break; + } + Some(ProgressInfo::Pending(_)) | Some(ProgressInfo::InProgress(_)) => { + print!("."); + stdout().flush()?; + delay_for(Duration::from_secs(1)).await; + } + Some(ProgressInfo::Failed(err)) => Err(err)?, + } + if ct == 60 { + bail!("Error: timeout"); + } + } + + Ok(handle) +} diff --git a/src/workers.rs b/src/workers.rs new file mode 100644 index 0000000000..fd5b403a48 --- /dev/null +++ b/src/workers.rs @@ -0,0 +1,144 @@ +use crate::{common, AnyhowResult}; +use crossbeam::Receiver; +use log::{info, error, warn}; +use std::thread; +use tokio::time::Duration; +use std::path::PathBuf; +use egg_mode::media::{MediaHandle, media_types, upload_media, set_metadata, get_status, ProgressInfo}; +use egg_mode::tweet::DraftTweet; +use anyhow::Error; +use tokio::runtime::Handle; + +pub struct Workload { + pub info: String, +} + + +pub async fn spawn_workers(config: common::Config, receiver: Receiver, num_workers: usize) { + //thread::sleep(Duration::from_secs(5)); + + for i in 0 .. num_workers { + let conf = config.clone(); + let recv = receiver.clone(); + + info!("Spawning worker {}", i); + + let handle = Handle::current(); + + //tokio::task::spawn(async move {}); + handle.spawn(async move { + info!("a"); + start_worker(conf, recv, i).await; + info!("b"); + }); + + + //thread::spawn(move || start_worker(conf, recv, i)); + } + + //joinables.iter().map(|j| j.join()); +} + +async fn start_worker(config: common::Config, receiver: Receiver, worker_id: usize) { + loop { + info!("Worker thread loop - listening: {}", worker_id); + + let workload = match receiver.recv() { + Err(e) => { + warn!("Error receiving from queue: {}", e); + thread::sleep(Duration::from_millis(500)); + continue; + }, + Ok(workload) => workload, + }; + + info!("Worker {} got tweet: {}", worker_id, &workload.info); + + let path = PathBuf::from("/home/bt/dev/voice/ffmpeg-server/output/out.mp4"); + + let r = respond_with_media(&config, "generic response", path, "media"); + + match r { + Ok(_) => info!("Responded to tweet successfully"), + Err(e) => error!("Error responding to tweet: {}", e), + } + } +} + +fn respond_with_media( + config: &common::Config, + tweet_text: &str, + media_path: PathBuf, + media_alt_text: &str) -> AnyhowResult<()> +{ + + // let rt = tokio::runtime::Runtime::new().unwrap(); + // let mut executor = rt.executor(); + + // executor.spawn(async { + // let mut tweet = DraftTweet::new(tweet_text.to_string()); + + // //let handle = upload_media_to_twitter(config, media_path, media_alt_text).await?; + // //tweet.add_media(handle.id.clone()); + + // tweet.send(&config.token).await + // }); + + // tokio::task::spawn_blocking({ + // fut + // })?; + //futures::executor::block_on(fut)?; + + Ok(()) +} + +/*fn upload_media_to_twitter( + config: &common::Config, + media_path: PathBuf, + media_alt_text: &str) -> AnyhowResult +{ + println!("Uploading media from '{}'", media_path.display()); + + let typ = match media_path.extension().and_then(|os| os.to_str()).unwrap_or("") { + "jpg" | "jpeg" => media_types::image_jpg(), + "gif" => media_types::image_gif(), + "png" => media_types::image_png(), + "webp" => media_types::image_webp(), + "mp4" => media_types::video_mp4(), + _ => { + eprintln!("Format not recognized, must be one of [jpg, jpeg, gif, png, webp, mp4]"); + std::process::exit(1); + } + }; + + let bytes = std::fs::read(media_path)?; + let handle = upload_media(&bytes, &typ, &config.token).await?; + + set_metadata(&handle.id, media_alt_text, &config.token).await?; + + println!("Media uploaded"); + + // Wait 60 seconds for processing + println!("Waiting for media to finish processing..."); + + for ct in 0..=60u32 { + match get_status(handle.id.clone(), &config.token).await?.progress { + None | Some(ProgressInfo::Success) => { + println!("\nMedia sucessfully processed"); + break; + } + Some(ProgressInfo::Pending(_)) | Some(ProgressInfo::InProgress(_)) => { + print!("."); + stdout().flush()?; + delay_for(Duration::from_secs(1)).await; + } + Some(ProgressInfo::Failed(err)) => Err(err)?, + } + if ct == 60 { + bail!("Error: timeout"); + } + } + + Ok(handle) +} +*/ \ No newline at end of file