Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net.Http;
- using System.Threading.Tasks;
- using Newtonsoft.Json;
- namespace TelegramBot
- {
- class Program
- {
- static async Task Main(string[] args)
- {
- var botToken = "ТОКЕН_ТВОЕГО_БОТА";
- var httpClient = new HttpClient();
- var chatId = "ID_ЧАТА_ПОЛЬЗОВАТЕЛЯ";
- var message = "Привет, я ChatGPT! Чем могу помочь?";
- var url = $"https://api.telegram.org/bot{botToken}/sendMessage?chat_id={chatId}&text={message}";
- var response = await httpClient.GetAsync(url);
- var content = await response.Content.ReadAsStringAsync();
- var result = JsonConvert.DeserializeObject<dynamic>(content);
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement