Lines of
src/main.rs
from check-in fabcca1eaf
that are changed by the sequence of edits moving toward
check-in 9adc69d514:
1: //! This is telegram bot to fetch RSS/ATOM feeds and post results on public
2: //! channels
3:
4: #![warn(missing_docs)]
5:
6: mod command;
7: mod core;
8: mod sql;
9: mod tg_bot;
10:
11: use async_compat::Compat;
12: use stacked_errors::{
13: Result,
14: StackableErr,
15: };
16: use tgbot::handler::LongPoll;
17:
18: fn main () -> Result<()> {
19: smol::block_on(Compat::new(async {
20: async_main().await.unwrap();
21: }));
22:
23: Ok(())
24: }
25:
26: /// Initialises configuration and the bot core, then runs the Telegram long-poll loop.
27: ///
28: /// This function loads configuration (with a default API gateway), constructs the application
29: /// core, and starts the long-polling loop that handles incoming Telegram updates.
30: async fn async_main () -> Result<()> {
31: let settings = config::Config::builder()
32: .set_default("api_gateway", "https://api.telegram.org").stack()?
33: .add_source(config::File::with_name("rsstg"))
34: .build()
35: .stack()?;
36:
37: let core = core::Core::new(settings).await.stack()?;
38:
39: LongPoll::new(core.tg.client.clone(), core).run().await;
40:
41: Ok(())
42: }