-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new/Добавлена возможность отвечать на сообщения
new/Добавлена возможность прикреплять клавиатуры
- Loading branch information
Байкин Егор
authored and
Байкин Егор
committed
Oct 27, 2024
1 parent
4c5d96f
commit 99c84a5
Showing
15 changed files
with
436 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Telegram_bots.Keyboards | ||
{ | ||
/// <summary> | ||
/// Keyboard | ||
/// </summary> | ||
public interface IKeyboard | ||
{ | ||
/// <summary> | ||
/// Keyboard's buttons | ||
/// </summary> | ||
IKeyboardButton[][] Keyboard { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Text.Json.Serialization; | ||
using Telegram_bots.Keyboards; | ||
|
||
namespace Telegram_bots | ||
{ | ||
/// <summary> | ||
/// Keyboard's button | ||
/// </summary> | ||
[JsonDerivedType(typeof(InlineKeyboardButton))] | ||
[JsonDerivedType(typeof(KeyboardButton))] | ||
public interface IKeyboardButton | ||
{ | ||
/// <summary> | ||
/// Button's text | ||
/// </summary> | ||
[JsonPropertyName("text")] | ||
string Text { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Collections; | ||
using System.Text.Json.Serialization; | ||
using System.Xml.Serialization; | ||
|
||
namespace Telegram_bots.Keyboards | ||
{ | ||
/// <summary> | ||
/// Inline keyboard | ||
/// </summary> | ||
/// <remarks> | ||
/// Create an inline keyboard | ||
/// </remarks> | ||
/// <param name="buttons">Keyboard's buttons</param> | ||
[Serializable] | ||
public class InlineKeyboard(InlineKeyboardButton[][] buttons) : IKeyboard | ||
{ | ||
/// <summary> | ||
/// <inheritdoc/> | ||
/// </summary> | ||
[JsonPropertyName("inline_keyboard")] | ||
public IKeyboardButton[][] Keyboard { get; set; } = buttons; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.Json.Serialization; | ||
using System.Threading.Tasks; | ||
|
||
namespace Telegram_bots | ||
{ | ||
/// <summary> | ||
/// The inline keyboard button | ||
/// </summary> | ||
[Serializable] | ||
public class InlineKeyboardButton : IKeyboardButton | ||
{ | ||
/// <summary> | ||
/// <inheritdoc/> | ||
/// </summary> | ||
[JsonPropertyName("text")] | ||
public string Text { get; set; } | ||
/// <summary> | ||
/// CallbackData of the inline keyboard buttons | ||
/// </summary> | ||
[JsonPropertyName("callback_data")] | ||
public string CallbackData { get; set; } | ||
|
||
/// <summary> | ||
/// Create an inline keyboard button | ||
/// </summary> | ||
/// <param name="text">Button's text</param> | ||
/// <param name="callbackData">CallbackData of the inline keyboard buttons</param> | ||
public InlineKeyboardButton(string text, string callbackData) | ||
{ | ||
Text = text; | ||
CallbackData = callbackData; | ||
} | ||
|
||
/// <summary> | ||
/// Create an inline keyboard button | ||
/// </summary> | ||
/// <param name="text">Button's text</param> | ||
public InlineKeyboardButton(string text) | ||
{ | ||
Text = text; | ||
CallbackData = text; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Telegram_bots.Keyboards | ||
{ | ||
/// <summary> | ||
/// Keyboard button | ||
/// </summary> | ||
/// <remarks> | ||
/// Create a keyboard button | ||
/// </remarks> | ||
/// <param name="text">Button's text</param> | ||
[Serializable] | ||
public class KeyboardButton(string text) : IKeyboardButton | ||
{ | ||
/// <summary> | ||
/// <inheritdoc/> | ||
/// </summary> | ||
[JsonPropertyName("text")] | ||
public string Text { get; set; } = text; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.Json.Serialization; | ||
using System.Threading.Tasks; | ||
|
||
namespace Telegram_bots.Keyboards | ||
{ | ||
/// <summary> | ||
/// Keyboard | ||
/// </summary> | ||
/// <remarks> | ||
/// Create a keyboard | ||
/// </remarks> | ||
/// <param name="buttons">Keyboard's buttons</param> | ||
[Serializable] | ||
public class ReplyKeyboard(KeyboardButton[][] buttons) : IKeyboard | ||
{ | ||
/// <summary> | ||
/// <inheritdoc/> | ||
/// </summary> | ||
[JsonPropertyName("keyboard")] | ||
public IKeyboardButton[][] Keyboard { get; set; } = buttons; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Text.Json.Serialization; | ||
using System.Threading.Tasks; | ||
|
||
namespace Telegram_bots.Keyboards | ||
{ | ||
/// <summary> | ||
/// Remove the keyboard | ||
/// </summary> | ||
[Serializable] | ||
public class ReplyKeyboardRemove : IKeyboard | ||
{ | ||
/// It's nothing | ||
[JsonIgnore] | ||
public IKeyboardButton[][] Keyboard { get; set; } = [[]]; | ||
/// <summary> | ||
/// Should I remove the keyboard or not? | ||
/// </summary> | ||
[JsonPropertyName("remove_keyboard")] | ||
public bool RemoveKeyboard { get; set; } = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.