Only execute lines with commands.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
Fixes #45 and #46.
This commit is contained in:
parent
0e04e67f6e
commit
e251294b5f
|
@ -124,14 +124,14 @@ impl DiceBot {
|
||||||
|
|
||||||
let mut results = Vec::with_capacity(msg_body.lines().count());
|
let mut results = Vec::with_capacity(msg_body.lines().count());
|
||||||
|
|
||||||
for command in msg_body.lines() {
|
let commands = msg_body.trim().lines().filter(|line| line.starts_with("!"));
|
||||||
if !command.is_empty() {
|
|
||||||
|
for command in commands {
|
||||||
let ctx = Context::new(&self.db, &room_id.as_str(), &sender_username, &command);
|
let ctx = Context::new(&self.db, &room_id.as_str(), &sender_username, &command);
|
||||||
if let Some(cmd_result) = execute_command(&ctx).await {
|
if let Some(cmd_result) = execute_command(&ctx).await {
|
||||||
results.push(cmd_result);
|
results.push(cmd_result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if results.len() >= 1 {
|
if results.len() >= 1 {
|
||||||
if results.len() == 1 {
|
if results.len() == 1 {
|
||||||
|
|
Loading…
Reference in New Issue