pub struct TelegramGateway { /* private fields */ }Expand description
Owns the Bot API client and the sole getUpdates polling loop.
Create one gateway per bot token and share its Arc with tools and inbound adapters. Interactive replies are correlated by the Telegram message ID they reply to; all other messages are broadcast to normal message handlers.
Implementations§
Source§impl TelegramGateway
impl TelegramGateway
pub fn new(token: &str) -> Arc<Self> ⓘ
pub fn from_env() -> Result<Arc<Self>, TelegramError>
pub fn subscribe(&self) -> Receiver<IncomingMessage>
pub async fn send_message( &self, chat_id: i64, text: &str, ) -> Result<(), TelegramError>
pub async fn notify_user( &self, chat_id: i64, text: &str, ) -> Result<(), TelegramError>
pub async fn ask_text( &self, chat_id: i64, question: &str, timeout: Duration, ) -> Result<String, TelegramError>
pub async fn ask_yes_no( &self, chat_id: i64, question: &str, timeout: Duration, ) -> Result<bool, TelegramError>
Auto Trait Implementations§
impl !Freeze for TelegramGateway
impl !RefUnwindSafe for TelegramGateway
impl !UnwindSafe for TelegramGateway
impl Send for TelegramGateway
impl Sync for TelegramGateway
impl Unpin for TelegramGateway
impl UnsafeUnpin for TelegramGateway
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more