mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Update to new Telegram.Bot.
This commit is contained in:
@@ -9,6 +9,7 @@ using BotFramework.Setup;
|
||||
using Kruzya.TelegramBot.Core.Extensions;
|
||||
using Kruzya.TelegramBot.RichSiteSummary.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
using Telegram.Bot.Types.ReplyMarkups;
|
||||
@@ -51,24 +52,21 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
|
||||
var callbackData = $"feed|{from.Id}|do|{feed.FeedId}";
|
||||
if (await _dbContext.Subscriptions.HasSubscription(chat, feed))
|
||||
{
|
||||
buttons.Add(new InlineKeyboardButton()
|
||||
buttons.Add(new InlineKeyboardButton("Unsubscribe")
|
||||
{
|
||||
CallbackData = callbackData,
|
||||
Text = "Unsubscribe"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
buttons.Add(new InlineKeyboardButton()
|
||||
buttons.Add(new InlineKeyboardButton("Subscribe")
|
||||
{
|
||||
CallbackData = callbackData,
|
||||
Text = "Subscribe"
|
||||
});
|
||||
}
|
||||
buttons.Add(new InlineKeyboardButton()
|
||||
buttons.Add(new InlineKeyboardButton("Last 10 posts")
|
||||
{
|
||||
CallbackData = $"feed|{from.Id}|last|{feed.FeedId}",
|
||||
Text = "Last 10 posts"
|
||||
});
|
||||
|
||||
var inlineButtons = new InlineKeyboardMarkup(buttons);
|
||||
@@ -155,10 +153,9 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
|
||||
foreach (var feed in result)
|
||||
{
|
||||
row = new List<InlineKeyboardButton>();
|
||||
row.Add(new InlineKeyboardButton()
|
||||
row.Add(new InlineKeyboardButton(feed.Title)
|
||||
{
|
||||
CallbackData = $"feed|{From.Id}|show|{feed.FeedId.ToString()}",
|
||||
Text = feed.Title
|
||||
});
|
||||
|
||||
buttons.Add(row);
|
||||
@@ -169,25 +166,22 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
|
||||
row = new List<InlineKeyboardButton>();
|
||||
if (backButton)
|
||||
{
|
||||
row.Add(new InlineKeyboardButton()
|
||||
row.Add(new InlineKeyboardButton("⬅️")
|
||||
{
|
||||
CallbackData = $"feed|{From.Id}|page|{query}|{page - 1}",
|
||||
Text = "⬅️"
|
||||
});
|
||||
}
|
||||
|
||||
row.Add(new InlineKeyboardButton()
|
||||
row.Add(new InlineKeyboardButton($"{page + 1}/{(totalCount / elementsOnPage) + 1}")
|
||||
{
|
||||
CallbackData = $"feed|{From.Id}|donothing",
|
||||
Text = $"{page + 1}/{(totalCount / elementsOnPage) + 1}"
|
||||
});
|
||||
|
||||
if (nextButton)
|
||||
{
|
||||
row.Add(new InlineKeyboardButton()
|
||||
row.Add(new InlineKeyboardButton("➡️")
|
||||
{
|
||||
CallbackData = $"feed|{From.Id}|page|{query}|{page + 1}",
|
||||
Text = "➡️"
|
||||
});
|
||||
}
|
||||
|
||||
@@ -196,12 +190,12 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
|
||||
|
||||
if (editableMessage == null)
|
||||
{
|
||||
await Bot.SendTextMessageAsync(Chat, "Select the feed for viewing details", ParseMode.Default,
|
||||
await Bot.SendTextMessageAsync(Chat, "Select the feed for viewing details", null,
|
||||
null, true, true, 0, replyMarkup: new InlineKeyboardMarkup(buttons));
|
||||
}
|
||||
else
|
||||
{
|
||||
await Bot.EditMessageTextAsync(editableMessage.Chat, editableMessage.MessageId, "Select the feed for viewing details", ParseMode.Default, null, false,
|
||||
await Bot.EditMessageTextAsync(editableMessage.Chat, editableMessage.MessageId, "Select the feed for viewing details", null, null, false,
|
||||
new InlineKeyboardMarkup(buttons));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||
using BotFramework.Attributes;
|
||||
using Kruzya.TelegramBot.RichSiteSummary.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
|
||||
namespace Kruzya.TelegramBot.RichSiteSummary.Handler
|
||||
|
||||
Reference in New Issue
Block a user