Merge pull request #35 from teloxide/bot_name_and_str

adapt to teloxide changes
This commit is contained in:
Waffle Maybe 2022-10-06 15:29:20 +04:00 committed by GitHub
commit 5d6cce4121
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View file

@ -18,4 +18,4 @@ heck = "0.4.0"
[dev-dependencies]
# XXX: Do not enable `macros` feature
teloxide = { git = "https://github.com/teloxide/teloxide.git", rev = "4246455" }
teloxide = { git = "https://github.com/teloxide/teloxide.git", rev = "b5e237a8a22f9f987b6e4245b9b6c3ca1f804c19" }

View file

@ -102,10 +102,7 @@ fn impl_parse(
let matching_values = infos.iter().map(|c| c.get_prefixed_command());
quote! {
fn parse<N>(s: &str, bot_name: N) -> Result<Self, teloxide::utils::command::ParseError>
where
N: Into<String>
{
fn parse(s: &str, bot_name: &str) -> Result<Self, teloxide::utils::command::ParseError> {
// FIXME: we should probably just call a helper function from `teloxide`, instead of parsing command syntax ourselves
use std::str::FromStr;
use teloxide::utils::command::ParseError;
@ -121,7 +118,7 @@ fn impl_parse(
let bot_username = full_command.next();
match bot_username {
None => {}
Some(username) if username.eq_ignore_ascii_case(&bot_name.into()) => {}
Some(username) if username.eq_ignore_ascii_case(bot_name) => {}
Some(n) => return Err(ParseError::WrongBotName(n.to_owned())),
}