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:
@@ -31,10 +31,6 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Data
|
||||
string content = String.Empty;
|
||||
switch (parseMode)
|
||||
{
|
||||
case ParseMode.Default:
|
||||
content = RawRepresentation(text);
|
||||
break;
|
||||
|
||||
case ParseMode.Html:
|
||||
content = HtmlRepresentation(text);
|
||||
break;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,8 +3,10 @@ using System.Collections.Concurrent;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BotFramework;
|
||||
using BotFramework.Abstractions;
|
||||
using Kruzya.TelegramBot.Core.Service;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Exceptions;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
@@ -17,7 +19,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Service
|
||||
protected readonly ConcurrentQueue<UserMessage> _queue;
|
||||
protected readonly ConcurrentQueue<UserUnsubscribe> _unsubscribeQueue;
|
||||
|
||||
public MessageSender(ILogger<MessageSender> logger, ITelegramBot bot, ConcurrentQueue<UserMessage> userMessageQueue, ConcurrentQueue<UserUnsubscribe> userUnsubscribeQueue) : base(logger, bot)
|
||||
public MessageSender(ILogger<MessageSender> logger, IBotInstance bot, ConcurrentQueue<UserMessage> userMessageQueue, ConcurrentQueue<UserUnsubscribe> userUnsubscribeQueue) : base(logger, bot)
|
||||
{
|
||||
_unsubscribeQueue = userUnsubscribeQueue;
|
||||
_queue = userMessageQueue;
|
||||
|
||||
@@ -3,10 +3,12 @@ using System.Collections.Concurrent;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using BotFramework;
|
||||
using BotFramework.Abstractions;
|
||||
using Kruzya.TelegramBot.Core.Service;
|
||||
using Kruzya.TelegramBot.RichSiteSummary.Data;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
|
||||
namespace Kruzya.TelegramBot.RichSiteSummary.Service
|
||||
@@ -18,7 +20,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Service
|
||||
|
||||
protected override TimeSpan TimerPeriod => TimeSpan.FromSeconds(1);
|
||||
|
||||
public Unsubscriber(ILogger<Unsubscriber> logger, ITelegramBot bot, ConcurrentQueue<UserUnsubscribe> queue, IServiceScopeFactory scopeFactory) : base(logger, bot)
|
||||
public Unsubscriber(ILogger<Unsubscriber> logger, IBotInstance bot, ConcurrentQueue<UserUnsubscribe> queue, IServiceScopeFactory scopeFactory) : base(logger, bot)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
_queue = queue;
|
||||
|
||||
Reference in New Issue
Block a user