onMessage method
Listen to message events with entityType
and keyword
in text and caption
entityType
include mention
(@username), hashtag
(#hashtag), cashtag
($USD),
bot_command
(/start@jobs_bot), url
(https://telegram.org/),
email
(do-not-reply@telegram.org), phone_number
(+1-212-555-0123), bold
(bold text),
italic
(italic text), underline
(underlined text), strikethrough
(strikethrough text),
code
(monowidth string), pre
(monowidth block), text_link
(for
clickable text URLs), text_mention
(for users without usernames)
Omitting entityType
or passing null will results listening to messages with no entityType
.
To listen to messages of all entityType
, pass *
as entityType
.
Normal message has NO entityType
Normal message accepts regular expressions as keyword
To listen to /start
onMessage(entityType: 'bot_command', keyword: 'start').listen((message) =>
teledart.telegram.sendMessage(message.chat.id, 'hello world!'));
Implementation
Stream<TeleDartMessage> onMessage({String? entityType, dynamic keyword}) =>
_event
.onMessage(entityType: entityType, keyword: keyword)
.map(_messageStreamMapper);