Basic Sentry integration.

This commit is contained in:
Syfaro 2020-01-08 16:17:21 -06:00
parent 58b8da0b9c
commit d8067e3e54
6 changed files with 544 additions and 72 deletions

270
Cargo.lock generated
View File

@ -1,5 +1,10 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "adler32"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "aho-corasick"
version = "0.7.6"
@ -171,6 +176,32 @@ dependencies = [
"bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cookie"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "cookie_store"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"publicsuffix 1.5.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "core-foundation"
version = "0.6.4"
@ -185,6 +216,14 @@ name = "core-foundation-sys"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "crc32fast"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "crossbeam-deque"
version = "0.7.2"
@ -273,6 +312,17 @@ dependencies = [
"syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "debugid"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "digest"
version = "0.8.1"
@ -348,6 +398,14 @@ dependencies = [
"termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "error-chain"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "failure"
version = "0.1.6"
@ -382,6 +440,17 @@ dependencies = [
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "flate2"
version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fluent"
version = "0.9.1"
@ -443,6 +512,7 @@ version = "0.1.1"
dependencies = [
"async-trait 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"egg-mode 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"fautil 0.1.0",
"fluent 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
"fluent-langneg 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -458,6 +528,7 @@ dependencies = [
"regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"scraper 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sentry 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
"telegram 0.1.0",
@ -689,6 +760,15 @@ dependencies = [
"digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "hostname"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "html5ever"
version = "0.24.1"
@ -747,6 +827,11 @@ name = "httparse"
version = "1.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "httpdate"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "humantime"
version = "1.3.0"
@ -850,6 +935,16 @@ dependencies = [
"unicode-normalization 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "im"
version = "12.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"sized-chunks 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "indexmap"
version = "1.3.0"
@ -1006,6 +1101,14 @@ dependencies = [
"unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "miniz_oxide"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "mio"
version = "0.6.21"
@ -1313,6 +1416,18 @@ name = "procedural-masquerade"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "publicsuffix"
version = "1.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
"idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quick-error"
version = "1.2.3"
@ -1515,6 +1630,39 @@ dependencies = [
"syn 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "reqwest"
version = "0.9.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cookie_store 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"encoding_rs 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)",
"flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-executor 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-threadpool 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-timer 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
"winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "reqwest"
version = "0.10.0"
@ -1647,6 +1795,44 @@ name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "sentry"
version = "0.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"backtrace 0.3.40 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"httpdate 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"im 12.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"sentry-types 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uname 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "sentry-types"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
"debugid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde"
version = "1.0.104"
@ -1685,6 +1871,17 @@ dependencies = [
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_urlencoded"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_urlencoded"
version = "0.6.1"
@ -1732,6 +1929,14 @@ name = "siphasher"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "sized-chunks"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "slab"
version = "0.4.2"
@ -1829,6 +2034,7 @@ dependencies = [
name = "telegram"
version = "0.1.0"
dependencies = [
"failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"reqwest 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2131,11 +2337,27 @@ name = "try-lock"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "try_from"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "typenum"
version = "1.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "uname"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "unic-langid"
version = "0.7.1"
@ -2211,11 +2433,29 @@ dependencies = [
"percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "url_serde"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "utf-8"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "uuid"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "vcpkg"
version = "0.2.8"
@ -2406,6 +2646,14 @@ dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winutil"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ws2_32-sys"
version = "0.2.1"
@ -2424,6 +2672,7 @@ dependencies = [
]
[metadata]
"checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2"
"checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d"
"checksum anyhow 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)" = "7825f6833612eb2414095684fcf6c635becf3ce97fe48cf6421321e93bfbd53c"
"checksum async-trait 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "c8df72488e87761e772f14ae0c2480396810e51b2c2ade912f97f0f7e5b95e3c"
@ -2447,8 +2696,11 @@ dependencies = [
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
"checksum chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "888604f00b3db336d2af898ec3c1d5d0ddf5e6d462220f2ededc33a87ac4bbd5"
"checksum cookie_store 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46750b3f362965f197996c4448e4a0935e791bf7d6631bfce9ee0af3d24c919c"
"checksum core-foundation 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "25b9e03f145fd4f2bf705e07b900cd41fc636598fe5dc452fd0db1441c3f496d"
"checksum core-foundation-sys 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
"checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1"
"checksum crossbeam-deque 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c3aa945d63861bfe624b55d153a39684da1e8c0bc8fba932f7ee3a3c16cea3ca"
"checksum crossbeam-epoch 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5064ebdbf05ce3cb95e45c8b086f72263f4166b29b97f6baff7ef7fe047b55ac"
"checksum crossbeam-queue 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b"
@ -2457,6 +2709,7 @@ dependencies = [
"checksum crypto-mac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4434400df11d95d556bac068ddfedd482915eb18fe8bea89bc80b6e4b1c179e5"
"checksum cssparser 0.25.9 (registry+https://github.com/rust-lang/crates.io-index)" = "fbe18ca4efb9ba3716c6da66cc3d7e673bf59fa576353011f48c4cfddbdd740e"
"checksum cssparser-macros 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "5bb1c84e87c717666564ec056105052331431803d606bd45529b28547b611eef"
"checksum debugid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "088c9627adec1e494ff9dea77377f1e69893023d631254a0ec68b16ee20be3e9"
"checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
"checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e"
"checksum dtoa-short 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "59020b8513b76630c49d918c33db9f4c91638e7d3404a28084083b87e33f76f2"
@ -2465,9 +2718,11 @@ dependencies = [
"checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"
"checksum encoding_rs 0.8.22 (registry+https://github.com/rust-lang/crates.io-index)" = "cd8d03faa7fe0c1431609dfad7bbe827af30f82e1e2ae6f7ee4fca6bd764bc28"
"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"
"checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9"
"checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9"
"checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08"
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
"checksum flate2 1.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd6d6f4752952feb71363cffc9ebac9411b75b87c6ab6058c40c8900cf43c0f"
"checksum fluent 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39c566a7c669a3694e5caa5a7fb69ede545c4809e3b06432be178095b501886a"
"checksum fluent-bundle 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cb733f6cedee059a77da074a14d1d855f3c7a04de18164b181ba2aa82221e281"
"checksum fluent-langneg 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "55e840a3a9938e6dd9a57a6a3be02bef1d51b1d75b883cdfe84810c7e7ca1293"
@ -2500,12 +2755,14 @@ dependencies = [
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
"checksum hermit-abi 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "eff2656d88f158ce120947499e971d743c05dbcbed62e5bd2f38f1698bbc3772"
"checksum hmac 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dcb5e64cda4c23119ab41ba960d1e170a774c8e4b9d9e6a9bc18aabf5e59695"
"checksum hostname 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "21ceb46a83a85e824ef93669c8b390009623863b5c195d1ba747292c0c72f94e"
"checksum html5ever 0.24.1 (registry+https://github.com/rust-lang/crates.io-index)" = "025483b0a1e4577bb28578318c886ee5f817dda6eb62473269349044406644cb"
"checksum http 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0"
"checksum http 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b708cc7f06493459026f53b9a61a7a121a5d1ec6238dee58ea4941132b30156b"
"checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d"
"checksum http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b"
"checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9"
"checksum httpdate 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47"
"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
"checksum hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)" = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6"
"checksum hyper 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8bf49cfb32edee45d890537d9057d1b02ed55f53b7b6a30bae83a38c9231749e"
@ -2513,6 +2770,7 @@ dependencies = [
"checksum hyper-tls 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ab58a31960b2f78c5c24cf255216789863754438a1e48849a956846f899e762e"
"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
"checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9"
"checksum im 12.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "de38d1511a0ce7677538acb1e31b5df605147c458e061b2cdb89858afb1cd182"
"checksum indexmap 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712d7b3ea5827fcb9d4fda14bf4da5f136f0db2ae9c8f4bd4e2d1c6fde4e6db2"
"checksum influxdb 0.0.5 (git+https://github.com/Empty2k12/influxdb-rust.git?rev=1b0cae12d8b1b0e2bd29129e6757a9df8a8faf50)" = "<none>"
"checksum intl_pluralrules 5.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "752ecba25a0554836d7921e383ba5c78ffea6e4825cc70dac75e2ab8e43af1be"
@ -2534,6 +2792,7 @@ dependencies = [
"checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9"
"checksum mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "dd1d63acd1b78403cc0c325605908475dd9b9a3acbf65ed8bcab97e27014afcf"
"checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599"
"checksum miniz_oxide 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f74f726ae935c3f514300cc6773a0c9492abc5e972d42ba0c0ebb88757625"
"checksum mio 0.6.21 (registry+https://github.com/rust-lang/crates.io-index)" = "302dec22bcf6bae6dfb69c647187f4b4d0fb6f535521f7bc022430ce8e12008f"
"checksum mio-uds 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)" = "966257a94e196b11bb43aca423754d87429960a768de9414f3691d6957abf125"
"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919"
@ -2570,6 +2829,7 @@ dependencies = [
"checksum proc-macro-nested 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "369a6ed065f249a159e06c45752c780bda2fb53c995718f9e484d08daa9eb42e"
"checksum proc-macro2 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "0319972dcae462681daf4da1adeeaa066e3ebd29c69be96c6abb1259d2ee2bcc"
"checksum procedural-masquerade 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "9a1574a51c3fd37b26d2c0032b649d08a7d51d4cca9c41bbc5bf7118fa4509d0"
"checksum publicsuffix 1.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "3bbaa49075179162b49acac1c6aa45fb4dafb5f13cf6794276d77bc7fd95757b"
"checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca"
@ -2594,6 +2854,7 @@ dependencies = [
"checksum rental 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8545debe98b2b139fb04cad8618b530e9b07c152d99a5de83c860b877d67847f"
"checksum rental-impl 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "475e68978dc5b743f2f40d8e0a8fdc83f1c5e78cbf4b8fa5e74e73beebc340de"
"checksum reqwest 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "03c6cbd2bc1c1cb7052dbe30f4a70cf65811967c800f2dfbb2e6036dc9ee2553"
"checksum reqwest 0.9.24 (registry+https://github.com/rust-lang/crates.io-index)" = "f88643aea3c1343c804950d7bf983bd2067f5ab59db6d613a08e05572f2714ab"
"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8"
@ -2605,15 +2866,19 @@ dependencies = [
"checksum selectors 0.21.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b86b100bede4f651059740afc3b6cb83458d7401cb7c1ad96d8a11e91742c86"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum sentry 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe4ea18f306c959be49f1bea8f3911a454e5d09d2dc43307215729e636bfbf4b"
"checksum sentry-types 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b23e3d9c8c6e4a1523f24df6753c4088bfe16c44a73c8881c1d23c70f28ae280"
"checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449"
"checksum serde_cbor 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45cd6d95391b16cd57e88b68be41d504183b7faae22030c0cc3b3f73dd57b2fd"
"checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64"
"checksum serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)" = "48c575e0cc52bdd09b47f330f646cf59afc586e9c4e3ccd6fc1f625b8ea1dad7"
"checksum serde_urlencoded 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "642dd69105886af2efd227f75a520ec9b44a820d65bc133a9131f7d229fd165a"
"checksum serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97"
"checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35"
"checksum servo_arc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d98238b800e0d1576d8b6e3de32827c2d74bee68bb97748dcf5071fb53965432"
"checksum sha-1 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
"checksum sized-chunks 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d3e7f23bad2d6694e0f46f5e470ec27eb07b8f3e8b309a4b0dc17501928b9f2"
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6"
"checksum smallvec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44e59e0c9fa00817912ae6e4e6e3c4fe04455e75699d06eedc7d85917ed8e8f4"
@ -2653,7 +2918,9 @@ dependencies = [
"checksum tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930"
"checksum tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860"
"checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382"
"checksum try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b"
"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9"
"checksum uname 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b72f89f0ca32e4db1c04e2a72f5345d59796d4866a1ee0609084569f73683dc8"
"checksum unic-langid 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7935b530ca240640bf8dd67d04301a3ed02bfc8635105fea9e9a26477143ca22"
"checksum unic-langid-impl 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "86ab4a5be993d5b9d082476a7dd7149c083cf63a72469e700c09e69784511957"
"checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
@ -2664,7 +2931,9 @@ dependencies = [
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
"checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a"
"checksum url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75b414f6c464c879d7f9babf951f23bc3743fb7313c081b2e6ca719067ea9d61"
"checksum url_serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "74e7d099f1ee52f823d4bdd60c93c3602043c728f5db3b97bdb548467f7bddea"
"checksum utf-8 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7"
"checksum uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a"
"checksum vcpkg 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "3fc439f2794e98976c88a2a2dafce96b930fe8010b0a256b3c2199a773933168"
"checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd"
"checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce"
@ -2688,5 +2957,6 @@ dependencies = [
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
"checksum wincolor 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96f5016b18804d24db43cebf3c77269e7569b8954a8464501c216cc5e070eaa9"
"checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9"
"checksum winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e"
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
"checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d"

View File

@ -18,6 +18,8 @@ hyper = "0.13.1"
log = "0.4.8"
pretty_env_logger = "0.3.1"
sentry = "0.17.0"
failure = "0.1.6"
influxdb = { git = "https://github.com/Empty2k12/influxdb-rust.git", rev = "1b0cae12d8b1b0e2bd29129e6757a9df8a8faf50" }
serde = { version = "1.0", features = ["derive"] }

View File

@ -1,5 +1,6 @@
#![feature(try_trait)]
use sentry::integrations::failure::capture_fail;
use sites::{PostInfo, Site};
use std::collections::HashMap;
use std::sync::{atomic::AtomicBool, Arc};
@ -8,6 +9,9 @@ use tokio::sync::Mutex;
use tokio01::runtime::current_thread::block_on_all;
use unic_langid::LanguageIdentifier;
#[macro_use]
extern crate failure;
mod sites;
fn generate_id() -> String {
@ -155,18 +159,27 @@ async fn main() {
.parse()
.unwrap_or(false);
let _guard = if let Ok(dsn) = std::env::var("SENTRY_DSN") {
sentry::integrations::panic::register_panic_handler();
Some(sentry::init(dsn))
} else {
None
};
if use_webhooks {
let webhook_endpoint = std::env::var("WEBHOOK_ENDPOINT").expect("Missing WEBHOOK_ENDPOINT");
let set_webhook = SetWebhook {
url: webhook_endpoint,
};
if let Err(e) = bot.make_request(&set_webhook).await {
capture_fail(&e);
log::error!("Unable to set webhook: {:?}", e);
}
receive_webhook(handler).await;
} else {
let delete_webhook = DeleteWebhook {};
if let Err(e) = bot.make_request(&delete_webhook).await {
capture_fail(&e);
log::error!("Unable to clear webhook: {:?}", e);
}
poll_updates(bot, handler).await;
@ -212,7 +225,12 @@ async fn handle_request(
let handler = handler.lock().await;
if let Err(e) = handler.influx.query(&point).await {
log::error!("Unable to send http request info to InfluxDB: {:?}", e);
let uuid = capture_fail(&e);
log::error!(
"[{}] Unable to send http request info to InfluxDB: {:?}",
uuid,
e
);
}
});
@ -262,6 +280,7 @@ async fn poll_updates(bot: Arc<Telegram>, handler: Arc<Mutex<MessageHandler>>) {
let updates = match bot.make_request(&update_req).await {
Ok(updates) => updates,
Err(e) => {
capture_fail(&e);
log::error!("Unable to get updates: {:?}", e);
std::thread::sleep(std::time::Duration::from_secs(5));
continue;
@ -314,6 +333,33 @@ fn get_message(
}
}
fn with_user_scope<C>(
from: Option<&User>,
tags: Option<std::collections::HashMap<&'static str, String>>,
callback: C,
) where
C: FnOnce(),
{
sentry::with_scope(
|scope| {
if let Some(user) = from {
scope.set_user(Some(sentry::User {
id: Some(user.id.to_string()),
username: user.username.clone(),
..Default::default()
}));
};
if let Some(tags) = tags {
for tag in tags {
scope.set_tag(tag.0, tag.1);
}
}
},
callback,
);
}
impl MessageHandler {
fn get_fluent_bundle(
&mut self,
@ -395,6 +441,18 @@ impl MessageHandler {
let images = match site.get_images(inline.from.id, link_str).await {
Ok(images) => images,
Err(e) => {
with_user_scope(
Some(&inline.from),
Some(
[("site", site.name().to_string())]
.iter()
.cloned()
.collect(),
),
|| {
capture_fail(&e);
},
);
log::warn!("Unable to get image: {:?}", e);
continue 'link;
}
@ -451,12 +509,18 @@ impl MessageHandler {
}
if let Err(e) = self.bot.make_request(&answer_inline).await {
with_user_scope(Some(&inline.from), None, || {
capture_fail(&e);
});
log::error!("Unable to respond to inline: {:?}", e);
}
point = point.add_field("duration", now.elapsed().as_millis() as i64);
if let Err(e) = self.influx.query(&point).await {
log::error!("Unable to log inline to InfluxDB: {:?}", e);
with_user_scope(Some(&inline.from), None, || {
let uuid = capture_fail(&e);
log::error!("[{}] Unable to log inline to InfluxDB: {:?}", uuid, e);
});
};
}
@ -495,6 +559,8 @@ impl MessageHandler {
log::debug!("Got command: {}", command_text);
log::trace!("Command {} had arguments: {}", command_text, args);
let from = message.from.clone();
match command_text {
"/help" | "/start" => {
let from = message.from.clone().unwrap();
@ -513,15 +579,27 @@ impl MessageHandler {
}]],
});
let message = SendMessage {
let send_message = SendMessage {
chat_id: message.chat_id(),
text: get_message(&bundle, "welcome", None).unwrap(),
reply_markup: Some(reply_markup),
..Default::default()
};
if let Err(e) = self.bot.make_request(&message).await {
log::warn!("Unable to send help message: {:?}", e);
if let Err(e) = self.bot.make_request(&send_message).await {
with_user_scope(
message.from.as_ref(),
Some(
[("command", command_text.to_string())]
.iter()
.cloned()
.collect(),
),
|| {
let uuid = capture_fail(&e);
log::error!("[{}] Unable to send help message: {:?}", uuid, e);
},
);
}
}
"/twitter" => self.authenticate_twitter(message).await,
@ -535,6 +613,9 @@ impl MessageHandler {
.add_field("duration", now.elapsed().as_millis() as i64);
if let Err(e) = self.influx.query(&point).await {
with_user_scope(from.as_ref(), None, || {
capture_fail(&e);
});
log::error!("Unable to send command to InfluxDB: {:?}", e);
}
}
@ -543,6 +624,7 @@ impl MessageHandler {
&self,
max: usize,
chat_id: ChatID,
user: Option<User>,
action: ChatAction,
completed: Arc<AtomicBool>,
) {
@ -569,6 +651,9 @@ impl MessageHandler {
})
.for_each(|_| async {
if let Err(e) = bot.make_request(&chat_action).await {
with_user_scope(user.as_ref(), None, || {
capture_fail(&e);
});
log::warn!("Unable to send chat action: {:?}", e);
}
})
@ -578,7 +663,13 @@ impl MessageHandler {
async fn handle_source(&mut self, message: Message) {
let completed = Arc::new(AtomicBool::new(false));
self.send_action(12, message.chat_id(), ChatAction::Typing, completed.clone());
self.send_action(
12,
message.chat_id(),
message.from.clone(),
ChatAction::Typing,
completed.clone(),
);
let message = if let Some(reply_to_message) = message.reply_to_message {
*reply_to_message
@ -607,6 +698,9 @@ impl MessageHandler {
Ok(file) => file,
Err(e) => {
self.send_generic_reply(&message, "error-generic").await;
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
log::error!("Unable to get file: {:?}", e);
return;
}
@ -616,6 +710,9 @@ impl MessageHandler {
Ok(bytes) => bytes,
Err(e) => {
self.send_generic_reply(&message, "error-generic").await;
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
log::error!("Unable to download file: {:?}", e);
return;
}
@ -625,6 +722,9 @@ impl MessageHandler {
Ok(matches) => matches,
Err(e) => {
self.send_generic_reply(&message, "error-generic").await;
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
log::error!("Unable to find matches: {:?}", e);
return;
}
@ -639,7 +739,7 @@ impl MessageHandler {
}
};
let bundle = self.get_fluent_bundle(message.from.unwrap().language_code.as_deref());
let bundle = self.get_fluent_bundle(message.from.clone().unwrap().language_code.as_deref());
let name = if result.distance < 5 {
"reverse-good-result"
@ -654,7 +754,7 @@ impl MessageHandler {
fluent::FluentValue::from(format!("https://www.furaffinity.net/view/{}/", result.id)),
);
let message = SendMessage {
let send_message = SendMessage {
chat_id: message.chat.id.into(),
text: get_message(&bundle, name, Some(args)).unwrap(),
disable_web_page_preview: Some(result.distance > 5),
@ -662,8 +762,11 @@ impl MessageHandler {
..Default::default()
};
if let Err(e) = self.bot.make_request(&message).await {
if let Err(e) = self.bot.make_request(&send_message).await {
log::error!("Unable to make request: {:?}", e);
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
}
completed.store(true, std::sync::atomic::Ordering::SeqCst);
@ -676,15 +779,18 @@ impl MessageHandler {
};
let bundle = self.get_fluent_bundle(language_code.as_deref());
let message = SendMessage {
let send_message = SendMessage {
chat_id: message.chat_id(),
reply_to_message_id: Some(message.message_id),
text: get_message(&bundle, name, None).unwrap(),
..Default::default()
};
if let Err(e) = self.bot.make_request(&message).await {
if let Err(e) = self.bot.make_request(&send_message).await {
log::error!("Unable to make request: {:?}", e);
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
}
}
@ -695,6 +801,7 @@ impl MessageHandler {
self.send_action(
6,
message.chat_id(),
message.from.clone(),
ChatAction::UploadPhoto,
completed.clone(),
);
@ -732,6 +839,9 @@ impl MessageHandler {
Err(e) => {
missing.push(link_str.to_string());
log::warn!("Unable to get image: {:?}", e);
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
continue 'link;
}
};
@ -778,6 +888,9 @@ impl MessageHandler {
if let Err(e) = self.bot.make_request(&photo).await {
log::error!("Unable to make request: {:?}", e);
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
}
} else {
for chunk in results.chunks(10) {
@ -805,6 +918,9 @@ impl MessageHandler {
if let Err(e) = self.bot.make_request(&media_group).await {
log::error!("Unable to make request: {:?}", e);
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
}
}
@ -817,7 +933,7 @@ impl MessageHandler {
let mut args = fluent::FluentArgs::new();
args.insert("links", fluent::FluentValue::from(links.join("\n")));
let message = SendMessage {
let send_message = SendMessage {
chat_id: message.chat_id(),
reply_to_message_id: Some(message.message_id),
text: get_message(&bundle, "mirror-missing", Some(args)).unwrap(),
@ -825,8 +941,11 @@ impl MessageHandler {
..Default::default()
};
if let Err(e) = self.bot.make_request(&message).await {
if let Err(e) = self.bot.make_request(&send_message).await {
log::error!("Unable to make request: {:?}", e);
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
}
}
}
@ -891,6 +1010,13 @@ impl MessageHandler {
) {
log::warn!("Unable to save user credentials: {:?}", e);
with_user_scope(Some(&from), None, || {
sentry::integrations::failure::capture_error(&format_err!(
"Unable to save to Twitter database: {}",
e
));
});
let bundle = self.get_fluent_bundle(from.language_code.as_deref());
let message = SendMessage {
@ -902,6 +1028,9 @@ impl MessageHandler {
if let Err(e) = self.bot.make_request(&message).await {
log::warn!("Unable to send message: {:?}", e);
with_user_scope(Some(&from), None, || {
capture_fail(&e);
});
}
return;
}
@ -920,6 +1049,9 @@ impl MessageHandler {
if let Err(e) = self.bot.make_request(&message).await {
log::warn!("Unable to send message: {:?}", e);
with_user_scope(Some(&from), None, || {
capture_fail(&e);
});
}
let point = influxdb::Query::write_query(influxdb::Timestamp::Now, "twitter")
@ -928,6 +1060,9 @@ impl MessageHandler {
if let Err(e) = self.influx.query(&point).await {
log::error!("Unable to send command to InfluxDB: {:?}", e);
with_user_scope(Some(&from), None, || {
capture_fail(&e);
});
}
}
@ -948,6 +1083,7 @@ impl MessageHandler {
if let Err(e) = self.influx.query(&point).await {
log::error!("Unable to send chosen inline result to InfluxDB: {:?}", e);
capture_fail(&e);
}
}
}
@ -960,7 +1096,7 @@ impl MessageHandler {
return;
}
let user = message.from.unwrap();
let user = message.from.clone().unwrap();
let con_token =
egg_mode::KeyPair::new(self.consumer_key.clone(), self.consumer_secret.clone());
@ -970,6 +1106,10 @@ impl MessageHandler {
Err(e) => {
log::warn!("Unable to get request token: {:?}", e);
with_user_scope(Some(&user), None, || {
capture_fail(&e);
});
let bundle = self.get_fluent_bundle(user.language_code.as_deref());
let message = SendMessage {
@ -981,6 +1121,9 @@ impl MessageHandler {
if let Err(e) = self.bot.make_request(&message).await {
log::warn!("Unable to send message: {:?}", e);
with_user_scope(Some(&user), None, || {
capture_fail(&e);
});
}
return;
}
@ -992,6 +1135,13 @@ impl MessageHandler {
) {
log::warn!("Unable to save authenticate: {:?}", e);
with_user_scope(Some(&user), None, || {
sentry::integrations::failure::capture_error(&format_err!(
"Unable to save to Twitter database: {}",
e
));
});
let bundle = self.get_fluent_bundle(user.language_code.as_deref());
let message = SendMessage {
@ -1003,6 +1153,9 @@ impl MessageHandler {
if let Err(e) = self.bot.make_request(&message).await {
log::warn!("Unable to send message: {:?}", e);
with_user_scope(Some(&user), None, || {
capture_fail(&e);
});
}
return;
}
@ -1014,16 +1167,19 @@ impl MessageHandler {
let bundle = self.get_fluent_bundle(user.language_code.as_deref());
let message = SendMessage {
chat_id: user.id.into(),
let send_message = SendMessage {
chat_id: message.chat_id(),
text: get_message(&bundle, "twitter-oob", Some(args)).unwrap(),
reply_markup: Some(ReplyMarkup::ForceReply(ForceReply::selective())),
reply_to_message_id: Some(message.message_id),
..Default::default()
};
if let Err(e) = self.bot.make_request(&message).await {
if let Err(e) = self.bot.make_request(&send_message).await {
log::warn!("Unable to send message: {:?}", e);
with_user_scope(Some(&user), None, || {
capture_fail(&e);
});
}
let point = influxdb::Query::write_query(influxdb::Timestamp::Now, "twitter")
@ -1032,6 +1188,9 @@ impl MessageHandler {
if let Err(e) = self.influx.query(&point).await {
log::error!("Unable to send command to InfluxDB: {:?}", e);
with_user_scope(Some(&user), None, || {
capture_fail(&e);
});
}
}
@ -1142,9 +1301,15 @@ impl MessageHandler {
let now = std::time::Instant::now();
let completed = Arc::new(AtomicBool::new(false));
self.send_action(12, message.chat_id(), ChatAction::Typing, completed.clone());
self.send_action(
12,
message.chat_id(),
message.from.clone(),
ChatAction::Typing,
completed.clone(),
);
let photos = message.photo.unwrap();
let photos = message.photo.clone().unwrap();
let mut most_pixels = 0;
let mut file_id = String::default();
@ -1159,21 +1324,34 @@ impl MessageHandler {
let get_file = GetFile { file_id };
let file = match self.bot.make_request(&get_file).await {
Ok(file) => file,
_ => return,
Err(e) => {
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
self.send_generic_reply(&message, "error-generic").await;
return;
}
};
let photo = match self.bot.download_file(file.file_path.unwrap()).await {
Ok(photo) => photo,
_ => return,
Err(e) => {
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
self.send_generic_reply(&message, "error-generic").await;
return;
}
};
let matches = match self.fapi.image_search(photo, false).await {
Ok(matches) if !matches.is_empty() => matches,
_ => {
let bundle = self.get_fluent_bundle(message.from.unwrap().language_code.as_deref());
let bundle =
self.get_fluent_bundle(message.from.clone().unwrap().language_code.as_deref());
let message = SendMessage {
chat_id: message.chat.id.into(),
let send_message = SendMessage {
chat_id: message.chat_id(),
text: get_message(&bundle, "reverse-no-results", None).unwrap(),
reply_to_message_id: Some(message.message_id),
..Default::default()
@ -1181,8 +1359,12 @@ impl MessageHandler {
completed.store(true, std::sync::atomic::Ordering::SeqCst);
if let Err(e) = self.bot.make_request(&message).await {
if let Err(e) = self.bot.make_request(&send_message).await {
log::error!("Unable to respond to photo: {:?}", e);
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
self.send_generic_reply(&message, "error-generic").await;
}
let point = influxdb::Query::write_query(influxdb::Timestamp::Now, "source")
@ -1191,6 +1373,10 @@ impl MessageHandler {
if let Err(e) = self.influx.query(&point).await {
log::error!("Unable to send command to InfluxDB: {:?}", e);
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
self.send_generic_reply(&message, "error-generic").await;
}
return;
@ -1200,7 +1386,7 @@ impl MessageHandler {
let first = matches.get(0).unwrap();
log::debug!("Match has distance of {}", first.distance);
let bundle = self.get_fluent_bundle(message.from.unwrap().language_code.as_deref());
let bundle = self.get_fluent_bundle(message.from.clone().unwrap().language_code.as_deref());
let name = if first.distance < 5 {
"reverse-good-result"
@ -1215,8 +1401,8 @@ impl MessageHandler {
fluent::FluentValue::from(format!("https://www.furaffinity.net/view/{}/", first.id)),
);
let message = SendMessage {
chat_id: message.chat.id.into(),
let send_message = SendMessage {
chat_id: message.chat_id(),
text: get_message(&bundle, name, Some(args)).unwrap(),
disable_web_page_preview: Some(first.distance > 5),
reply_to_message_id: Some(message.message_id),
@ -1225,8 +1411,12 @@ impl MessageHandler {
completed.store(true, std::sync::atomic::Ordering::SeqCst);
if let Err(e) = self.bot.make_request(&message).await {
if let Err(e) = self.bot.make_request(&send_message).await {
log::error!("Unable to respond to photo: {:?}", e);
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
self.send_generic_reply(&message, "error-generic").await;
}
let point = influxdb::Query::write_query(influxdb::Timestamp::Now, "source")
@ -1236,6 +1426,10 @@ impl MessageHandler {
if let Err(e) = self.influx.query(&point).await {
log::error!("Unable to send command to InfluxDB: {:?}", e);
with_user_scope(message.from.as_ref(), None, || {
capture_fail(&e);
});
self.send_generic_reply(&message, "error-generic").await;
}
}
}

View File

@ -30,38 +30,39 @@ fn get_file_ext(name: &str) -> Option<&str> {
name.split('.').last()
}
#[derive(Debug)]
pub struct SiteError {
error: Option<Box<dyn std::error::Error>>,
#[derive(Fail, Debug)]
pub enum SiteError {
#[fail(display = "http error")]
Request(reqwest::Error),
#[fail(display = "json parsing error")]
JSON(serde_json::Error),
#[fail(display = "missing required value")]
Missing(std::option::NoneError),
#[fail(display = "twitter error")]
Twitter(egg_mode::error::Error),
}
impl From<reqwest::Error> for SiteError {
fn from(error: reqwest::Error) -> SiteError {
SiteError {
error: Some(Box::new(error)),
}
fn from(e: reqwest::Error) -> Self {
SiteError::Request(e)
}
}
impl From<serde_json::Error> for SiteError {
fn from(error: serde_json::Error) -> SiteError {
SiteError {
error: Some(Box::new(error)),
}
}
}
impl From<std::option::NoneError> for SiteError {
fn from(_: std::option::NoneError) -> SiteError {
SiteError { error: None }
fn from(e: serde_json::Error) -> Self {
SiteError::JSON(e)
}
}
impl From<egg_mode::error::Error> for SiteError {
fn from(error: egg_mode::error::Error) -> SiteError {
SiteError {
error: Some(Box::new(error)),
}
fn from(e: egg_mode::error::Error) -> Self {
SiteError::Twitter(e)
}
}
impl From<std::option::NoneError> for SiteError {
fn from(e: std::option::NoneError) -> Self {
SiteError::Missing(e)
}
}
@ -558,28 +559,13 @@ impl Site for Mastodon {
let base = captures["host"].to_owned();
let status_id = captures["id"].to_owned();
let resp = reqwest::Client::new()
let json: MastodonStatus = reqwest::Client::new()
.get(&format!("{}/api/v1/statuses/{}", base, status_id))
.header(header::USER_AGENT, USER_AGENT)
.send();
let resp = match resp.await {
Ok(resp) => resp,
Err(e) => {
return Err(SiteError {
error: Some(Box::new(e)),
})
}
};
let json: MastodonStatus = match resp.json().await {
Ok(json) => json,
Err(e) => {
return Err(SiteError {
error: Some(Box::new(e)),
})
}
};
.send()
.await?
.json()
.await?;
if json.media_attachments.is_empty() {
return Ok(None);

View File

@ -9,3 +9,4 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
reqwest = { version = "0.10.0", features = ["json"] }
log = "0.4.8"
failure = "0.1.6"

View File

@ -1,9 +1,15 @@
use serde::{Deserialize, Serialize};
#[derive(Debug)]
#[macro_use]
extern crate failure;
#[derive(Fail, Debug)]
pub enum Error {
#[fail(display = "telegram error: {}", _0)]
Telegram(TelegramError),
#[fail(display = "json parsing error: {}", _0)]
JSON(serde_json::Error),
#[fail(display = "http error: {}", _0)]
Request(reqwest::Error),
}
@ -35,6 +41,19 @@ pub struct TelegramError {
pub parameters: Option<ResponseParameters>,
}
impl std::fmt::Display for TelegramError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(
f,
"Telegram Error {}: {}",
self.error_code.unwrap_or(-1),
self.description
.clone()
.unwrap_or_else(|| "no description".to_string())
)
}
}
#[derive(Debug, Deserialize)]
pub struct Response<T> {
/// If the request was successful. If true, the result is available.
@ -413,7 +432,7 @@ impl std::fmt::Debug for FileType {
FileType::Attach(attach) => write!(f, "FileType Attach: {}", attach),
FileType::Bytes(name, bytes) => {
write!(f, "FileType Bytes: {} with len {}", name, bytes.len())
},
}
FileType::Missing => write!(f, "FileType Missing!!"),
}
}