Skip to content

Instantly share code, notes, and snippets.

@WaffleLapkin
Last active May 18, 2021 07:28
Show Gist options
  • Save WaffleLapkin/2126bcc88eb23c42d70e09d5f29b565e to your computer and use it in GitHub Desktop.
Save WaffleLapkin/2126bcc88eb23c42d70e09d5f29b565e to your computer and use it in GitHub Desktop.
// [dependencies]
// reqwest = "0.11"
// teloxide = "0.4"
// tokio = { version = "1.6", features = ["macros", "rt-multi-thread"] }
#[tokio::main]
async fn main() {
run().await;
}
async fn run() {
use teloxide::requests::{Request, Requester};
let pic_url =
"https://cdn.discordapp.com/attachments/536882422848159784/542784769646264352/unknown.png";
let token = "TOKEN";
let chat = 218485655i64;
let rsp = reqwest::get(pic_url).await.expect("Network Error");
let body = rsp.bytes().await.expect("No body?");
let pic = body.as_ref().to_vec();
let bot = teloxide::Bot::new(token);
bot.send_photo(chat, teloxide::types::InputFile::memory("unknown.png", pic))
.send()
.await
.expect("Failed to send request");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment