Annotation For src/main.rs
Logged in as anonymous

Origin for each line in src/main.rs from check-in b543dce9f7:

9171c791eb 2021-11-13        arcade: mod command;
9171c791eb 2021-11-13        arcade: mod core;
9171c791eb 2021-11-13        arcade: 
a7f91033c0 2021-11-13        arcade: use anyhow::Result;
cb86e770f9 2022-03-15        arcade: use async_std::task;
3dc9cddd4d 2023-08-04        arcade: use async_std::stream::StreamExt;
a7f91033c0 2021-11-13        arcade: 
cb86e770f9 2022-03-15        arcade: fn main() -> Result<()> {
28da2e2a00 2022-03-12        arcade: 	let settings = config::Config::builder()
28da2e2a00 2022-03-12        arcade: 		.add_source(config::File::with_name("rsstg"))
28da2e2a00 2022-03-12        arcade: 		.build()?;
a7f91033c0 2021-11-13        arcade: 
cb86e770f9 2022-03-15        arcade: 	let core = core::Core::new(settings)?;
a7f91033c0 2021-11-13        arcade: 
a7f91033c0 2021-11-13        arcade: 	let mut stream = core.stream();
a7f91033c0 2021-11-13        arcade: 	stream.allowed_updates(&[telegram_bot::AllowedUpdate::Message]);
cb86e770f9 2022-03-15        arcade: 
cb86e770f9 2022-03-15        arcade: 	task::block_on(async {
cb86e770f9 2022-03-15        arcade: 		let mut reply_to: Option<telegram_bot::UserId>;
cb86e770f9 2022-03-15        arcade: 		loop {
cb86e770f9 2022-03-15        arcade: 			reply_to = None;
cb86e770f9 2022-03-15        arcade: 			match stream.next().await {
cb86e770f9 2022-03-15        arcade: 				Some(update) => {
cb86e770f9 2022-03-15        arcade: 					if let Err(err) = handle(update?, &core, &reply_to).await {
cb86e770f9 2022-03-15        arcade: 						core.send(&format!("🛑 {:?}", err), reply_to, None).await?;
cb86e770f9 2022-03-15        arcade: 					};
cb86e770f9 2022-03-15        arcade: 				},
cb86e770f9 2022-03-15        arcade: 				None => {
cb86e770f9 2022-03-15        arcade: 					core.send("🛑 None error.", None, None).await?;
cb86e770f9 2022-03-15        arcade: 				}
cb86e770f9 2022-03-15        arcade: 			};
cb86e770f9 2022-03-15        arcade: 		}
cb86e770f9 2022-03-15        arcade: 	})
a7f91033c0 2021-11-13        arcade: }
a7f91033c0 2021-11-13        arcade: 
a7f91033c0 2021-11-13        arcade: async fn handle(update: telegram_bot::Update, core: &core::Core, mut _reply_to: &Option<telegram_bot::UserId>) -> Result<()> {
f988dfd28f 2022-02-13        arcade: 	if let telegram_bot::UpdateKind::Message(message) = update.kind {
b543dce9f7 2024-08-03        arcade: 		if let Some(from) = message.from {
b543dce9f7 2024-08-03        arcade: 			if let telegram_bot::MessageKind::BotCommand { ref cmd_str, .. } = message.kind {
79c91a5357 2024-08-02        arcade: 				let sender = from.id;
b543dce9f7 2024-08-03        arcade: 				let words: Vec<&str> = cmd_str.split_whitespace().collect();
79c91a5357 2024-08-02        arcade: 				if let Err(err) = match words[0] {
79c91a5357 2024-08-02        arcade: 					"/check" | "/clean" | "/enable" | "/delete" | "/disable" => command::command(core, sender, words).await,
79c91a5357 2024-08-02        arcade: 					"/start" => command::start(core, sender).await,
79c91a5357 2024-08-02        arcade: 					"/list" => command::list(core, sender).await,
79c91a5357 2024-08-02        arcade: 					"/add" | "/update" => command::update(core, sender, words).await,
79c91a5357 2024-08-02        arcade: 					_ => Ok(()),
79c91a5357 2024-08-02        arcade: 				} {
79c91a5357 2024-08-02        arcade: 					core.send(format!("🛑 {:?}", err), Some(sender), None).await?;
79c91a5357 2024-08-02        arcade: 				};
f988dfd28f 2022-02-13        arcade: 			};
f988dfd28f 2022-02-13        arcade: 		};
4acdad1942 2020-11-26        arcade: 	};
61df933942 2020-11-18        arcade: 
61df933942 2020-11-18        arcade: 	Ok(())
61df933942 2020-11-18        arcade: }