aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Perry <avaglir@gmail.com>2019-04-09 01:58:05 -0400
committerNathan Perry <avaglir@gmail.com>2019-04-09 01:58:05 -0400
commit0a1ce5c5bb1bd6174e12bba971ebd8b3bc451b41 (patch)
tree2c3e569cf5fdb6d07bfb18d50ea5f3cfd21f3c33
parent2b05cde092d0bfde28739f2f8e1ee0ab4deae181 (diff)
only random-tts if meme has text
-rw-r--r--src/commands/meme/mod.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/commands/meme/mod.rs b/src/commands/meme/mod.rs
index ce1cb48..3738eab 100644
--- a/src/commands/meme/mod.rs
+++ b/src/commands/meme/mod.rs
@@ -29,18 +29,20 @@ mod invoke;
mod delete;
fn send_meme(ctx: &Context, t: &Meme, conn: &PgConnection, msg: &Message) -> Result<()> {
- debug!("sending meme: {:?}", t);
+ let should_tts = t.content.as_ref().map(|t| t.len() > 0).unwrap_or(false) &&
+ thread_rng().gen::<u32>() % 25 == 0;
+
+ debug!("sending meme (tts: {}): {:?}", should_tts, t);
let image = t.image(conn);
let audio = t.audio(conn);
let create_msg = |m: CreateMessage| {
- let ret = m
- .tts(thread_rng().gen::<u32>() % 25 == 0);
+ let ret = m.tts(should_tts);
match t.content {
- Some(ref text) => ret.content(text),
- None => ret,
+ Some(ref text) if text.len() > 0 => ret.content(text),
+ _ => ret,
}
};