614456ed35 2025-02-22 1: //! This is telegram bot to fetch RSS/ATOM feeds and post results on public
614456ed35 2025-02-22 2: //! channels
614456ed35 2025-02-22 3:
614456ed35 2025-02-22 4: #![warn(missing_docs)]
614456ed35 2025-02-22 5:
614456ed35 2025-02-22 6: mod command;
614456ed35 2025-02-22 7: mod core;
0340541002 2025-04-24 8: mod sql;
9c4f09193a 2026-01-09 9: mod tg_bot;
bb89b6fab8 2025-06-15 10:
dc7c43b010 2026-01-01 11: use async_compat::Compat;
44575a91d3 2025-07-09 12: use stacked_errors::{
44575a91d3 2025-07-09 13: Result,
44575a91d3 2025-07-09 14: StackableErr,
44575a91d3 2025-07-09 15: };
bb89b6fab8 2025-06-15 16: use tgbot::handler::LongPoll;
bb89b6fab8 2025-06-15 17:
dc7c43b010 2026-01-01 18: fn main () -> Result<()> {
7393d62235 2026-01-07 19: smol::block_on(Compat::new(async {
dc7c43b010 2026-01-01 20: async_main().await.unwrap();
dc7c43b010 2026-01-01 21: }));
dc7c43b010 2026-01-01 22:
dc7c43b010 2026-01-01 23: Ok(())
dc7c43b010 2026-01-01 24: }
dc7c43b010 2026-01-01 25:
fabcca1eaf 2026-01-09 26: /// Initialises configuration and the bot core, then runs the Telegram long-poll loop.
fabcca1eaf 2026-01-09 27: ///
fabcca1eaf 2026-01-09 28: /// This function loads configuration (with a default API gateway), constructs the application
fabcca1eaf 2026-01-09 29: /// core, and starts the long-polling loop that handles incoming Telegram updates.
dc7c43b010 2026-01-01 30: async fn async_main () -> Result<()> {
e624ef9d66 2025-04-20 31: let settings = config::Config::builder()
42b29b744b 2026-01-01 32: .set_default("api_gateway", "https://api.telegram.org").stack()?
e624ef9d66 2025-04-20 33: .add_source(config::File::with_name("rsstg"))
44575a91d3 2025-07-09 34: .build()
44575a91d3 2025-07-09 35: .stack()?;
e624ef9d66 2025-04-20 36:
44575a91d3 2025-07-09 37: let core = core::Core::new(settings).await.stack()?;
e624ef9d66 2025-04-20 38:
9c4f09193a 2026-01-09 39: LongPoll::new(core.tg.client.clone(), core).run().await;
61df933942 2020-11-18 40:
61df933942 2020-11-18 41: Ok(())
61df933942 2020-11-18 42: }