use tbot::{
prelude::*,
types::input_file::{Animation, Document, Photo, Video},
};
const PHOTO: &[u8] = include_bytes!("./assets/photo.jpg");
const GIF: &[u8] = include_bytes!("./assets/gif.mp4");
const TUTORIAL: &[u8] = include_bytes!("./tutorial.rs");
#[tokio::main]
async fn main() {
let mut bot = tbot::from_env!("BOT_TOKEN").event_loop();
bot.command("photo", |context| {
async move {
let photo = Photo::bytes(PHOTO);
let call_result = context.send_photo(photo).call().await;
if let Err(err) = call_result {
dbg!(err);
}
}
});
bot.command("animation", |context| {
async move {
let animation = Animation::bytes(GIF);
let call_result = context.send_animation(animation).call().await;
if let Err(err) = call_result {
dbg!(err);
}
}
});
bot.command("document", |context| {
async move {
let document = Document::bytes("tutorial.rs", TUTORIAL);
let call_result = context.send_document(document).call().await;
if let Err(err) = call_result {
dbg!(err);
}
}
});
bot.command("video", |context| {
async move {
let video = Video::bytes(GIF);
let call_result = context.send_video(video).call().await;
if let Err(err) = call_result {
dbg!(err);
}
}
});
bot.command("album", |context| {
async move {
let album = &[Photo::bytes(PHOTO).into(), Video::bytes(GIF).into()];
let call_result = context.send_media_group(album).call().await;
if let Err(err) = call_result {
dbg!(err);
}
}
});
bot.polling().start().await.unwrap();
}