pub struct HttpTelegramBot { /* private fields */ }Expand description
TelegramBot over the Telegram Bot API: POST {base}/bot{token}/{method}
with a JSON body, through the runtime’s HttpClient port.
No Debug derive: the token is a struct field, and a derived Debug
would print it wherever a log line met the adapter. The hand-written one
prints a placeholder instead.
Implementations§
Source§impl HttpTelegramBot
impl HttpTelegramBot
Sourcepub fn new(
http: Arc<dyn HttpClient>,
clock: Arc<dyn Clock>,
bot_token: impl Into<String>,
) -> Self
pub fn new( http: Arc<dyn HttpClient>, clock: Arc<dyn Clock>, bot_token: impl Into<String>, ) -> Self
A bot pointed at Telegram under bot_token.
Sourcepub fn with_base(self, base_url: impl Into<String>) -> Self
pub fn with_base(self, base_url: impl Into<String>) -> Self
Overrides the root every request is posted to — a fake in tests —
instead of https://api.telegram.org.
Sourcepub fn with_limits(self, limits: RateLimits) -> Self
pub fn with_limits(self, limits: RateLimits) -> Self
Replaces the rate budgets with limits, discarding the tokens the
old budgets had accrued and any 429 deadlines. Chain after new.
Sourcepub async fn set_webhook(
&self,
url: &str,
secret_token: &str,
allowed_updates: &[&str],
) -> Result<(), TelegramError>
pub async fn set_webhook( &self, url: &str, secret_token: &str, allowed_updates: &[&str], ) -> Result<(), TelegramError>
Registers url as the bot’s webhook with secret_token in
webhook::SECRET_HEADER and the
named update types delivered. An empty url deletes the webhook.
Counted against the global budget only: there is no chat to scope a per-chat bucket to, and a 429 here has nothing to remember one for.
§Errors
TelegramError::Invalid for a url that is neither https nor a
localhost http (the one exception Telegram allows), a secret
outside Telegram’s alphabet, or a bot token that is not shaped like
one; otherwise the same mapping as TelegramBot::send_message.
Trait Implementations§
Source§impl Debug for HttpTelegramBot
impl Debug for HttpTelegramBot
Source§impl TelegramBot for HttpTelegramBot
impl TelegramBot for HttpTelegramBot
Source§fn send_message<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 OutgoingMessage,
) -> Pin<Box<dyn Future<Output = Result<SentMessage, TelegramError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send_message<'life0, 'life1, 'async_trait>(
&'life0 self,
message: &'life1 OutgoingMessage,
) -> Pin<Box<dyn Future<Output = Result<SentMessage, TelegramError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn edit_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
chat_id: i64,
message_id: i64,
text: &'life1 str,
buttons: &'life2 [Vec<InlineButton>],
) -> Pin<Box<dyn Future<Output = Result<(), TelegramError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn edit_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
chat_id: i64,
message_id: i64,
text: &'life1 str,
buttons: &'life2 [Vec<InlineButton>],
) -> Pin<Box<dyn Future<Output = Result<(), TelegramError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
buttons removes the keyboard). Read moreSource§fn delete_message<'life0, 'async_trait>(
&'life0 self,
chat_id: i64,
message_id: i64,
) -> Pin<Box<dyn Future<Output = Result<(), TelegramError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete_message<'life0, 'async_trait>(
&'life0 self,
chat_id: i64,
message_id: i64,
) -> Pin<Box<dyn Future<Output = Result<(), TelegramError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn answer_callback<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
callback_query_id: &'life1 str,
text: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<(), TelegramError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn answer_callback<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
callback_query_id: &'life1 str,
text: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<(), TelegramError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
text as a toast
to the user who pressed the button. Read more