Annotation For src/tg_bot.rs
Logged in as anonymous

Lines of src/tg_bot.rs from check-in 9c4f09193a that are changed by the sequence of edits moving toward check-in fabcca1eaf:

                         1: use stacked_errors::{
                         2: 	Result,
                         3: 	StackableErr,
                         4: };
                         5: use tgbot::{
                         6: 	api::Client,
                         7: 	types::{
                         8: 		Bot,
                         9: 		ChatPeerId,
                        10: 		GetBot,
                        11: 		Message,
                        12: 		ParseMode,
                        13: 		SendMessage,
                        14: 	},
                        15: };
                        16: 
                        17: #[derive(Clone)]
                        18: pub struct Tg {
                        19: 	pub me: Bot,
                        20: 	pub owner: ChatPeerId,
                        21: 	pub client: Client,
                        22: }
                        23: 
                        24: impl Tg {
                        25: 	pub async fn new (settings: &config::Config) -> Result<Tg> {
                        26: 		let api_key = settings.get_string("api_key").stack()?;
                        27: 
                        28: 		let owner = ChatPeerId::from(settings.get_int("owner").stack()?);
                        29: 		let client = Client::new(&api_key).stack()?
                        30: 			.with_host(settings.get_string("api_gateway").stack()?)
                        31: 			.with_max_retries(0);
                        32: 		let me = client.execute(GetBot).await.stack()?;
                        33: 		Ok(Tg {
                        34: 			me,
                        35: 			owner,
                        36: 			client,
                        37: 		})
                        38: 	}
                        39: 
                        40: 	pub async fn send <S>(&self, msg: S, target: Option<ChatPeerId>, mode: Option<ParseMode>) -> Result<Message>
                        41: 	where S: Into<String> {
                        42: 		let msg = msg.into();
                        43: 
                        44: 		let mode = mode.unwrap_or(ParseMode::Html);
                        45: 		let target = target.unwrap_or(self.owner);
                        46: 		self.client.execute(
                        47: 			SendMessage::new(target, msg)
                        48: 				.with_parse_mode(mode)
                        49: 		).await.stack()
                        50: 	}
                        51: 
9c4f09193a 2026-01-09   52: 	pub fn with_owner (&self, owner: i64) -> Tg {
                        53: 		Tg {
9c4f09193a 2026-01-09   54: 			owner: ChatPeerId::from(owner),
                        55: 			..self.clone()
                        56: 		}
                        57: 	}
                        58: }