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;
9c4f09193a 2026-01-09 10:
9adc69d514 2026-03-25 11: use std::sync::Arc;
9adc69d514 2026-03-25 12:
dc7c43b010 2026-01-01 13: use async_compat::Compat;
9adc69d514 2026-03-25 14: use smol::lock::Mutex;
44575a91d3 2025-07-09 15: use stacked_errors::{
44575a91d3 2025-07-09 16: Result,
44575a91d3 2025-07-09 17: StackableErr,
44575a91d3 2025-07-09 18: };
bb89b6fab8 2025-06-15 19: use tgbot::handler::LongPoll;
bb89b6fab8 2025-06-15 20:
dc7c43b010 2026-01-01 21: fn main () -> Result<()> {
7393d62235 2026-01-07 22: smol::block_on(Compat::new(async {
dc7c43b010 2026-01-01 23: async_main().await.unwrap();
dc7c43b010 2026-01-01 24: }));
dc7c43b010 2026-01-01 25:
dc7c43b010 2026-01-01 26: Ok(())
dc7c43b010 2026-01-01 27: }
dc7c43b010 2026-01-01 28:
fabcca1eaf 2026-01-09 29: /// Initialises configuration and the bot core, then runs the Telegram long-poll loop.
fabcca1eaf 2026-01-09 30: ///
fabcca1eaf 2026-01-09 31: /// This function loads configuration (with a default API gateway), constructs the application
fabcca1eaf 2026-01-09 32: /// core, and starts the long-polling loop that handles incoming Telegram updates.
dc7c43b010 2026-01-01 33: async fn async_main () -> Result<()> {
e624ef9d66 2025-04-20 34: let settings = config::Config::builder()
42b29b744b 2026-01-01 35: .set_default("api_gateway", "https://api.telegram.org").stack()?
e624ef9d66 2025-04-20 36: .add_source(config::File::with_name("rsstg"))
44575a91d3 2025-07-09 37: .build()
44575a91d3 2025-07-09 38: .stack()?;
e624ef9d66 2025-04-20 39:
44575a91d3 2025-07-09 40: let core = core::Core::new(settings).await.stack()?;
e624ef9d66 2025-04-20 41:
9c4f09193a 2026-01-09 42: LongPoll::new(core.tg.client.clone(), core).run().await;
61df933942 2020-11-18 43:
61df933942 2020-11-18 44: Ok(())
61df933942 2020-11-18 45: }