Annotation For src/main.rs
Logged in as anonymous

Lines of src/main.rs from check-in a7f91033c0 that are changed by the sequence of edits moving toward check-in 4632d20d39:

                         1: mod command;
                         2: mod core;
                         3: 
                         4: use config;
                         5: use futures::StreamExt;
                         6: use tokio;
                         7: use telegram_bot;
                         8: 
                         9: #[macro_use]
                        10: extern crate lazy_static;
                        11: 
                        12: use anyhow::Result;
                        13: 
                        14: #[tokio::main]
                        15: async fn main() -> Result<()> {
                        16: 	let mut settings = config::Config::default();
                        17: 	settings.merge(config::File::with_name("rsstg"))?;
                        18: 
                        19: 	let core = core::Core::new(settings).await?;
                        20: 
                        21: 	let mut stream = core.stream();
                        22: 	stream.allowed_updates(&[telegram_bot::AllowedUpdate::Message]);
                        23: 	let mut reply_to: Option<telegram_bot::UserId>;
                        24: 
                        25: 	loop {
                        26: 		reply_to = None;
                        27: 		match stream.next().await {
                        28: 			Some(update) => {
                        29: 				if let Err(err) = handle(update?, &core, &mut reply_to).await {
                        30: 					core.send(&format!("🛑 {:?}", err), reply_to, None)?;
                        31: 				};
                        32: 			},
                        33: 			None => {
                        34: 				core.send(&format!("🛑 None error."), None, None)?;
                        35: 			}
                        36: 		};
                        37: 	}
                        38: 
                        39: 	//Ok(())
                        40: }
                        41: 
                        42: async fn handle(update: telegram_bot::Update, core: &core::Core, mut _reply_to: &Option<telegram_bot::UserId>) -> Result<()> {
                        43: 	match update.kind {
                        44: 		telegram_bot::UpdateKind::Message(message) => {
                        45: 			match message.kind {
                        46: 				telegram_bot::MessageKind::Text { ref data, .. } => {
                        47: 					let sender = message.from.id;
                        48: 					let words: Vec<&str> = data.split_whitespace().collect();
a7f91033c0 2021-11-13   49: 					match words[0] {
a7f91033c0 2021-11-13   50: 						"/check" | "/clean" | "/enable" | "/delete" | "/disable" => command::command(core, sender, words).await?,
a7f91033c0 2021-11-13   51: 						"/start" => command::start(core, sender).await?,
a7f91033c0 2021-11-13   52: 						"/list" => command::list(core, sender).await?,
a7f91033c0 2021-11-13   53: 						"/add" | "/update" => command::update(core, sender, words).await?,
a7f91033c0 2021-11-13   54: 						_ => {
a7f91033c0 2021-11-13   55: 						},
                        56: 					};
                        57: 				},
                        58: 				_ => {
                        59: 				},
                        60: 			};
                        61: 		},
                        62: 		_ => {},
                        63: 	};
                        64: 
                        65: 	Ok(())
                        66: }