Function teloxide::utils::command::parse_command [−][src]
pub fn parse_command<N>(text: &str, bot_name: N) -> Option<(&str, Vec<&str>)> where
N: AsRef<str>,
Parses a string into a command with args.
This function is just a shortcut for calling parse_command_with_prefix
with the default prefix /
.
Example
use teloxide::utils::command::parse_command; let text = "/mute@my_admin_bot 5 hours"; let (command, args) = parse_command(text, "my_admin_bot").unwrap(); assert_eq!(command, "mute"); assert_eq!(args, vec!["5", "hours"]);
If the name of a bot does not match, it will return None
:
use teloxide::utils::command::parse_command; let result = parse_command("/ban@MyNameBot1 3 hours", "MyNameBot2"); assert!(result.is_none());