Add discord upload support
This commit is contained in:
parent
dd020543de
commit
2f13d0011c
14
src/main.rs
14
src/main.rs
@ -50,11 +50,14 @@ impl EventHandler for Handler {
|
|||||||
wc_info(msg);
|
wc_info(msg);
|
||||||
} else if msg.content.starts_with("wc!crop ") {
|
} else if msg.content.starts_with("wc!crop ") {
|
||||||
wc_crop(msg);
|
wc_crop(msg);
|
||||||
|
} else if msg.content == "wc!crop" {
|
||||||
|
wc_crop_discord_upload(msg);
|
||||||
} else if msg.content == "wc!warfeed" {
|
} else if msg.content == "wc!warfeed" {
|
||||||
wc_warfeed(msg);
|
wc_warfeed(msg);
|
||||||
} else if msg.content == "wc!unwarfeed" {
|
} else if msg.content == "wc!unwarfeed" {
|
||||||
wc_unwarfeed(msg);
|
wc_unwarfeed(msg);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set a handler to be called on the `on_ready` event. This is called when a
|
// 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();
|
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() {
|
fn territory_livefeed() {
|
||||||
use models::LivefeedListener;
|
use models::LivefeedListener;
|
||||||
use schema::livefeedlisteners::dsl::*;
|
use schema::livefeedlisteners::dsl::*;
|
||||||
@ -380,7 +392,6 @@ fn main() {
|
|||||||
env::var("DATABASE_URL")
|
env::var("DATABASE_URL")
|
||||||
.expect("DATABASE_URL must be set");
|
.expect("DATABASE_URL must be set");
|
||||||
|
|
||||||
/*
|
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.spawn(|| {
|
.spawn(|| {
|
||||||
loop {
|
loop {
|
||||||
@ -388,7 +399,6 @@ fn main() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
*/
|
|
||||||
|
|
||||||
thread::Builder::new()
|
thread::Builder::new()
|
||||||
.spawn(|| {
|
.spawn(|| {
|
||||||
|
Loading…
Reference in New Issue
Block a user