aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorJokler <jokler@protonmail.com>2020-01-16 19:06:04 +0100
committerGitHub <noreply@github.com>2020-01-16 19:06:04 +0100
commitfbaa817578faf46242d4400aeaba4bea37317cd1 (patch)
treecb261f1b02e7c7c245c7878e70f4b839b79156c7 /src/main.rs
parent41689b929336ff4b5f09d9850113787ba0f6d241 (diff)
downloadpokebot-fbaa817578faf46242d4400aeaba4bea37317cd1.tar.gz
pokebot-fbaa817578faf46242d4400aeaba4bea37317cd1.zip
Revert chat command syntax and add skip alias (#9)
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs
index 0ba8e34..d1b34df 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -170,14 +170,16 @@ impl Application {
async fn on_text(&self, message: Message) -> Result<(), AudioPlayerError> {
let msg = message.text;
- if msg.starts_with("poke") {
- let tokens = msg.split_whitespace().collect::<Vec<_>>();
-
- let args = Command::from_iter_safe(&tokens);
- match args {
- Ok(v) => self.on_command(v).await?,
- Err(e) => self.send_message(&format!("\n{}", e.message)),
- };
+ if msg.starts_with("!") {
+ let tokens = msg[1..].split_whitespace().collect::<Vec<_>>();
+
+ match Command::from_iter_safe(&tokens) {
+ Ok(args) => self.on_command(args).await?,
+ Err(e) if e.kind == structopt::clap::ErrorKind::HelpDisplayed => {
+ self.send_message(&format!("\n{}", e.message));
+ }
+ _ => (),
+ }
}
Ok(())