J
J
judywb2020-12-30 17:25:33
C++ / C#
judywb, 2020-12-30 17:25:33

How to send a text message using Telegram.Bot?

Hello
Library - Telegram.bot
.net framework
How to make the bot send a message when running the script.
That is, the bot did not wait for any command, but simply immediately sent the text.
I can send the first message, but the bot must act without outside interference.
I ran the script, a message was sent
How to do this? Please post a piece of code if possible. Or anything at all to write it

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasily Bannikov, 2020-12-30
@vabka

Something like this:

var bot = new Telegram.Bot.TelegramBotClient("token");
await bot.SendTextMessageAsync(new ChatId("username"), "Hello world");

X
xxxfdd, 2020-12-31
@xxxfdd

Look, you will find out the id of the person who needs to send a message and insert this id instead of id )))
bot.send_message(id, 'Any text' )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question