Changes In Branch trunk Through [e624ef9d66] Excluding Merge-Ins
This is equivalent to a diff from a2880e5100 to e624ef9d66
2025-04-24
| ||
12:12 | move all sql stuff to separate module, get rid of macros check-in: 0340541002 user: arcade tags: trunk, v0.3.1 | |
2025-04-20
| ||
09:51 | drop old telegram_bot library, switch to frankenstein check-in: e624ef9d66 user: arcade tags: trunk, v0.3.0 | |
2025-04-19
| ||
08:06 | well, that was an attempt to go teloxide, but let's try frankenstein Leaf check-in: a2880e5100 user: arcade tags: frankenstein | |
2025-04-06
| ||
10:00 | bump crates Closed-Leaf check-in: fc8aa8c8ab user: arcade tags: trunk, v0.2.26 | |
Modified Cargo.lock
from [35f78aff63]
to [85f5ac9f8e].
︙ | ︙ | |||
64 65 66 67 68 69 70 | [[package]] name = "anyhow" version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" | < < < < < < < < < < < < < < | 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | [[package]] name = "anyhow" version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "async-attributes" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" dependencies = [ "quote", |
︙ | ︙ | |||
245 246 247 248 249 250 251 252 253 254 255 256 257 258 | ] [[package]] name = "async-task" version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "atoi" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" dependencies = [ | > > > > > > > > > > > | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | ] [[package]] name = "async-task" version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" version = "0.1.88" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" dependencies = [ "proc-macro2", "quote", "syn 2.0.100", ] [[package]] name = "atoi" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" dependencies = [ |
︙ | ︙ | |||
344 345 346 347 348 349 350 351 352 353 354 355 356 357 | dependencies = [ "async-channel 2.3.1", "async-task", "futures-io", "futures-lite 2.6.0", "piper", ] [[package]] name = "brotli" version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd" dependencies = [ | > > > > > > > > > > > > > > > > > > > > > > > > > | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | dependencies = [ "async-channel 2.3.1", "async-task", "futures-io", "futures-lite 2.6.0", "piper", ] [[package]] name = "bon" version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94054366e2ff97b455acdd4fdb03913f717febc57b7bbd1741b2c3b87efae030" dependencies = [ "bon-macros", "rustversion", ] [[package]] name = "bon-macros" version = "3.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "542a990e676ce0a0a895ae54b2d94afd012434f2228a85b186c6bc1a7056cdc6" dependencies = [ "darling", "ident_case", "prettyplease", "proc-macro2", "quote", "rustversion", "syn 2.0.100", ] [[package]] name = "brotli" version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd" dependencies = [ |
︙ | ︙ | |||
372 373 374 375 376 377 378 | [[package]] name = "bumpalo" version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" | < < < < < < | 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | [[package]] name = "bumpalo" version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] |
︙ | ︙ | |||
573 574 575 576 577 578 579 | checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" dependencies = [ "const-oid", "pem-rfc7468", "zeroize", ] | < < < < < < < < < < | 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" dependencies = [ "const-oid", "pem-rfc7468", "zeroize", ] [[package]] name = "derive_builder" version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" dependencies = [ "derive_builder_macro", |
︙ | ︙ | |||
614 615 616 617 618 619 620 | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", "syn 2.0.100", ] | < < < < < < < < < < < < < < < < < < < < < | 620 621 622 623 624 625 626 627 628 629 630 631 632 633 | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", "syn 2.0.100", ] [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", |
︙ | ︙ | |||
673 674 675 676 677 678 679 | [[package]] name = "dotenvy" version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" | < < < < < < < < < | 658 659 660 661 662 663 664 665 666 667 668 669 670 671 | [[package]] name = "dotenvy" version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" [[package]] name = "either" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" dependencies = [ "serde", |
︙ | ︙ | |||
706 707 708 709 710 711 712 | [[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" | < < < < < < < < < < | 682 683 684 685 686 687 688 689 690 691 692 693 694 695 | [[package]] name = "equivalent" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", |
︙ | ︙ | |||
835 836 837 838 839 840 841 842 843 844 845 846 847 848 | name = "form_urlencoded" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "futures" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ | > > > > > > > > > > > > > > > > > > | 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 | name = "form_urlencoded" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] [[package]] name = "frankenstein" version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bb8f97b9b2fefaa34071c0ccb9df53d7d15d5c4a375c07cd701e133dac048af" dependencies = [ "async-trait", "bon", "macro_rules_attribute", "paste", "reqwest", "serde", "serde_json", "serde_with", "thiserror 2.0.12", "tokio", ] [[package]] name = "futures" version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ |
︙ | ︙ | |||
1031 1032 1033 1034 1035 1036 1037 | dependencies = [ "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", "http", | | < < < < < < | | 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 | dependencies = [ "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", "http", "indexmap", "slab", "tokio", "tokio-util", "tracing", ] [[package]] name = "hashbrown" version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" dependencies = [ "allocator-api2", "equivalent", "foldhash", ] [[package]] name = "hashlink" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" dependencies = [ "hashbrown", ] [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" |
︙ | ︙ | |||
1398 1399 1400 1401 1402 1403 1404 | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" dependencies = [ "icu_normalizer", "icu_properties", ] | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < | 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" dependencies = [ "icu_normalizer", "icu_properties", ] [[package]] name = "indexmap" version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", "hashbrown", ] [[package]] name = "instant" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" |
︙ | ︙ | |||
1465 1466 1467 1468 1469 1470 1471 | [[package]] name = "ipnet" version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" | < < < < < < < < < | 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 | [[package]] name = "ipnet" version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "itoa" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] |
︙ | ︙ | |||
1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 | version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" dependencies = [ "value-bag", ] [[package]] name = "md-5" version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ "cfg-if", | > > > > > > > > > > > > > > > > | 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 | version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" dependencies = [ "value-bag", ] [[package]] name = "macro_rules_attribute" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a82271f7bc033d84bbca59a3ce3e4159938cb08a9c3aebbe54d215131518a13" dependencies = [ "macro_rules_attribute-proc_macro", "paste", ] [[package]] name = "macro_rules_attribute-proc_macro" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8dd856d451cc0da70e2ef2ce95a18e39a93b7558bedf10201ad28503f918568" [[package]] name = "md-5" version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" dependencies = [ "cfg-if", |
︙ | ︙ | |||
1665 1666 1667 1668 1669 1670 1671 | "num-iter", "num-traits", "rand 0.8.5", "smallvec", "zeroize", ] | < < < < < < | 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 | "num-iter", "num-traits", "rand 0.8.5", "smallvec", "zeroize", ] [[package]] name = "num-integer" version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ "num-traits", |
︙ | ︙ | |||
1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 | "cfg-if", "libc", "redox_syscall", "smallvec", "windows-targets 0.52.6", ] [[package]] name = "pathdiff" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" [[package]] | > > > > > > | 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 | "cfg-if", "libc", "redox_syscall", "smallvec", "windows-targets 0.52.6", ] [[package]] name = "paste" version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pathdiff" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" [[package]] |
︙ | ︙ | |||
1810 1811 1812 1813 1814 1815 1816 | [[package]] name = "percent-encoding" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" | < < < < < < < < < < < < < < < < < < < < | 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 | [[package]] name = "percent-encoding" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] |
︙ | ︙ | |||
1911 1912 1913 1914 1915 1916 1917 | "hermit-abi 0.4.0", "pin-project-lite", "rustix 0.38.44", "tracing", "windows-sys 0.59.0", ] | < < < < < < | | | < < | < < < < < < < < < < < < < < < < < < | 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 | "hermit-abi 0.4.0", "pin-project-lite", "rustix 0.38.44", "tracing", "windows-sys 0.59.0", ] [[package]] name = "ppv-lite86" version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" dependencies = [ "zerocopy", ] [[package]] name = "prettyplease" version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "664ec5419c51e34154eec046ebcba56312d5a2fc3b09a06da188e1ad21afadf6" dependencies = [ "proc-macro2", "syn 2.0.100", ] [[package]] name = "proc-macro2" version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] [[package]] name = "quick-xml" version = "0.37.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4ce8c88de324ff838700f36fb6ab86c96df0e3c4ab6ef3a9b2044465cce1369" dependencies = [ "encoding_rs", |
︙ | ︙ | |||
2103 2104 2105 2106 2107 2108 2109 | version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ "getrandom 0.3.2", ] | < < < < < < < < < | 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 | version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ "getrandom 0.3.2", ] [[package]] name = "redox_syscall" version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2f103c6d277498fbceb16e84d317e2a400f160f46904d5f5410848c829511a3" dependencies = [ "bitflags 2.9.0", |
︙ | ︙ | |||
2204 2205 2206 2207 2208 2209 2210 | "wasm-bindgen-futures", "wasm-streams", "web-sys", "webpki-roots", "windows-registry", ] | < < < < < < < < < | 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 | "wasm-bindgen-futures", "wasm-streams", "web-sys", "webpki-roots", "windows-registry", ] [[package]] name = "ring" version = "0.17.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" dependencies = [ "cc", |
︙ | ︙ | |||
2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 | version = "0.3.0" dependencies = [ "anyhow", "async-std", "atom_syndication", "chrono", "config", "futures", "futures-util", "lazy_static", "regex", "reqwest", "rss", "sedregex", "sqlx", | > < | 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 | version = "0.3.0" dependencies = [ "anyhow", "async-std", "atom_syndication", "chrono", "config", "frankenstein", "futures", "futures-util", "lazy_static", "regex", "reqwest", "rss", "sedregex", "sqlx", "thiserror 2.0.12", ] [[package]] name = "rustc-demangle" version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" |
︙ | ︙ | |||
2493 2494 2495 2496 2497 2498 2499 | [[package]] name = "serde_with" version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" dependencies = [ | < < < < < < < | 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 | [[package]] name = "serde_with" version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6b6f7f2fcb69f747921f79f3926bd1e203fce4fef62c268dd3abfb6d86029aa" dependencies = [ "serde", "serde_derive", "serde_with_macros", ] [[package]] name = "serde_with_macros" version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d00caa5193a3c8362ac2b73be6b9e768aa5a4b2f721d8f4b339600c3cb51f8e" |
︙ | ︙ | |||
2545 2546 2547 2548 2549 2550 2551 | [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" | < < < < < < < < < | 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 | [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signature" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest", |
︙ | ︙ | |||
2653 2654 2655 2656 2657 2658 2659 | "crossbeam-queue", "either", "event-listener 5.4.0", "futures-core", "futures-intrusive", "futures-io", "futures-util", | | | | 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 | "crossbeam-queue", "either", "event-listener 5.4.0", "futures-core", "futures-intrusive", "futures-io", "futures-util", "hashbrown", "hashlink", "indexmap", "log", "memchr", "once_cell", "percent-encoding", "rustls", "serde", "serde_json", |
︙ | ︙ | |||
2822 2823 2824 2825 2826 2827 2828 | [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" | < < < < < < < < < < < < < | 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 | [[package]] name = "stable_deref_trait" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "stringprep" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b4df3d392d81bd458a8a621b8bffbd2302a12ffe288a9d931670948749463b1" dependencies = [ "unicode-bidi", |
︙ | ︙ | |||
2921 2922 2923 2924 2925 2926 2927 | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" dependencies = [ "core-foundation-sys", "libc", ] | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 | source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" dependencies = [ "core-foundation-sys", "libc", ] [[package]] name = "tempfile" version = "3.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" dependencies = [ "fastrand 2.3.0", |
︙ | ︙ | |||
3056 3057 3058 3059 3060 3061 3062 | checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", "syn 2.0.100", ] | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 | checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", "syn 2.0.100", ] [[package]] name = "tinystr" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" dependencies = [ "displaydoc", |
︙ | ︙ | |||
3123 3124 3125 3126 3127 3128 3129 | checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" dependencies = [ "backtrace", "bytes", "libc", "mio", "pin-project-lite", | < | 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 | checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" dependencies = [ "backtrace", "bytes", "libc", "mio", "pin-project-lite", "socket2 0.5.9", "windows-sys 0.52.0", ] [[package]] name = "tokio-native-tls" version = "0.3.1" |
︙ | ︙ | |||
3160 3161 3162 3163 3164 3165 3166 | dependencies = [ "either", "futures-util", "thiserror 1.0.69", "tokio", ] | < < < < < < < < < < < | 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 | dependencies = [ "either", "futures-util", "thiserror 1.0.69", "tokio", ] [[package]] name = "tokio-util" version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b9590b93e6fcc1739458317cccd391ad3955e2bde8913edf6f95f9e65a8f034" dependencies = [ "bytes", |
︙ | ︙ | |||
3211 3212 3213 3214 3215 3216 3217 | [[package]] name = "toml_edit" version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ | | | 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 | [[package]] name = "toml_edit" version = "0.22.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", "winnow", ] [[package]] |
︙ | ︙ | |||
3322 3323 3324 3325 3326 3327 3328 | [[package]] name = "unicode-properties" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" | < < < < < < < < < < < < < < < < | 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 | [[package]] name = "unicode-properties" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" [[package]] name = "untrusted" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" version = "2.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" dependencies = [ "form_urlencoded", "idna", "percent-encoding", ] [[package]] name = "utf16_iter" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" [[package]] name = "utf8_iter" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" [[package]] name = "value-bag" version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "943ce29a8a743eb10d6082545d861b24f9d1b160b7d741e0f2cdf726bec909c5" [[package]] |
︙ | ︙ |
Modified Cargo.toml
from [40a2849462]
to [0f0e00c98d].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | [package] name = "rsstg" version = "0.3.0" authors = ["arcade"] edition = "2021" [dependencies] anyhow = "1.0.86" async-std = { version = "1.12.0", features = [ "attributes", "tokio1" ] } atom_syndication = { version = "0.12.4", features = [ "with-serde" ] } chrono = "0.4.38" config = { version = "0.15", default-features = false, features = [ "toml" ] } futures = "0.3.30" futures-util = "0.3.30" lazy_static = "1.5.0" regex = "1.10.6" reqwest = { version = "0.12.7", features = [ "brotli", "socks", "deflate" ]} rss = "2.0.9" sedregex = "0.2.5" sqlx = { version = "0.8", features = [ "postgres", "runtime-async-std-rustls", "chrono", "macros" ], default-features = false } | > < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | [package] name = "rsstg" version = "0.3.0" authors = ["arcade"] edition = "2021" [dependencies] anyhow = "1.0.86" async-std = { version = "1.12.0", features = [ "attributes", "tokio1" ] } atom_syndication = { version = "0.12.4", features = [ "with-serde" ] } chrono = "0.4.38" config = { version = "0.15", default-features = false, features = [ "toml" ] } frankenstein = { version = "0.40.0", features = [ "client-reqwest" ] } futures = "0.3.30" futures-util = "0.3.30" lazy_static = "1.5.0" regex = "1.10.6" reqwest = { version = "0.12.7", features = [ "brotli", "socks", "deflate" ]} rss = "2.0.9" sedregex = "0.2.5" sqlx = { version = "0.8", features = [ "postgres", "runtime-async-std-rustls", "chrono", "macros" ], default-features = false } thiserror = "2.0.0" [profile.release] lto = true codegen-units = 1 |
Modified src/command.rs
from [08ae8be400]
to [11c299d7be].
1 2 3 4 5 6 7 8 9 10 | use crate::core::Core; use anyhow::{ bail, Context, Result }; use lazy_static::lazy_static; use regex::Regex; use sedregex::ReplaceCommand; | > > > > > > > > > > > > > > < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < | | < | | | | | | | | | > | | | > > > > > > > > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 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 134 135 136 137 138 139 140 | use crate::core::Core; use std::borrow::Cow; use anyhow::{ bail, Context, Result }; use frankenstein::{ methods::{ GetChatAdministratorsParams, GetChatParams, }, types::{ ChatId, ChatMember, }, AsyncTelegramApi, ParseMode, }; use lazy_static::lazy_static; use regex::Regex; use sedregex::ReplaceCommand; lazy_static! { static ref RE_USERNAME: Regex = Regex::new(r"^@[a-zA-Z][a-zA-Z0-9_]+$").unwrap(); static ref RE_LINK: Regex = Regex::new(r"^https?://[a-zA-Z.0-9-]+/[-_a-zA-Z.:0-9/?=]+$").unwrap(); static ref RE_IV_HASH: Regex = Regex::new(r"^[a-f0-9]{14}$").unwrap(); } pub async fn start(core: &Core, chat_id: i64) -> Result<()> { core.send("We are open\\. Probably\\. Visit [channel](https://t.me/rsstg_bot_help/3) for details\\.", Some(chat_id), Some(ParseMode::MarkdownV2)).await?; Ok(()) } pub async fn list(core: &Core, sender: i64) -> Result<()> { core.send(core.list(sender).await?, Some(sender), Some(ParseMode::MarkdownV2)).await?; Ok(()) } pub async fn command(core: &Core, sender: i64, command: Vec<&str>) -> Result<()> { if command.len() >= 2 { let msg: Cow<str> = match &command[1].parse::<i32>() { Err(err) => format!("I need a number.\n{}", &err).into(), Ok(number) => match command[0] { "/check" => core.check(number, sender, false).await .context("Channel check failed.")?, "/clean" => core.clean(number, sender).await?, "/enable" => core.enable(number, sender).await?.into(), "/delete" => core.delete(number, sender).await?, "/disable" => core.disable(number, sender).await?.into(), _ => bail!("Command {} not handled.", &command[0]), }, }; core.send(msg, Some(sender), None).await?; } else { core.send("This command needs a number.", Some(sender), None).await?; } Ok(()) } pub async fn update(core: &Core, sender: i64, command: Vec<&str>) -> Result<()> { let mut source_id: Option<i32> = None; let at_least = "Requires at least 3 parameters."; let mut i_command = command.iter(); let first_word = i_command.next().context(at_least)?; match *first_word { "/update" => { let next_word = i_command.next().context(at_least)?; source_id = Some(next_word.parse::<i32>() .context(format!("I need a number, but got {next_word}."))?); }, "/add" => {}, _ => bail!("Passing {first_word} is not possible here."), }; let (channel, url, iv_hash, url_re) = ( i_command.next().context(at_least)?, i_command.next().context(at_least)?, i_command.next(), i_command.next()); if ! RE_USERNAME.is_match(channel) { bail!("Usernames should be something like \"@\\[a\\-zA\\-Z]\\[a\\-zA\\-Z0\\-9\\_]+\", aren't they?\nNot {channel:?}"); }; if ! RE_LINK.is_match(url) { bail!("Link should be a link to atom/rss feed, something like \"https://domain/path\".\nNot {url:?}"); } let iv_hash = match iv_hash { Some(hash) => { match *hash { "-" => None, thing => { if ! RE_IV_HASH.is_match(thing) { bail!("IV hash should be 14 hex digits.\nNot {thing:?}"); }; Some(thing) }, } }, None => None, }; let url_re = match url_re { Some(re) => { match *re { "-" => None, thing => { let _url_rex = ReplaceCommand::new(thing).context("Regexp parsing error:")?; Some(thing) } } }, None => None, }; let chat_id = ChatId::String((*channel).into()); let channel_id = core.tg.get_chat(&GetChatParams { chat_id: chat_id.clone() }).await?.result.id; let chan_adm = core.tg.get_chat_administrators(&GetChatAdministratorsParams { chat_id }).await .context("Sorry, I have no access to that chat.")?.result; let (mut me, mut user) = (false, false); for admin in chan_adm { let member_id = match admin { ChatMember::Creator(member) => member.user.id, ChatMember::Administrator(member) => member.user.id, ChatMember::Left(_) | ChatMember::Kicked(_) | ChatMember::Member(_) | ChatMember::Restricted(_) => continue, } as i64; if member_id == core.me.id as i64 { me = true; }; if member_id == sender { user = true; }; }; if ! me { bail!("I need to be admin on that channel."); }; if ! user { bail!("You should be admin on that channel."); }; core.send(core.update(source_id, channel, channel_id, url, iv_hash, url_re, sender).await?, Some(sender), None).await?; Ok(()) } |
Modified src/core.rs
from [90bda79dca]
to [d44f60dcb6].
|
| < < | < < < < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | < > > < | < | | | | | | | > > > > > > | > > > > | < > > > > | | < < < < | < < > > > > > | > > > > > | < < | < < | > | < | < | | < | | < | | | | < | > | > | | > > > > > > > > > > > > > | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 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 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | use crate::command; use std::{ borrow::Cow, collections::{ BTreeMap, HashSet, }, num::TryFromIntError, sync::{ Arc, Mutex }, }; use anyhow::{ anyhow, bail, Result, }; use async_std::task; use chrono::DateTime; use frankenstein::{ client_reqwest::Bot, methods::{ GetUpdatesParams, SendMessageParams }, types::{ AllowedUpdate, MessageEntityType, User, }, updates::UpdateContent, AsyncTelegramApi, ParseMode, }; use sqlx::postgres::PgPoolOptions; use thiserror::Error; #[derive(Error, Debug)] pub enum RssError { // #[error(transparent)] // Tg(#[from] TgError), #[error(transparent)] Int(#[from] TryFromIntError), } #[derive(Clone)] pub struct Core { owner_chat: i64, pub tg: Bot, pub me: User, pool: sqlx::Pool<sqlx::Postgres>, sources: Arc<Mutex<HashSet<Arc<i32>>>>, http_client: reqwest::Client, } impl Core { pub async fn new(settings: config::Config) -> Result<Arc<Core>> { let owner_chat = settings.get_int("owner")?; let api_key = settings.get_string("api_key")?; let tg = Bot::new(&api_key); let mut client = reqwest::Client::builder(); if let Ok(proxy) = settings.get_string("proxy") { let proxy = reqwest::Proxy::all(proxy)?; client = client.proxy(proxy); } let http_client = client.build()?; let me = tg.get_me().await?; let me = me.result; let core = Arc::new(Core { tg, me, owner_chat, 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 { eprintln!("Autofetch error: {err:?}"); }; std::time::Duration::from_secs(60) }, Ok(time) => *time, }; task::sleep(delay).await; } }); Ok(core) } pub async fn stream(&self) -> Result<()> { let mut offset: i64 = 0; let mut params = GetUpdatesParams { offset: None, limit: Some(100), timeout: Some(300), allowed_updates: Some(vec![AllowedUpdate::Message]), }; loop { let updates = self.tg.get_updates(¶ms).await?.result; if updates.is_empty() { offset = 0; params.offset = None; continue; } for update in updates { if i64::from(update.update_id) >= offset { offset = i64::from(update.update_id) + 1; params.offset = Some(offset); } if let UpdateContent::Message(msg) = update.content { if let Some(text) = msg.text { if let Some(entities) = msg.entities { let chars: Vec<u16> = text.encode_utf16().collect(); for entity in entities { if entity.type_field == MessageEntityType::BotCommand && entity.offset != 0 { bail!("commands should be at message start"); }; let cmd = String::from_utf16_lossy(&chars[entity.offset as usize..entity.length as usize]); let words: Vec<&str> = text.split_whitespace().collect(); match cmd.as_ref() { "/check" | "/clean" | "/enable" | "/delete" | "/disable" => { command::command(self, msg.chat.id, words).await? }, "/start" => { command::start(self, msg.chat.id).await?; }, "/list" => { command::list(self, msg.chat.id).await?; }, "/add" | "/update" => { command::update(self, msg.chat.id, words).await?; }, any => { self.send(format!("\\#error\n```\nUnknown command: {any}\n```"), Some(msg.chat.id), Some(ParseMode::MarkdownV2) ).await?; }, }; }; }; }; }; } } } pub async fn send <S>(&self, msg: S, target: Option<i64>, mode: Option<ParseMode>) -> Result<()> where S: Into<String> { let msg = msg.into(); let mode = mode.unwrap_or(ParseMode::Html); let target = target.unwrap_or(self.owner_chat); let send = SendMessageParams::builder() .chat_id(target) .text(msg) .parse_mode(mode) .build(); self.tg.send_message(&send).await?; Ok(()) } pub async fn check (&self, id: &i32, owner: i64, real: bool) -> Result<Cow<'_, str>> { let mut posted: i32 = 0; let mut conn = self.pool.acquire().await?; let id = { let mut set = self.sources.lock().unwrap(); match set.get(id) { Some(id) => id.clone(), None => { let id = Arc::new(*id); set.insert(id.clone()); id.clone() }, } }; let count = Arc::strong_count(&id); if count == 2 { let source = sqlx::query!("select source_id, channel_id, url, iv_hash, owner, url_re from rsstg_source where source_id = $1 and owner = $2", *id, owner).fetch_one(&mut *conn).await?; let destination = match real { true => source.channel_id, false => source.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(&source.url).send().await?; let status = response.status(); let content = response.bytes().await?; |
︙ | ︙ | |||
179 180 181 182 183 184 185 | for item in feed.entries() { let date = item.published().unwrap(); let url = item.links()[0].href(); posts.insert(*date, url.to_string()); }; }, Err(err) => { | | | | | | | < | < | < < < > < | < < < > | < | < < < > < | < < < > < | > | < < | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | for item in feed.entries() { let date = item.published().unwrap(); let url = item.links()[0].href(); posts.insert(*date, url.to_string()); }; }, Err(err) => { bail!("Unsupported or mangled content:\n{:?}\n{err:#?}\n{status:#?}\n", &source.url) }, } }, rss::Error::Eof => (), _ => bail!("Unsupported or mangled content:\n{:?}\n{err:#?}\n{status:#?}\n", &source.url) } }; for (date, url) in posts.iter() { let post_url: Cow<str> = match source.url_re { Some(ref x) => sedregex::ReplaceCommand::new(x)?.execute(url), None => url.into(), }; if let Some(exists) = sqlx::query!("select exists(select true from rsstg_post where url = $1 and source_id = $2) as exists;", &post_url, *id).fetch_one(&mut *conn).await?.exists { if ! exists { if this_fetch.is_none() || *date > this_fetch.unwrap() { this_fetch = Some(*date); }; self.send( match &source.iv_hash { Some(hash) => format!("<a href=\"https://t.me/iv?url={post_url}&rhash={hash}\"> </a>{post_url}"), None => format!("{post_url}"), }, Some(destination), Some(ParseMode::Html)).await?; sqlx::query!("insert into rsstg_post (source_id, posted, url) values ($1, $2, $3);", *id, date, &post_url).execute(&mut *conn).await?; }; }; posted += 1; }; posts.clear(); }; sqlx::query!("update rsstg_source set last_scrape = now() where source_id = $1;", *id).execute(&mut *conn).await?; Ok(format!("Posted: {posted}").into()) } pub async fn delete (&self, source_id: &i32, owner: i64) -> Result<Cow<'_, str>> { match sqlx::query!("delete from rsstg_source where source_id = $1 and owner = $2;", source_id, owner).execute(&mut *self.pool.acquire().await?).await?.rows_affected() { 0 => { Ok("No data found found.".into()) }, x => { Ok(format!("{} sources removed.", x).into()) }, } } pub async fn clean (&self, source_id: &i32, owner: i64) -> Result<Cow<'_, str>> { match sqlx::query!("delete from rsstg_post p using rsstg_source s where p.source_id = $1 and owner = $2 and p.source_id = s.source_id;", source_id, owner).execute(&mut *self.pool.acquire().await?).await?.rows_affected() { 0 => { Ok("No data found found.".into()) }, x => { Ok(format!("{x} posts purged.").into()) }, } } pub async fn enable (&self, source_id: &i32, owner: i64) -> Result<&str> { match sqlx::query!("update rsstg_source set enabled = true where source_id = $1 and owner = $2", source_id, owner).execute(&mut *self.pool.acquire().await?).await?.rows_affected() { 1 => { Ok("Source enabled.") }, 0 => { Ok("Source not found.") }, _ => { Err(anyhow!("Database error.")) }, } } pub async fn disable (&self, source_id: &i32, owner: i64) -> Result<&str> { match sqlx::query!("update rsstg_source set enabled = false where source_id = $1 and owner = $2", source_id, owner).execute(&mut *self.pool.acquire().await?).await?.rows_affected() { 1 => { Ok("Source disabled.") }, 0 => { Ok("Source not found.") }, _ => { Err(anyhow!("Database error.")) }, } } pub async fn update (&self, update: Option<i32>, channel: &str, channel_id: i64, url: &str, iv_hash: Option<&str>, url_re: Option<&str>, owner: i64) -> Result<&str> { let mut conn = self.pool.acquire().await?; match match update { Some(id) => { sqlx::query!("update rsstg_source set channel_id = $2, url = $3, iv_hash = $4, owner = $5, channel = $6, url_re = $7 where source_id = $1", id, channel_id, url, iv_hash, owner, channel, url_re).execute(&mut *conn).await }, |
︙ | ︙ | |||
295 296 297 298 299 300 301 | }, None => { Ok("No database error extracted.") }, } }, Err(err) => { | | | | | | < < < | | < | > | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | }, None => { Ok("No database error extracted.") }, } }, Err(err) => { bail!("Sorry, unknown error:\n{err:#?}\n"); }, } } async fn autofetch(&self) -> Result<std::time::Duration> { let mut delay = chrono::Duration::minutes(1); let now = chrono::Local::now(); let mut queue = sqlx::query!(r#"select source_id, next_fetch as "next_fetch: DateTime<chrono::Local>", owner from rsstg_order natural left join rsstg_source where next_fetch < now() + interval '1 minute';"#) .fetch_all(&mut *self.pool.acquire().await?).await?; for row in queue.iter() { if let Some(next_fetch) = row.next_fetch { if next_fetch < now { if let (Some(owner), Some(source_id)) = (row.owner, row.source_id) { let clone = Core { owner_chat: owner, ..self.clone() }; task::spawn(async move { if let Err(err) = clone.check(&source_id, owner, true).await { if let Err(err) = clone.send(&format!("🛑 {err:?}"), None, None).await { eprintln!("Check error: {err:?}"); // clone.disable(&source_id, owner).await.unwrap(); }; }; }); } } else if next_fetch - now < delay { delay = next_fetch - now; } } }; queue.clear(); Ok(delay.to_std()?) } pub async fn list (&self, owner: i64) -> Result<String> { let mut reply: Vec<Cow<str>> = vec![]; reply.push("Channels:".into()); let rows = sqlx::query!("select source_id, channel, enabled, url, iv_hash, url_re from rsstg_source where owner = $1 order by source_id", owner).fetch_all(&mut *self.pool.acquire().await?).await?; for row in rows.iter() { reply.push(format!("\n\\#️⃣ {} \\*️⃣ `{}` {}\n🔗 `{}`", row.source_id, row.channel, match row.enabled { true => "🔄 enabled", false => "⛔ disabled", }, row.url).into()); if let Some(hash) = &row.iv_hash { reply.push(format!("IV: `{hash}`").into()); } if let Some(re) = &row.url_re { reply.push(format!("RE: `{re}`").into()); } }; Ok(reply.join("\n")) } } |
Modified src/main.rs
from [3296d64e7b]
to [086f4498d9].
1 2 3 4 5 6 7 8 9 | //! This is telegram bot to fetch RSS/ATOM feeds and post results on public //! channels #![warn(missing_docs)] mod command; mod core; use anyhow::Result; | < < | | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | //! This is telegram bot to fetch RSS/ATOM feeds and post results on public //! channels #![warn(missing_docs)] mod command; mod core; use anyhow::Result; #[async_std::main] async fn main() -> Result<()> { let settings = config::Config::builder() .add_source(config::File::with_name("rsstg")) .build()?; let core = core::Core::new(settings).await?; core.stream().await?; Ok(()) } |