mirror of
https://github.com/yawaflua/Telegram.Net.git
synced 2025-12-10 04:29:28 +02:00
Create project
This commit is contained in:
40
Examples/Telegram.Examples/UpdatePolling/Update.cs
Normal file
40
Examples/Telegram.Examples/UpdatePolling/Update.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Net.Attributes;
|
||||
using Telegram.Net.Interfaces;
|
||||
|
||||
namespace Telegram.Examples.UpdatePolling;
|
||||
|
||||
public class Update : IUpdatePollingSerivce
|
||||
{
|
||||
[Update]
|
||||
public async Task UpdateExample(ITelegramBotClient client, Bot.Types.Update update, CancellationToken ctx)
|
||||
{
|
||||
if (update.Poll != null)
|
||||
{
|
||||
Console.WriteLine(update.Poll.IsClosed);
|
||||
}
|
||||
}
|
||||
|
||||
[Callback("act-")]
|
||||
public async Task CallbackExample(ITelegramBotClient client, CallbackQuery query, CancellationToken ctx)
|
||||
{
|
||||
Console.WriteLine(query.Message!.Text);
|
||||
}
|
||||
|
||||
[Command("/start")]
|
||||
public async Task StartCommand(ITelegramBotClient client, Message message, CancellationToken ctx)
|
||||
{
|
||||
if (message.Text!.Contains(" ") && message.Text.Split(" ")[1] == "test")
|
||||
await client.SendMessage(message.From!.Id, "Hello, I`m example bot. And this - command with subparam", cancellationToken: ctx);
|
||||
else
|
||||
await client.SendMessage(message.From!.Id, "Hello, I`m example bot.", cancellationToken: ctx);
|
||||
}
|
||||
|
||||
[EditMessage]
|
||||
public async Task EditMessageExmaple(ITelegramBotClient client, Message message, CancellationToken ctx)
|
||||
{
|
||||
Console.WriteLine($"new message text: {message.Text}");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user