sochix / TLSharp

Telegram client library implemented in C#
1.01k stars 380 forks source link

Send/Get message to/from Bot #846

Open mrSkyMan opened 5 years ago

mrSkyMan commented 5 years ago

Hello. How can I send a message to the bot and get a response from him?

avdynut commented 4 years ago

To send a message: var dialogsResult = (TLDialogs) await _client.GetUserDialogsAsync(); var users = dialogsResult.Users.OfType<TLUser>(); var bot = users.FirstOrDefault(x => x.Username == "BotUsername"); var peer = new TLInputPeerUser { UserId = bot.Id, AccessHash = bot.AccessHash.Value }; var result = await _client.SendMessageAsync(peer, "message");