Add discord upload support

This commit is contained in:
Sakuhl 2018-01-12 21:23:27 +01:00
parent dd020543de
commit 2f13d0011c

View File

@ -50,11 +50,14 @@ impl EventHandler for Handler {
wc_info(msg);
} else if msg.content.starts_with("wc!crop ") {
wc_crop(msg);
} else if msg.content == "wc!crop" {
wc_crop_discord_upload(msg);
} else if msg.content == "wc!warfeed" {
wc_warfeed(msg);
} else if msg.content == "wc!unwarfeed" {
wc_unwarfeed(msg);
}
*/
}
// Set a handler to be called on the `on_ready` event. This is called when a
@ -288,6 +291,15 @@ fn wc_crop(msg: Message) {
msg.channel_id.say(&new_url).unwrap();
}
fn wc_crop_discord_upload(msg: Message) {
let last = &msg.channel_id.messages(|g| g.before(msg.id).limit(1)).unwrap()[0];
for attachment in &last.attachments {
let url = &attachment.url;
let new_url = reqwest::get(&format!("https://wynncraft-autocrop.herokuapp.com/crop?url={}", url)).unwrap().text().unwrap();
msg.channel_id.say(&new_url).unwrap();
}
}
fn territory_livefeed() {
use models::LivefeedListener;
use schema::livefeedlisteners::dsl::*;
@ -380,7 +392,6 @@ fn main() {
env::var("DATABASE_URL")
.expect("DATABASE_URL must be set");
/*
thread::Builder::new()
.spawn(|| {
loop {
@ -388,7 +399,6 @@ fn main() {
}
})
.unwrap();
*/
thread::Builder::new()
.spawn(|| {