Advertisement
Andites

Untitled

Apr 4th, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. using System;
  2. using System.Net.Http;
  3. using System.Threading.Tasks;
  4. using Newtonsoft.Json;
  5.  
  6. namespace TelegramBot
  7. {
  8. class Program
  9. {
  10. static async Task Main(string[] args)
  11. {
  12. var botToken = "ТОКЕН_ТВОЕГО_БОТА";
  13. var httpClient = new HttpClient();
  14. var chatId = "ID_ЧАТА_ПОЛЬЗОВАТЕЛЯ";
  15. var message = "Привет, я ChatGPT! Чем могу помочь?";
  16. var url = $"https://api.telegram.org/bot{botToken}/sendMessage?chat_id={chatId}&text={message}";
  17. var response = await httpClient.GetAsync(url);
  18. var content = await response.Content.ReadAsStringAsync();
  19. var result = JsonConvert.DeserializeObject<dynamic>(content);
  20. Console.WriteLine(result);
  21. }
  22. }
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement