Skip to content

send message to a user #211

Answered by HeySreelal
paulobreim asked this question in Q&A
Sep 8, 2022 · 3 comments · 10 replies
Discussion options

You must be logged in to vote

Hey, the TeleDartMessage.reply method is used to reply to the chat where the message is sent that is if the chat is a group chat, the bot will reply to the group itself.

Anyway, you can use the TeleDart.sendMessage method to send messages to your bot users. Just pass the user's chat_id as a parameter to the sendMessage method.

⚠️ The only thing you must remember is that the user must have initiated the chat. (Telegram bots cannot start the chat with users).

So, probably this snippet is what you might be looking for:

teleDart.onMessage().listen((message) {
  teleDart.sendMessage(message.from?.id, "Your reply");
});

Once again, this will throw an error if the user hasn't chatted with the bo…

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
2 replies
@paulobreim
Comment options

@HeySreelal
Comment options

Answer selected by paulobreim
Comment options

You must be logged in to vote
4 replies
@DinoLeung
Comment options

@paulobreim
Comment options

@DinoLeung
Comment options

@paulobreim
Comment options

Comment options

You must be logged in to vote
4 replies
@HeySreelal
Comment options

@paulobreim
Comment options

@DinoLeung
Comment options

@paulobreim
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants