Annotation For src/main.rs
Logged in as anonymous

Lines of src/main.rs from check-in f988dfd28f that are changed by the sequence of edits moving toward check-in 26339860ce:

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