mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
work on commands
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace Kruzya.TelegramBot.CustomChatAddOns.Data.InputFile
|
||||
{
|
||||
public interface ICustomInputFile
|
||||
{
|
||||
public IInputFile Convert();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Kruzya.TelegramBot.Core.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace Kruzya.TelegramBot.CustomChatAddOns.Data.InputFile
|
||||
{
|
||||
[AllowedSerializableType("input_id_file")]
|
||||
public class InputIdFile : ICustomInputFile
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
public IInputFile Convert()
|
||||
{
|
||||
return new InputFileId(Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Kruzya.TelegramBot.Core.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace Kruzya.TelegramBot.CustomChatAddOns.Data.InputFile
|
||||
{
|
||||
[AllowedSerializableType("input_url_file")]
|
||||
public class InputUrlFile : ICustomInputFile
|
||||
{
|
||||
[JsonProperty("url")]
|
||||
public string Url { get; set; } = "";
|
||||
|
||||
public IInputFile Convert()
|
||||
{
|
||||
return new InputFileUrl(Url);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Kruzya.TelegramBot.Core.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace Kruzya.TelegramBot.CustomChatAddOns.Data
|
||||
{
|
||||
[AllowedSerializableType("new_message")]
|
||||
public class NewMessage
|
||||
{
|
||||
[JsonProperty("message")]
|
||||
public Message Message { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Newtonsoft.Json;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace Kruzya.TelegramBot.CustomChatAddOns.Data.WebhookCommand
|
||||
{
|
||||
public abstract class BaseReplyMessage
|
||||
{
|
||||
[JsonProperty("content")]
|
||||
public string Content { get; set; }
|
||||
|
||||
[JsonProperty("parse_mode")]
|
||||
public ParseMode? ParseMode { get; set; }
|
||||
|
||||
[JsonProperty("disable_notification")]
|
||||
public bool? DisableNotification { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace Kruzya.TelegramBot.CustomChatAddOns.Data.WebhookCommand
|
||||
{
|
||||
public interface IWebhookCommand
|
||||
{
|
||||
public Task Execute(ITelegramBotClient botClient, Message message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Kruzya.TelegramBot.CustomChatAddOns.Data.InputFile;
|
||||
using Newtonsoft.Json;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace Kruzya.TelegramBot.CustomChatAddOns.Data.WebhookCommand
|
||||
{
|
||||
public class PhotoReplyMessage : BaseReplyMessage, IWebhookCommand
|
||||
{
|
||||
[JsonProperty("photo")]
|
||||
public ICustomInputFile Photo { get; set; }
|
||||
|
||||
public async Task Execute(ITelegramBotClient botClient, Message message)
|
||||
{
|
||||
await botClient.SendPhotoAsync(message.Chat.Id, Photo.Convert(),
|
||||
caption: Content, parseMode: ParseMode,
|
||||
disableNotification: DisableNotification);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Kruzya.TelegramBot.Core.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace Kruzya.TelegramBot.CustomChatAddOns.Data.WebhookCommand
|
||||
{
|
||||
[AllowedSerializableType("text_reply_message")]
|
||||
public class TextReplyMessage : BaseReplyMessage, IWebhookCommand
|
||||
{
|
||||
[JsonProperty("disable_web_page_preview")]
|
||||
public bool? DisableWebPagePreview { get; set; }
|
||||
|
||||
public async Task Execute(ITelegramBotClient botClient, Message message)
|
||||
{
|
||||
await botClient.SendTextMessageAsync(message.Chat.Id, Content,
|
||||
parseMode: ParseMode, disableNotification: DisableNotification,
|
||||
disableWebPagePreview: DisableWebPagePreview);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user