Overview
Comment: | 0.2.18: now proxies for outgoing requests are supported, including Tor |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
45e34762e4757f1445221c78ddeb07fe |
User & Date: | arcade on 2023-05-28 14:25:41.282 |
Other Links: | manifest | tags |
Context
2023-07-30
| ||
11:19 | bump, fix proxy string handling check-in: 9d8a6738fd user: arcade tags: trunk | |
2023-05-28
| ||
14:25 | 0.2.18: now proxies for outgoing requests are supported, including Tor check-in: 45e34762e4 user: arcade tags: trunk | |
2023-05-27
| ||
04:55 | bump + some clippy lints check-in: aae1b6f580 user: arcade tags: trunk | |
Changes
Modified Cargo.lock
from [5130f3f46b]
to [5dfc230ed0].
︙ | ︙ | |||
96 97 98 99 100 101 102 | checksum = "5b0122885821398cc923ece939e24d1056a2384ee719432397fa9db87230ff11" dependencies = [ "brotli", "flate2", "futures-core", "memchr", "pin-project-lite", | | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | checksum = "5b0122885821398cc923ece939e24d1056a2384ee719432397fa9db87230ff11" dependencies = [ "brotli", "flate2", "futures-core", "memchr", "pin-project-lite", "tokio 1.28.2", ] [[package]] name = "async-executor" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fa3dc5f2a8564f07759c008b9109dc0d39de92a88d5588b8a5036d286383afb" |
︙ | ︙ | |||
126 127 128 129 130 131 132 | "async-channel", "async-executor", "async-io", "async-lock", "blocking", "futures-lite", "once_cell", | | | 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | "async-channel", "async-executor", "async-io", "async-lock", "blocking", "futures-lite", "once_cell", "tokio 1.28.2", ] [[package]] name = "async-io" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" |
︙ | ︙ | |||
217 218 219 220 221 222 223 | name = "async-trait" version = "0.1.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", | | | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | name = "async-trait" version = "0.1.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", "syn 2.0.18", ] [[package]] name = "atoi" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" |
︙ | ︙ | |||
600 601 602 603 604 605 606 | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", "typenum", ] | < < < < < < < < < < | 600 601 602 603 604 605 606 607 608 609 610 611 612 613 | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", "typenum", ] [[package]] name = "darling" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" dependencies = [ "darling_core 0.10.2", |
︙ | ︙ | |||
1021 1022 1023 1024 1025 1026 1027 | name = "futures-macro" version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", | | | 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 | name = "futures-macro" version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", "syn 2.0.18", ] [[package]] name = "futures-rustls" version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" |
︙ | ︙ | |||
1147 1148 1149 1150 1151 1152 1153 | "fnv", "futures-core", "futures-sink", "futures-util", "http 0.2.9", "indexmap", "slab", | | | 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 | "fnv", "futures-core", "futures-sink", "futures-util", "http 0.2.9", "indexmap", "slab", "tokio 1.28.2", "tokio-util", "tracing", ] [[package]] name = "hashbrown" version = "0.12.3" |
︙ | ︙ | |||
1329 1330 1331 1332 1333 1334 1335 | "http 0.2.9", "http-body 0.4.5", "httparse", "httpdate", "itoa 1.0.6", "pin-project-lite", "socket2", | | | 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 | "http 0.2.9", "http-body 0.4.5", "httparse", "httpdate", "itoa 1.0.6", "pin-project-lite", "socket2", "tokio 1.28.2", "tower-service", "tracing", "want 0.3.0", ] [[package]] name = "hyper-tls" |
︙ | ︙ | |||
1357 1358 1359 1360 1361 1362 1363 | version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes 1.4.0", "hyper 0.14.26", "native-tls", | | | 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 | version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" dependencies = [ "bytes 1.4.0", "hyper 0.14.26", "native-tls", "tokio 1.28.2", "tokio-native-tls", ] [[package]] name = "iana-time-zone" version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" |
︙ | ︙ | |||
1555 1556 1557 1558 1559 1560 1561 | dependencies = [ "autocfg 1.1.0", "scopeguard", ] [[package]] name = "log" | | | < | 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 | dependencies = [ "autocfg 1.1.0", "scopeguard", ] [[package]] name = "log" version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "518ef76f2f87365916b142844c16d8fefd85039bc5699050210a7778ee1cd1de" dependencies = [ "value-bag", ] [[package]] name = "matches" version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" |
︙ | ︙ | |||
1807 1808 1809 1810 1811 1812 1813 | name = "openssl-macros" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", | | | 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 | name = "openssl-macros" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", "syn 2.0.18", ] [[package]] name = "openssl-probe" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" |
︙ | ︙ | |||
1935 1936 1937 1938 1939 1940 1941 | name = "pin-project-internal" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", | | | 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 | name = "pin-project-internal" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39407670928234ebc5e6e580247dd567ad73a3578460c5990f9503df207e8f07" dependencies = [ "proc-macro2", "quote", "syn 2.0.18", ] [[package]] name = "pin-project-lite" version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" |
︙ | ︙ | |||
2326 2327 2328 2329 2330 2331 2332 | "native-tls", "once_cell", "percent-encoding 2.2.0", "pin-project-lite", "serde", "serde_json", "serde_urlencoded 0.7.1", | | > | 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 | "native-tls", "once_cell", "percent-encoding 2.2.0", "pin-project-lite", "serde", "serde_json", "serde_urlencoded 0.7.1", "tokio 1.28.2", "tokio-native-tls", "tokio-socks", "tokio-util", "tower-service", "url 2.3.1", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", "winreg 0.10.1", |
︙ | ︙ | |||
2365 2366 2367 2368 2369 2370 2371 | "derive_builder 0.9.0", "quick-xml 0.17.2", "reqwest 0.9.24", ] [[package]] name = "rsstg" | | | 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 | "derive_builder 0.9.0", "quick-xml 0.17.2", "reqwest 0.9.24", ] [[package]] name = "rsstg" version = "0.2.18" dependencies = [ "anyhow", "async-std", "atom_syndication", "chrono", "config", "futures 0.3.28", |
︙ | ︙ | |||
2538 2539 2540 2541 2542 2543 2544 | name = "serde_derive" version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", | | | 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 | name = "serde_derive" version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", "syn 2.0.18", ] [[package]] name = "serde_json" version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" |
︙ | ︙ | |||
2810 2811 2812 2813 2814 2815 2816 | "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "syn" | | | | 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 | "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "syn" version = "2.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32d41677bcbe24c20c52e7c70b0d8db04134c5d1066bf98662e2871ad200ea3e" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] |
︙ | ︙ | |||
2842 2843 2844 2845 2846 2847 2848 | dependencies = [ "bytes 1.4.0", "futures 0.3.28", "hyper 0.14.26", "hyper-tls 0.5.0", "multipart", "telegram-bot-raw", | | | 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 | dependencies = [ "bytes 1.4.0", "futures 0.3.28", "hyper 0.14.26", "hyper-tls 0.5.0", "multipart", "telegram-bot-raw", "tokio 1.28.2", "tracing", "tracing-futures", ] [[package]] name = "telegram-bot-raw" version = "0.9.0" |
︙ | ︙ | |||
2889 2890 2891 2892 2893 2894 2895 | name = "thiserror-impl" version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", | | | 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 | name = "thiserror-impl" version = "1.0.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", "syn 2.0.18", ] [[package]] name = "time" version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" |
︙ | ︙ | |||
2939 2940 2941 2942 2943 2944 2945 | "tokio-tcp", "tokio-threadpool", "tokio-timer", ] [[package]] name = "tokio" | | | | 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 | "tokio-tcp", "tokio-threadpool", "tokio-timer", ] [[package]] name = "tokio" version = "1.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2" dependencies = [ "autocfg 1.1.0", "bytes 1.4.0", "libc", "mio 0.8.6", "num_cpus", "pin-project-lite", |
︙ | ︙ | |||
3002 3003 3004 3005 3006 3007 3008 | [[package]] name = "tokio-native-tls" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" dependencies = [ "native-tls", | | > > > > > > > > > > > > | 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 | [[package]] name = "tokio-native-tls" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" dependencies = [ "native-tls", "tokio 1.28.2", ] [[package]] name = "tokio-reactor" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" dependencies = [ "crossbeam-utils 0.7.2", "futures 0.1.31", "lazy_static", "log", "mio 0.6.23", "num_cpus", "parking_lot 0.9.0", "slab", "tokio-executor", "tokio-io", "tokio-sync", ] [[package]] name = "tokio-socks" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51165dfa029d2a65969413a6cc96f354b86b464498702f174a4efa13608fd8c0" dependencies = [ "either", "futures-util", "thiserror", "tokio 1.28.2", ] [[package]] name = "tokio-sync" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" dependencies = [ |
︙ | ︙ | |||
3087 3088 3089 3090 3091 3092 3093 | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes 1.4.0", "futures-core", "futures-sink", "pin-project-lite", | | | 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes 1.4.0", "futures-core", "futures-sink", "pin-project-lite", "tokio 1.28.2", "tracing", ] [[package]] name = "toml" version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" |
︙ | ︙ | |||
3126 3127 3128 3129 3130 3131 3132 | name = "tracing-attributes" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", | | | 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 | name = "tracing-attributes" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", "syn 2.0.18", ] [[package]] name = "tracing-core" version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" |
︙ | ︙ | |||
3256 3257 3258 3259 3260 3261 3262 | checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" dependencies = [ "rand 0.6.5", ] [[package]] name = "value-bag" | | | < < < < | 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 | checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" dependencies = [ "rand 0.6.5", ] [[package]] name = "value-bag" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4d330786735ea358f3bc09eea4caa098569c1c93f342d9aca0514915022fe7e" [[package]] name = "vcpkg" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" |
︙ | ︙ | |||
3342 3343 3344 3345 3346 3347 3348 | checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", | | | 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 | checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", "syn 2.0.18", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" version = "0.4.36" source = "registry+https://github.com/rust-lang/crates.io-index" |
︙ | ︙ | |||
3376 3377 3378 3379 3380 3381 3382 | name = "wasm-bindgen-macro-support" version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", | | | 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 | name = "wasm-bindgen-macro-support" version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", "syn 2.0.18", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.86" |
︙ | ︙ |
Modified Cargo.toml
from [38f7907aa7]
to [2ad01297e3].
1 2 | [package] name = "rsstg" | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | [package] name = "rsstg" version = "0.2.18" authors = ["arcade"] edition = "2021" [dependencies] anyhow = "*" async-std = { version = "*", features = [ "tokio1" ] } atom_syndication = { version = "*", features = [ "with-serde" ] } chrono = "*" config = { version = "*", default-features = false, features = [ "toml" ] } futures = "*" futures-util = "*" lazy_static = "*" regex = "*" reqwest = { version = "^0.11", features = [ "brotli", "socks", "deflate" ]} rss = { version = "*", features = [ "from_url" ] } sedregex = "*" sqlx = { version = "*", features = [ "postgres", "tls", "runtime-async-std-rustls", "chrono" ] } telegram-bot = { git = "https://github.com/telegram-rs/telegram-bot" } #surf = { version = "*", default-features = false, features = [ "middleware-logger", "encoding", "h1-client-rustls" ] } |
︙ | ︙ |
Modified rsstg.toml.example
from [70707be159]
to [83432d9677].
1 2 | pg = "postgres://user:password@hostname/database" api_key = "speak with @BotFather to get one" | | > | 1 2 3 4 | pg = "postgres://user:password@hostname/database" api_key = "speak with @BotFather to get one" owner = "Your ID (for debugging)" proxy = "Link to http or socks5 proxy you want to use. Tor works too" |
Modified src/core.rs
from [b99fc8e3c8]
to [ab9ea36160].
︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #[derive(Clone)] pub struct Core { owner_chat: telegram_bot::UserId, pub tg: telegram_bot::Api, pub my: telegram_bot::User, pool: sqlx::Pool<sqlx::Postgres>, sources: Arc<Mutex<HashSet<Arc<i32>>>>, } impl Core { pub fn new(settings: config::Config) -> Result<Arc<Core>> { let owner = settings.get_int("owner")?; let api_key = settings.get_string("api_key")?; let tg = telegram_bot::Api::new(api_key); let tg_cloned = tg.clone(); let core = Arc::new(Core { tg, my: task::block_on(async { tg_cloned.send(telegram_bot::GetMe).await })?, owner_chat: telegram_bot::UserId::new(owner), pool: PgPoolOptions::new() .max_connections(5) .acquire_timeout(std::time::Duration::new(300, 0)) .idle_timeout(std::time::Duration::new(60, 0)) .connect_lazy(&settings.get_string("pg")?)?, sources: Arc::new(Mutex::new(HashSet::new())), }); let clone = core.clone(); task::spawn(async move { loop { let delay = match &clone.autofetch().await { Err(err) => { if let Err(err) = clone.send(format!("🛑 {:?}", err), None, None).await { | > > > > > > > > > > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #[derive(Clone)] pub struct Core { owner_chat: telegram_bot::UserId, pub tg: telegram_bot::Api, pub my: telegram_bot::User, pool: sqlx::Pool<sqlx::Postgres>, sources: Arc<Mutex<HashSet<Arc<i32>>>>, http_client: reqwest::Client, } impl Core { pub fn new(settings: config::Config) -> Result<Arc<Core>> { let owner = settings.get_int("owner")?; let api_key = settings.get_string("api_key")?; let tg = telegram_bot::Api::new(api_key); let tg_cloned = tg.clone(); let proxy = settings.get_string("proxy")?; let mut client = reqwest::Client::builder(); if !proxy.is_empty() { let proxy = reqwest::Proxy::all(proxy)?; client = client.proxy(proxy); } let http_client = client.build()?; let core = Arc::new(Core { tg, my: task::block_on(async { tg_cloned.send(telegram_bot::GetMe).await })?, owner_chat: telegram_bot::UserId::new(owner), pool: PgPoolOptions::new() .max_connections(5) .acquire_timeout(std::time::Duration::new(300, 0)) .idle_timeout(std::time::Duration::new(60, 0)) .connect_lazy(&settings.get_string("pg")?)?, sources: Arc::new(Mutex::new(HashSet::new())), http_client, }); let clone = core.clone(); task::spawn(async move { loop { let delay = match &clone.autofetch().await { Err(err) => { if let Err(err) = clone.send(format!("🛑 {:?}", err), None, None).await { |
︙ | ︙ | |||
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | .with_context(|| format!("Query queue fetch conn:\n{:?}", &self.pool))?; let row = sqlx::query("select source_id, channel_id, url, iv_hash, owner, url_re from rsstg_source where source_id = $1 and owner = $2") .bind(*id) .bind(owner) .fetch_one(&mut conn).await .with_context(|| format!("Query source:\n{:?}", &self.pool))?; drop(conn); let channel_id: i64 = row.try_get("channel_id")?; let url: &str = row.try_get("url")?; let iv_hash: Option<&str> = row.try_get("iv_hash")?; let url_re = match row.try_get("url_re")? { Some(x) => Some(sedregex::ReplaceCommand::new(x)?), None => None, }; let destination = match real { true => telegram_bot::UserId::new(channel_id), false => telegram_bot::UserId::new(row.try_get("owner")?), }; let mut this_fetch: Option<DateTime<chrono::FixedOffset>> = None; let mut posts: BTreeMap<DateTime<chrono::FixedOffset>, String> = BTreeMap::new(); | > | > | 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | .with_context(|| format!("Query queue fetch conn:\n{:?}", &self.pool))?; let row = sqlx::query("select source_id, channel_id, url, iv_hash, owner, url_re from rsstg_source where source_id = $1 and owner = $2") .bind(*id) .bind(owner) .fetch_one(&mut conn).await .with_context(|| format!("Query source:\n{:?}", &self.pool))?; drop(conn); let channel_id: i64 = row.try_get("channel_id")?; let url: &str = row.try_get("url")?; let iv_hash: Option<&str> = row.try_get("iv_hash")?; let url_re = match row.try_get("url_re")? { Some(x) => Some(sedregex::ReplaceCommand::new(x)?), None => None, }; let destination = match real { true => telegram_bot::UserId::new(channel_id), false => telegram_bot::UserId::new(row.try_get("owner")?), }; let mut this_fetch: Option<DateTime<chrono::FixedOffset>> = None; let mut posts: BTreeMap<DateTime<chrono::FixedOffset>, String> = BTreeMap::new(); let response = self.http_client.get(url).send().await?; let status = response.status(); let content = response.bytes().await?; match rss::Channel::read_from(&content[..]) { Ok(feed) => { for item in feed.items() { if let Some(link) = item.link() { let date = match item.pub_date() { |
︙ | ︙ |