pub struct StringCommandHandler { /* private fields */ }Expand description
Handler that matches messages whose text starts with /command.
Unlike CommandHandler, this handler does not
require the message to have a bot_command entity. It performs a plain
string prefix check on the message text.
§Matching rules
- The update must carry an effective message with non-empty
text. - The text must start with
/<command>(case-sensitive). - Arguments are the remaining words after the command.
Implementations§
Source§impl StringCommandHandler
impl StringCommandHandler
Sourcepub fn new(command: String, callback: HandlerCallback, block: bool) -> Self
pub fn new(command: String, callback: HandlerCallback, block: bool) -> Self
Create a new StringCommandHandler.
Trait Implementations§
Source§impl Handler for StringCommandHandler
impl Handler for StringCommandHandler
Source§fn check_update(&self, update: &Update) -> Option<MatchResult>
fn check_update(&self, update: &Update) -> Option<MatchResult>
Determine whether this handler is interested in
update. Read moreSource§fn handle_update(
&self,
update: Arc<Update>,
match_result: MatchResult,
) -> Pin<Box<dyn Future<Output = HandlerResult> + Send>>
fn handle_update( &self, update: Arc<Update>, match_result: MatchResult, ) -> Pin<Box<dyn Future<Output = HandlerResult> + Send>>
Process the update. Called only when
check_update
returned Some.Source§fn block(&self) -> bool
fn block(&self) -> bool
Whether the application should block on this handler’s future before
dispatching to the next handler group.
Source§fn collect_additional_context(
&self,
_context: &mut CallbackContext,
_match_result: &MatchResult,
)
fn collect_additional_context( &self, _context: &mut CallbackContext, _match_result: &MatchResult, )
Populate additional context fields (e.g.
context.args, context.matches)
from the match result before the handler callback is invoked. Read moreSource§fn handle_update_with_context(
&self,
update: Arc<Update>,
match_result: MatchResult,
_context: CallbackContext,
) -> Pin<Box<dyn Future<Output = HandlerResult> + Send>>
fn handle_update_with_context( &self, update: Arc<Update>, match_result: MatchResult, _context: CallbackContext, ) -> Pin<Box<dyn Future<Output = HandlerResult> + Send>>
Process the update with an Application-provided
CallbackContext. Read moreAuto Trait Implementations§
impl Freeze for StringCommandHandler
impl !RefUnwindSafe for StringCommandHandler
impl Send for StringCommandHandler
impl Sync for StringCommandHandler
impl Unpin for StringCommandHandler
impl UnsafeUnpin for StringCommandHandler
impl !UnwindSafe for StringCommandHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more