Struct BotWrapper

Source
pub struct BotWrapper<B: BotHandler> { /* private fields */ }

Implementations§

Source§

impl BotWrapper<NoBotHandler>

Source

pub fn new(token: String) -> BotWrapper<NoBotHandler>

Examples found in repository?
examples/hello.rs (line 7)
5fn main() {
6    let token = env::var("TELEGRAM_BOT_KEY").expect("TELEGRAM_BOT_KEY not found in env");
7    let mut bot = BotWrapper::new(token);
8    bot.command("hello".into(), |api, msg| {
9        api.spawn(msg.text_reply(format!("Hello, {}!", &msg.from.first_name)));
10    });
11
12    bot.run();
13}
Source§

impl<B: BotHandler> BotWrapper<B>

Source

pub fn new_with_handler(token: String, handler: B) -> BotWrapper<B>

Examples found in repository?
examples/inline_query.rs (line 32)
30fn main() {
31    let token = env::var("TELEGRAM_BOT_KEY").expect("TELEGRAM_BOT_KEY not found in env");
32    let bot = BotWrapper::new_with_handler(token, MyBot);
33    bot.run();
34}
Source

pub fn run(self)

Examples found in repository?
examples/inline_query.rs (line 33)
30fn main() {
31    let token = env::var("TELEGRAM_BOT_KEY").expect("TELEGRAM_BOT_KEY not found in env");
32    let bot = BotWrapper::new_with_handler(token, MyBot);
33    bot.run();
34}
More examples
Hide additional examples
examples/hello.rs (line 12)
5fn main() {
6    let token = env::var("TELEGRAM_BOT_KEY").expect("TELEGRAM_BOT_KEY not found in env");
7    let mut bot = BotWrapper::new(token);
8    bot.command("hello".into(), |api, msg| {
9        api.spawn(msg.text_reply(format!("Hello, {}!", &msg.from.first_name)));
10    });
11
12    bot.run();
13}
Source

pub fn command<F>(&mut self, command: String, handle: F)
where F: 'static + Fn(&Api, &Message),

Examples found in repository?
examples/hello.rs (lines 8-10)
5fn main() {
6    let token = env::var("TELEGRAM_BOT_KEY").expect("TELEGRAM_BOT_KEY not found in env");
7    let mut bot = BotWrapper::new(token);
8    bot.command("hello".into(), |api, msg| {
9        api.spawn(msg.text_reply(format!("Hello, {}!", &msg.from.first_name)));
10    });
11
12    bot.run();
13}

Auto Trait Implementations§

§

impl<B> !Freeze for BotWrapper<B>

§

impl<B> !RefUnwindSafe for BotWrapper<B>

§

impl<B> !Send for BotWrapper<B>

§

impl<B> !Sync for BotWrapper<B>

§

impl<B> Unpin for BotWrapper<B>
where B: Unpin,

§

impl<B> !UnwindSafe for BotWrapper<B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.