Last active
May 18, 2021 07:28
-
-
Save WaffleLapkin/2126bcc88eb23c42d70e09d5f29b565e to your computer and use it in GitHub Desktop.
Example of sending files for https://github.com/teloxide/teloxide/issues/384
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [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