Add Box::ctx shortcut

This commit is contained in:
Waffle 2019-09-13 01:05:22 +03:00
parent 300a3cb285
commit fedc346e23

View file

@ -23,15 +23,19 @@ impl Bot {
client,
}
}
fn ctx(&self) -> RequestContext {
RequestContext {
token: &self.token,
client: &self.client,
}
}
}
/// Telegram functions
impl Bot {
pub fn get_me(&self) -> GetMe {
GetMe::new(RequestContext {
token: &self.token,
client: &self.client,
})
GetMe::new(self.ctx())
}
pub fn send_message<C, T>(&self, chat_id: C, text: T) -> SendMessage
@ -40,10 +44,7 @@ impl Bot {
T: Into<String>,
{
SendMessage::new(
RequestContext {
token: &self.token,
client: &self.client,
},
self.ctx(),
chat_id.into(),
text.into(),
)