mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Use the new version of TelegramBotFramework
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AleXr64.BotFramework" Version="0.0.17" />
|
||||
<PackageReference Include="AleXr64.BotFramework" Version="0.3.11" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.2" />
|
||||
|
||||
@@ -20,6 +20,6 @@ namespace Kruzya.TelegramBot.Core.Data
|
||||
/// <summary>
|
||||
/// The Telegram User identifier.
|
||||
/// </summary>
|
||||
public int UserId { get; set; }
|
||||
public long UserId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ namespace Kruzya.TelegramBot.Core.Extensions
|
||||
|
||||
#region BotUser
|
||||
|
||||
public static async Task<BotUser> FindOrCreate(this DbSet<BotUser> repository, long chatId, int userId)
|
||||
public static async Task<BotUser> FindOrCreate(this DbSet<BotUser> repository, long chatId, long userId)
|
||||
{
|
||||
var user = await repository.SingleOrDefaultAsync(e => e.ChatId == chatId && e.UserId == userId);
|
||||
if (user == null)
|
||||
@@ -76,7 +76,7 @@ namespace Kruzya.TelegramBot.Core.Extensions
|
||||
public static async Task<BotUserValue> FindOption(this DbSet<BotUserValue> repository, BotUser user,
|
||||
string option) => await repository.FindOption(user.ChatId, user.UserId, option);
|
||||
|
||||
public static async Task<BotUserValue> FindOption(this DbSet<BotUserValue> repository, long chatId, int userId,
|
||||
public static async Task<BotUserValue> FindOption(this DbSet<BotUserValue> repository, long chatId, long userId,
|
||||
string option) => await repository.SingleOrDefaultAsync(e =>
|
||||
e.BotUser.ChatId == chatId && e.BotUser.UserId == userId && e.Name == option);
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Kruzya.TelegramBot.Core.Extensions
|
||||
string option) => await repository.FindOrCreateOption(user.ChatId, user.UserId, option);
|
||||
|
||||
public static async Task<BotUserValue> FindOrCreateOption(this DbSet<BotUserValue> repository, long chatId,
|
||||
int userId, string option)
|
||||
long userId, string option)
|
||||
{
|
||||
var opt = await repository.FindOption(chatId, userId, option);
|
||||
if (opt == null)
|
||||
@@ -113,7 +113,7 @@ namespace Kruzya.TelegramBot.Core.Extensions
|
||||
public static async Task SetOptionValue<T>(this DbSet<BotUserValue> repository, BotUser user, string option,
|
||||
T val) => await repository.SetOptionValue(user.ChatId, user.UserId, option, val);
|
||||
|
||||
public static async Task SetOptionValue<T>(this DbSet<BotUserValue> repository, long chatId, int userId,
|
||||
public static async Task SetOptionValue<T>(this DbSet<BotUserValue> repository, long chatId, long userId,
|
||||
string option, T val)
|
||||
{
|
||||
var opt = await repository.FindOrCreateOption(chatId, userId, option);
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Kruzya.TelegramBot.Core
|
||||
await VerifyChatPair(chat.Id, user.Id);
|
||||
}
|
||||
|
||||
public async Task VerifyChatPair(long chat, int user)
|
||||
public async Task VerifyChatPair(long chat, long user)
|
||||
{
|
||||
var hasEntry = await databaseContext.Users.AnyAsync(e => e.ChatId == chat && e.UserId == user);
|
||||
if (hasEntry)
|
||||
@@ -64,7 +64,7 @@ namespace Kruzya.TelegramBot.Core
|
||||
await MakeChatPair(chat, user);
|
||||
}
|
||||
|
||||
public async Task MakeChatPair(long chat, int user)
|
||||
public async Task MakeChatPair(long chat, long user)
|
||||
{
|
||||
await databaseContext.Users.AddAsync(new BotUser()
|
||||
{
|
||||
|
||||
@@ -72,11 +72,11 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
|
||||
var inlineButtons = new InlineKeyboardMarkup(buttons);
|
||||
if (message == null)
|
||||
{
|
||||
await Bot.SendTextMessageAsync(new ChatId(chat.Id), text, ParseMode.Html, true, true, 0, inlineButtons);
|
||||
await Bot.SendTextMessageAsync(new ChatId(chat.Id), text, ParseMode.Html, null, true, true, 0, replyMarkup: inlineButtons);
|
||||
}
|
||||
else
|
||||
{
|
||||
await Bot.EditMessageTextAsync(chat, message.MessageId, text, ParseMode.Html, true, inlineButtons);
|
||||
await Bot.EditMessageTextAsync(chat, message.MessageId, text, ParseMode.Html, null, true, replyMarkup: inlineButtons);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
|
||||
{
|
||||
if (!(await GenerateMenu(query)))
|
||||
{
|
||||
await Bot.SendTextMessageAsync(Chat, $"No one feed match by search pattern (<code>{query}</code>).", ParseMode.Html, true);
|
||||
await Bot.SendTextMessageAsync(Chat, $"No one feed match by search pattern (<code>{query}</code>).", ParseMode.Html, null, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,11 +195,11 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
|
||||
if (editableMessage == null)
|
||||
{
|
||||
await Bot.SendTextMessageAsync(Chat, "Select the feed for viewing details", ParseMode.Default,
|
||||
true, true, 0, new InlineKeyboardMarkup(buttons));
|
||||
null, true, true, 0, replyMarkup: new InlineKeyboardMarkup(buttons));
|
||||
}
|
||||
else
|
||||
{
|
||||
await Bot.EditMessageTextAsync(editableMessage.Chat, editableMessage.MessageId, "Select the feed for viewing details", ParseMode.Default, false,
|
||||
await Bot.EditMessageTextAsync(editableMessage.Chat, editableMessage.MessageId, "Select the feed for viewing details", ParseMode.Default, null, false,
|
||||
new InlineKeyboardMarkup(buttons));
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
|
||||
}
|
||||
|
||||
await Bot.SendTextMessageAsync(RawUpdate.CallbackQuery.Message.Chat, messageTextBuilder.ToString(),
|
||||
ParseMode.Html, true);
|
||||
ParseMode.Html, null, true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,11 +40,11 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Service
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(message.ImageUrl))
|
||||
await _bot.BotClient.SendTextMessageAsync(message.ChatId, message.Text, message.ParseMode,
|
||||
await _bot.BotClient.SendTextMessageAsync(message.ChatId, message.Text, message.ParseMode, null,
|
||||
message.DisableWebPagePreview);
|
||||
else
|
||||
await _bot.BotClient.SendPhotoAsync(message.ChatId, message.ImageUrl, message.Text,
|
||||
message.ParseMode, message.DisableWebPagePreview);
|
||||
message.ParseMode, null, message.DisableWebPagePreview);
|
||||
}
|
||||
catch (ApiRequestException e)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Kruzya.TelegramBot.UrlLimitations
|
||||
foreach (var mention in message.Entities.Where(e =>
|
||||
e.Type == MessageEntityType.Mention || e.Type == MessageEntityType.TextMention))
|
||||
{
|
||||
var userId = 0;
|
||||
long userId = 0;
|
||||
if (mention.Type == MessageEntityType.TextMention)
|
||||
{
|
||||
userId = mention.User.Id;
|
||||
@@ -34,10 +34,10 @@ namespace Kruzya.TelegramBot.UrlLimitations
|
||||
return true;
|
||||
}
|
||||
|
||||
userId = Convert.ToInt32(chat.Id);
|
||||
userId = Convert.ToInt64(chat.Id);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user