From de08c74a5debdc0688787e2e161964eed9660dd8 Mon Sep 17 00:00:00 2001 From: West14 <30056636+West14@users.noreply.github.com> Date: Sat, 25 Dec 2021 15:17:13 +0200 Subject: [PATCH] Update target framework to .NET 5 & telegram-bot-framework. Update bot codebase to use the new framework API. --- Core/Core.csproj | 4 ++-- modules/CombotAntiSpam/CombotAntiSpam.csproj | 2 +- modules/CombotAntiSpam/UserJoinHandler.cs | 3 ++- modules/Destiny2.WhereIsXur/Destiny2.WhereIsXur.csproj | 2 +- modules/RichSiteSummary/Handler/FeedList.cs | 4 +++- modules/RichSiteSummary/RichSiteSummary.csproj | 2 +- modules/UrlLimitations/MessageHandler.cs | 3 ++- modules/UrlLimitations/UrlLimitations.csproj | 2 +- modules/UrlLimitations/UserJoinHandler.cs | 3 ++- 9 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Core/Core.csproj b/Core/Core.csproj index a432284..80edb00 100644 --- a/Core/Core.csproj +++ b/Core/Core.csproj @@ -1,13 +1,13 @@ - netcoreapp3.1 + net5.0 TelegramBot Kruzya.TelegramBot.Core - + diff --git a/modules/CombotAntiSpam/CombotAntiSpam.csproj b/modules/CombotAntiSpam/CombotAntiSpam.csproj index 463ac4f..ada4e7e 100644 --- a/modules/CombotAntiSpam/CombotAntiSpam.csproj +++ b/modules/CombotAntiSpam/CombotAntiSpam.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 TelegramBot.CombotAntiSpam Kruzya.TelegramBot.CombotAntiSpam diff --git a/modules/CombotAntiSpam/UserJoinHandler.cs b/modules/CombotAntiSpam/UserJoinHandler.cs index e085e1e..e7a7745 100644 --- a/modules/CombotAntiSpam/UserJoinHandler.cs +++ b/modules/CombotAntiSpam/UserJoinHandler.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using BotFramework; using BotFramework.Attributes; +using BotFramework.Enums; using BotFramework.Setup; using Kruzya.TelegramBot.CombotAntiSpam.Combot; using Kruzya.TelegramBot.Core.Extensions; @@ -20,7 +21,7 @@ namespace Kruzya.TelegramBot.CombotAntiSpam _combotClient = combotClient; } - [Message(MessageType.ChatMembersAdded, InChat.Public)] + [Message(InChat.Public, MessageFlag.HasNewChatMembers)] public async Task OnUserJoined() { var canKickMembers = ((await Bot.GetChatMemberAsync(Chat, (await Bot.GetMeAsync()).Id)).CanRestrictMembers == true); diff --git a/modules/Destiny2.WhereIsXur/Destiny2.WhereIsXur.csproj b/modules/Destiny2.WhereIsXur/Destiny2.WhereIsXur.csproj index 260611a..d207072 100644 --- a/modules/Destiny2.WhereIsXur/Destiny2.WhereIsXur.csproj +++ b/modules/Destiny2.WhereIsXur/Destiny2.WhereIsXur.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 Kruzya.TelegramBot.D2_WhereIsXur Kruzya.TelegramBot.Destiny2.WhereIsXur diff --git a/modules/RichSiteSummary/Handler/FeedList.cs b/modules/RichSiteSummary/Handler/FeedList.cs index 134b293..bc6c950 100644 --- a/modules/RichSiteSummary/Handler/FeedList.cs +++ b/modules/RichSiteSummary/Handler/FeedList.cs @@ -4,6 +4,8 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using BotFramework.Attributes; +using BotFramework.Enums; +using BotFramework.Setup; using Kruzya.TelegramBot.Core.Extensions; using Kruzya.TelegramBot.RichSiteSummary.Data; using Microsoft.EntityFrameworkCore; @@ -210,7 +212,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler #region Message handler - [CallbackQuery] + [Update(InChat.All, UpdateFlag.CallbackQuery)] public async Task HandleAction() { if (!RawUpdate.CallbackQuery.Data.StartsWith("feed|")) diff --git a/modules/RichSiteSummary/RichSiteSummary.csproj b/modules/RichSiteSummary/RichSiteSummary.csproj index c882e53..4eab7ec 100644 --- a/modules/RichSiteSummary/RichSiteSummary.csproj +++ b/modules/RichSiteSummary/RichSiteSummary.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 TelegramBot.RichSiteSummary Kruzya.TelegramBot.RichSiteSummary diff --git a/modules/UrlLimitations/MessageHandler.cs b/modules/UrlLimitations/MessageHandler.cs index 7f18a5f..fc65dc7 100644 --- a/modules/UrlLimitations/MessageHandler.cs +++ b/modules/UrlLimitations/MessageHandler.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading.Tasks; using BotFramework; using BotFramework.Attributes; +using BotFramework.Enums; using BotFramework.Setup; using Kruzya.TelegramBot.Core.Cache; using Kruzya.TelegramBot.Core.Data; @@ -24,7 +25,7 @@ namespace Kruzya.TelegramBot.UrlLimitations dbCtx = coreContext; } - [TextMessage(InChat.Public)] + [Message(InChat.Public, MessageFlag.HasText)] public async Task OnMessageReceived() { var option = await dbCtx.UserValues.FindOption(Chat.Id, From.Id, "urlLimitations.messagesAfterJoin"); diff --git a/modules/UrlLimitations/UrlLimitations.csproj b/modules/UrlLimitations/UrlLimitations.csproj index 41c572b..2a7e32e 100644 --- a/modules/UrlLimitations/UrlLimitations.csproj +++ b/modules/UrlLimitations/UrlLimitations.csproj @@ -1,7 +1,7 @@ - netcoreapp3.1 + net5.0 TelegramBot.UrlLimitations Kruzya.TelegramBot.UrlLimitations diff --git a/modules/UrlLimitations/UserJoinHandler.cs b/modules/UrlLimitations/UserJoinHandler.cs index bb293f1..1355eb3 100644 --- a/modules/UrlLimitations/UserJoinHandler.cs +++ b/modules/UrlLimitations/UserJoinHandler.cs @@ -2,6 +2,7 @@ using System.Threading.Tasks; using BotFramework; using BotFramework.Attributes; +using BotFramework.Enums; using BotFramework.Setup; using Kruzya.TelegramBot.Core.Cache; using Kruzya.TelegramBot.Core.Data; @@ -19,7 +20,7 @@ namespace Kruzya.TelegramBot.UrlLimitations dbCtx = coreContext; } - [Message(MessageType.ChatMembersAdded, InChat.Public)] + [Message(InChat.Public, MessageFlag.HasNewChatMembers)] public async Task OnChatMembersAdded() { foreach (var member in RawUpdate.Message.NewChatMembers)