Untitled
unknown
csharp
a year ago
1.4 kB
9
Indexable
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Telegram.Bot;
namespace TelegramBotExample
{
class Program
{
// Bot tokeninizi buraya ekleyin
private static readonly string BotToken = "YOUR_BOT_TOKEN";
private static readonly TelegramBotClient BotClient = new TelegramBotClient(BotToken);
static async Task Main(string[] args)
{
// Kanal ID'lerini ekleyin (kanal ID'si negatif bir sayı olarak gelir)
List<long> channelIds = new List<long>
{
-1001234567890, // Örnek Kanal 1
-1009876543210 // Örnek Kanal 2
};
// Göndermek istediğiniz mesaj
string message = "Bu otomatik bir mesajdır.";
foreach (var channelId in channelIds)
{
try
{
// Mesaj gönderme işlemi
await BotClient.SendTextMessageAsync(channelId, message);
Console.WriteLine($"Mesaj gönderildi: {channelId}");
}
catch (Exception ex)
{
Console.WriteLine($"Mesaj gönderilemedi: {channelId}. Hata: {ex.Message}");
}
}
Console.WriteLine("Mesaj gönderme işlemi tamamlandı.");
}
}
}Editor is loading...
Leave a Comment