Skip to content

Commit

Permalink
Don't double-post in DMs
Browse files Browse the repository at this point in the history
If we're replying to a log in DMs,
we don't also want to tell the user about the bot.
  • Loading branch information
Scotsguy committed Nov 30, 2019
1 parent 6c61d6b commit 3c939a0
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,6 @@ impl EventHandler for Handler {
return;
}

if msg.is_private() {
if let Err(why) = msg.channel_id.send_message(&ctx.http, |m| {
m.embed(|e| {
e.title("<:backgroundcat:280120125284417536>A bot to parse logfiles on the MultiMC discord<:backgroundcat:280120125284417536>");
#[allow(clippy::unreadable_literal)]
let creator_name = match UserId::from(185461862878543872).to_user(&ctx) {
Ok(o) => o.tag(),
Err(why) => {error!("Couldn't get info about creator: {}", why); "<Error getting name>".to_string()}
};
e.colour(Colour::DARK_TEAL);
e.description(format!(r"
Developed by {}.
To start, just post a https://paste.ee link in the Discord.
[Source Code available under AGPLv3](https://gitlab.com/Scotsguy/background-cat)
", creator_name));
e
});
m
}) {
error!("Couldn't send info message: {}", why)
}
}

lazy_static! {
static ref PASTEE_REGEX: Regex = Regex::new(r"https:/{2}paste.ee/p/[^\s/]+").unwrap();
}
Expand Down Expand Up @@ -115,7 +91,32 @@ impl EventHandler for Handler {
}) {
error!("Couldn't send message: {}", why)
}
return;
};

if msg.is_private() {
if let Err(why) = msg.channel_id.send_message(&ctx.http, |m| {
m.embed(|e| {
e.title("<:backgroundcat:280120125284417536>A bot to parse logfiles on the MultiMC discord<:backgroundcat:280120125284417536>");
#[allow(clippy::unreadable_literal)]
let creator_name = match UserId::from(185461862878543872).to_user(&ctx) {
Ok(o) => o.tag(),
Err(why) => {error!("Couldn't get info about creator: {}", why); "<Error getting name>".to_string()}
};
e.colour(Colour::DARK_TEAL);
e.description(format!(r"
Developed by {}.
To start, just post a https://paste.ee link in the Discord.
[Source Code available under AGPLv3](https://gitlab.com/Scotsguy/background-cat)
", creator_name));
e
});
m
}) {
error!("Couldn't send info message: {}", why)
}
}
}

// TODO: delete on reaction
Expand Down

0 comments on commit 3c939a0

Please sign in to comment.