diff --git a/Core/Core.csproj b/Core/Core.csproj index d230e0d..5c6bde4 100644 --- a/Core/Core.csproj +++ b/Core/Core.csproj @@ -8,7 +8,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/modules/ChatManagement/Handler/Greet.cs b/modules/ChatManagement/Handler/Greet.cs index 07636f2..a785a8d 100644 --- a/modules/ChatManagement/Handler/Greet.cs +++ b/modules/ChatManagement/Handler/Greet.cs @@ -47,6 +47,6 @@ public class Greet : BotEventHandler } await Bot.SendTextMessageAsync(Chat.Id, string.Format(reply.ToString(), membersHtml), - ParseMode.Html, replyToMessageId: message.MessageId); + parseMode: ParseMode.Html, replyToMessageId: message.MessageId); } } \ No newline at end of file diff --git a/modules/ChatQuotes/Handler/Quote.cs b/modules/ChatQuotes/Handler/Quote.cs index ba7d9de..9e58e1d 100644 --- a/modules/ChatQuotes/Handler/Quote.cs +++ b/modules/ChatQuotes/Handler/Quote.cs @@ -2,7 +2,7 @@ using BotFramework.Attributes; using BotFramework.Enums; using Telegram.Bot; -using Telegram.Bot.Types.InputFiles; +using Telegram.Bot.Types; namespace West.TelegramBot.ChatQuotes.Handler; @@ -31,7 +31,7 @@ public class Quote : BotEventHandler return; } - await Bot.SendStickerAsync(Chat.Id, new InputOnlineFile(quoteImage), + await Bot.SendStickerAsync(Chat.Id, new InputFile(quoteImage), replyToMessageId: msg.MessageId); } } \ No newline at end of file diff --git a/modules/ChatQuotes/Json/NullToEmptyObjectValueProvider.cs b/modules/ChatQuotes/Json/NullToEmptyObjectValueProvider.cs index 5f08515..cb6d497 100644 --- a/modules/ChatQuotes/Json/NullToEmptyObjectValueProvider.cs +++ b/modules/ChatQuotes/Json/NullToEmptyObjectValueProvider.cs @@ -19,7 +19,7 @@ public class NullToEmptyObjectValueProvider : IValueProvider return result; } - public void SetValue(object target, object value) + public void SetValue(object target, object? value) { _memberInfo.SetValue(target, value); } diff --git a/modules/CodeWatcher/Handler.cs b/modules/CodeWatcher/Handler.cs index 710c448..c73bff3 100644 --- a/modules/CodeWatcher/Handler.cs +++ b/modules/CodeWatcher/Handler.cs @@ -81,7 +81,7 @@ public class Handler : BotEventHandler var notifyMsg = await Bot.SendTextMessageAsync(Chat.Id, (message.From?.ToHtml() ?? "") + ", не стоит публиковать столь большой код прямо в чат. " + "Вместо этого загрузите его на https://pastebin.com и отправьте в виде ссылки.", - ParseMode.Html); + parseMode: ParseMode.Html); // TODO: maybe write a wrapper-service around collection to avoid direct interactions with the collection, West, 07.07.2022, 16:53 _requests.Add(new DeleteRequest diff --git a/modules/CombotAntiSpam/UserJoinHandler.cs b/modules/CombotAntiSpam/UserJoinHandler.cs index f81e170..f4f21a0 100644 --- a/modules/CombotAntiSpam/UserJoinHandler.cs +++ b/modules/CombotAntiSpam/UserJoinHandler.cs @@ -49,7 +49,7 @@ namespace Kruzya.TelegramBot.CombotAntiSpam messageText.Append( $"More details you can find on CAS site."); - await Bot.SendTextMessageAsync(Chat, messageText.ToString(), ParseMode.Html); + await Bot.SendTextMessageAsync(Chat, messageText.ToString(), parseMode: ParseMode.Html); if (canKickMembers) { diff --git a/modules/ContentStore/Handler/Store.cs b/modules/ContentStore/Handler/Store.cs index 0850e05..df44a2a 100644 --- a/modules/ContentStore/Handler/Store.cs +++ b/modules/ContentStore/Handler/Store.cs @@ -43,7 +43,7 @@ public class Store : BotEventHandler var user = From; var reputation = await _reputation.GetUserReputationAsync(Chat, user); - await Bot.SendTextMessageAsync(Chat.Id, $"{user.ToHtml()} ({reputation}), чего пожелаете?", ParseMode.Html, + await Bot.SendTextMessageAsync(Chat.Id, $"{user.ToHtml()} ({reputation}), чего пожелаете?", parseMode: ParseMode.Html, replyMarkup: new InlineKeyboardMarkup( _provider.GetServices() .ToAsyncEnumerable() @@ -116,7 +116,7 @@ public class Store : BotEventHandler switch (randomMedia.Type) { case InputMediaType.Photo: - await Bot.SendPhotoAsync(Chat.Id, file, randomMedia.Caption, replyToMessageId: messageId, parseMode: ParseMode.Html); + await Bot.SendPhotoAsync(Chat.Id, file, 0, randomMedia.Caption, replyToMessageId: messageId, parseMode: ParseMode.Html); break; case InputMediaType.Video: await Bot.SendVideoAsync(Chat.Id, file, caption: randomMedia.Caption, replyToMessageId: messageId, parseMode: ParseMode.Html); diff --git a/modules/ContentStore/Model/RandomMedia.cs b/modules/ContentStore/Model/RandomMedia.cs index d1b3021..0791658 100644 --- a/modules/ContentStore/Model/RandomMedia.cs +++ b/modules/ContentStore/Model/RandomMedia.cs @@ -1,17 +1,17 @@ -using Telegram.Bot.Types.Enums; -using Telegram.Bot.Types.InputFiles; +using Telegram.Bot.Types; +using Telegram.Bot.Types.Enums; namespace West.TelegramBot.ContentStore.Model; public class RandomMedia { - public RandomMedia(InputOnlineFile file, string? caption = null) + public RandomMedia(IInputFile file, string? caption = null) { File = file; Caption = caption; } - public InputOnlineFile File; + public IInputFile File; public string? Caption; public InputMediaType Type { get; set; } = InputMediaType.Photo; diff --git a/modules/ContentStore/Service/AbstractKittiesService.cs b/modules/ContentStore/Service/AbstractKittiesService.cs index 411f8b3..6c2f43a 100644 --- a/modules/ContentStore/Service/AbstractKittiesService.cs +++ b/modules/ContentStore/Service/AbstractKittiesService.cs @@ -5,7 +5,6 @@ using Kruzya.TelegramBot.Core.Data; using Kruzya.TelegramBot.Core.Extensions; using Microsoft.Extensions.Configuration; using Telegram.Bot.Types; -using Telegram.Bot.Types.InputFiles; using West.TelegramBot.ContentStore.Model; namespace West.TelegramBot.ContentStore.Service; @@ -45,7 +44,7 @@ public abstract class AbstractKittiesService : IRandomMediaService var videoTitle = Encoding.UTF8.GetString(Convert.FromBase64String(videoTitleBase64)); return new RandomMedia( - new InputOnlineFile(await response.Content.ReadAsStreamAsync()), + new InputFile(await response.Content.ReadAsStreamAsync()), new HtmlString().Url(videoSource, videoTitle).ToString() ); } diff --git a/modules/ContentStore/Service/AnimBoobsService.cs b/modules/ContentStore/Service/AnimBoobsService.cs index 4b5ef00..c27ae31 100644 --- a/modules/ContentStore/Service/AnimBoobsService.cs +++ b/modules/ContentStore/Service/AnimBoobsService.cs @@ -24,7 +24,7 @@ public class AnimBoobsService : IRandomMediaService public async Task GetRandomMediaAsync() { var fileName = await _httpClient.GetStringAsync("index.php"); - return new RandomMedia($"https://westdev.me/_boobs/media/{fileName}") + return new RandomMedia(new InputFileUrl($"https://westdev.me/_boobs/media/{fileName}")) { Type = InputMediaType.Video }; diff --git a/modules/ContentStore/Service/AnimalAsAService.cs b/modules/ContentStore/Service/AnimalAsAService.cs index eb6933c..653bcb3 100644 --- a/modules/ContentStore/Service/AnimalAsAService.cs +++ b/modules/ContentStore/Service/AnimalAsAService.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using Telegram.Bot.Types; using West.TelegramBot.ContentStore.Model; namespace West.TelegramBot.ContentStore.Service; @@ -20,7 +21,7 @@ public abstract class AnimalAsAService : IRandomMediaService public async Task GetRandomMediaAsync() { var resp = await _httpClient.GetAsync("images/search"); - var catImage = JsonConvert.DeserializeObject>(await resp.Content.ReadAsStringAsync())[0]; - return new RandomMedia(catImage.Url); + var catImage = JsonConvert.DeserializeObject>(await resp.Content.ReadAsStringAsync())![0]; + return new RandomMedia(new InputFileUrl(catImage.Url)); } } \ No newline at end of file diff --git a/modules/ContentStore/Service/CapyApiService.cs b/modules/ContentStore/Service/CapyApiService.cs index d4f6abb..46a454c 100644 --- a/modules/ContentStore/Service/CapyApiService.cs +++ b/modules/ContentStore/Service/CapyApiService.cs @@ -1,4 +1,5 @@ -using West.TelegramBot.ContentStore.Model; +using Telegram.Bot.Types; +using West.TelegramBot.ContentStore.Model; namespace West.TelegramBot.ContentStore.Service; @@ -7,6 +8,6 @@ public class CapyApiService : IRandomMediaService public StoreItem StoreItem { get; } = new("capybara", "Капибара", 60, 25); public async Task GetRandomMediaAsync() { - return new RandomMedia($"https://api.capy.lol/v1/capybara?{new Random().Next(0, 10000)}"); + return new RandomMedia(new InputFileUrl($"https://api.capy.lol/v1/capybara?{new Random().Next(0, 10000)}")); } } \ No newline at end of file diff --git a/modules/ContentStore/Service/OBoobsService.cs b/modules/ContentStore/Service/OBoobsService.cs index 450b25c..f761e1d 100644 --- a/modules/ContentStore/Service/OBoobsService.cs +++ b/modules/ContentStore/Service/OBoobsService.cs @@ -26,10 +26,10 @@ public class OBoobsService : IRandomMediaService // "/boobs/{start=0; sql offset}/{count=1; sql limit}/{order=-id;[id,rank,-rank,interest,-interest,random]}/ var httpResp = await _httpClient.GetAsync("boobs/1/1/random"); var boobsResponse = JsonConvert.DeserializeObject>(await httpResp.Content.ReadAsStringAsync()); - var boobsItem = boobsResponse[0]; + var boobsItem = boobsResponse![0]; var boobsId = boobsItem.Id.ToString("D5"); - return new RandomMedia($"https://media.oboobs.ru/boobs/{boobsId}.jpg", boobsItem.Model); + return new RandomMedia(new InputFileUrl($"https://media.oboobs.ru/boobs/{boobsId}.jpg"), boobsItem.Model); } public async Task CanView(Chat chat, User user) diff --git a/modules/ContentStore/Service/StraightKittiesService.cs b/modules/ContentStore/Service/StraightKittiesService.cs index 394e769..f614455 100644 --- a/modules/ContentStore/Service/StraightKittiesService.cs +++ b/modules/ContentStore/Service/StraightKittiesService.cs @@ -1,8 +1,5 @@ -using System.Net.Http.Headers; -using BotFramework.Utils; -using Kruzya.TelegramBot.Core.Data; +using Kruzya.TelegramBot.Core.Data; using Microsoft.Extensions.Configuration; -using Telegram.Bot.Types.InputFiles; using West.TelegramBot.ContentStore.Model; namespace West.TelegramBot.ContentStore.Service; diff --git a/modules/Destiny2.WhereIsXur/RequestHandler.cs b/modules/Destiny2.WhereIsXur/RequestHandler.cs index ea8ac7e..a3252e5 100644 --- a/modules/Destiny2.WhereIsXur/RequestHandler.cs +++ b/modules/Destiny2.WhereIsXur/RequestHandler.cs @@ -31,7 +31,7 @@ namespace Kruzya.TelegramBot.Destiny2.WhereIsXur protected async Task Response(string place) { - await Bot.SendTextMessageAsync(Chat, $"Xûr place is {place}", ParseMode.Html); + await Bot.SendTextMessageAsync(Chat, $"Xûr place is {place}", parseMode: ParseMode.Html); } } } \ No newline at end of file diff --git a/modules/Entertainment/Handler/Common.cs b/modules/Entertainment/Handler/Common.cs index 0b4eeab..b3bf726 100644 --- a/modules/Entertainment/Handler/Common.cs +++ b/modules/Entertainment/Handler/Common.cs @@ -57,7 +57,7 @@ namespace West.Entertainment.Handler .Br(); } - await Bot.SendTextMessageAsync(Chat.Id, msg.ToString(), ParseMode.Html); + await Bot.SendTextMessageAsync(Chat.Id, msg.ToString(), parseMode: ParseMode.Html); } } } \ No newline at end of file diff --git a/modules/Entertainment/Handler/Fun/AbstractAnimationReply.cs b/modules/Entertainment/Handler/Fun/AbstractAnimationReply.cs index 3689789..ad3f5f3 100644 --- a/modules/Entertainment/Handler/Fun/AbstractAnimationReply.cs +++ b/modules/Entertainment/Handler/Fun/AbstractAnimationReply.cs @@ -82,7 +82,7 @@ namespace West.Entertainment.Handler.Fun return false; } - await Bot.SendAnimationAsync(Chat.Id, animationFileId, + await Bot.SendAnimationAsync(Chat.Id, new InputFileId(animationFileId), replyToMessageId: GetMessageIdToReply() ?? Message?.MessageId); nextUseOption.SetValue(DateTime.Now + Cooldown); diff --git a/modules/Reputation/Handler/Reputation.cs b/modules/Reputation/Handler/Reputation.cs index 3d6f9fa..a64bc3a 100644 --- a/modules/Reputation/Handler/Reputation.cs +++ b/modules/Reputation/Handler/Reputation.cs @@ -176,7 +176,7 @@ public class Reputation : CommonHandler i++; } - await Bot.SendTextMessageAsync(Chat!, msg.ToString(), ParseMode.Html, + await Bot.SendTextMessageAsync(Chat!, msg.ToString(), parseMode: ParseMode.Html, disableNotification: true); } diff --git a/modules/RichSiteSummary/Handler/FeedList.cs b/modules/RichSiteSummary/Handler/FeedList.cs index 5d810b2..847b760 100644 --- a/modules/RichSiteSummary/Handler/FeedList.cs +++ b/modules/RichSiteSummary/Handler/FeedList.cs @@ -72,7 +72,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler var inlineButtons = new InlineKeyboardMarkup(buttons); if (message == null) { - await Bot.SendTextMessageAsync(new ChatId(chat.Id), text, ParseMode.Html, null, true, true, 0, replyMarkup: inlineButtons); + await Bot.SendTextMessageAsync(new ChatId(chat.Id), text, 0, ParseMode.Html, null, true, true, false, 0, replyMarkup: inlineButtons); } else { @@ -88,7 +88,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler { if (!(await GenerateMenu(query))) { - await Bot.SendTextMessageAsync(Chat, $"No one feed match by search pattern ({query}).", ParseMode.Html, null, true); + await Bot.SendTextMessageAsync(Chat, $"No one feed match by search pattern ({query}).", 0, ParseMode.Html, null, true); } } @@ -192,8 +192,8 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler if (editableMessage == null) { - await Bot.SendTextMessageAsync(Chat, "Select the feed for viewing details", null, - null, true, true, 0, replyMarkup: new InlineKeyboardMarkup(buttons)); + await Bot.SendTextMessageAsync(Chat, "Select the feed for viewing details", 0, null, + null, true, true, false, 0, replyMarkup: new InlineKeyboardMarkup(buttons)); } else { @@ -270,7 +270,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler } await Bot.SendTextMessageAsync(RawUpdate.CallbackQuery.Message.Chat, messageTextBuilder.ToString(), - ParseMode.Html, null, true); + 0, ParseMode.Html, null, true); break; } diff --git a/modules/RichSiteSummary/Handler/StatsHandler.cs b/modules/RichSiteSummary/Handler/StatsHandler.cs index 3e0863d..4fd7183 100644 --- a/modules/RichSiteSummary/Handler/StatsHandler.cs +++ b/modules/RichSiteSummary/Handler/StatsHandler.cs @@ -31,7 +31,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler textMessage.Append( $"- exists {subscriptionsCount} subscriptions on feeds (unique subscribers: {uniqueSubscribers})"); - await Bot.SendTextMessageAsync(Chat, textMessage.ToString(), ParseMode.Html); + await Bot.SendTextMessageAsync(Chat, textMessage.ToString(), parseMode: ParseMode.Html); } } } \ No newline at end of file diff --git a/modules/RichSiteSummary/Service/MessageSender.cs b/modules/RichSiteSummary/Service/MessageSender.cs index 5f1548f..ebc5d24 100644 --- a/modules/RichSiteSummary/Service/MessageSender.cs +++ b/modules/RichSiteSummary/Service/MessageSender.cs @@ -36,13 +36,13 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Service { if (string.IsNullOrWhiteSpace(message.ImageUrl)) { - await _bot.BotClient.SendTextMessageAsync(message.ChatId, message.Text, message.ParseMode, null, + await _bot.BotClient.SendTextMessageAsync(message.ChatId, message.Text, 0, message.ParseMode, null, message.DisableWebPagePreview); } else { - await _bot.BotClient.SendPhotoAsync(message.ChatId, message.ImageUrl, message.Text, + await _bot.BotClient.SendPhotoAsync(message.ChatId, new InputFileUrl(message.ImageUrl), 0, message.Text, message.ParseMode, null, message.DisableWebPagePreview); } } diff --git a/modules/UrlLimitations/MessageHandler.cs b/modules/UrlLimitations/MessageHandler.cs index e41fee6..a91ba03 100644 --- a/modules/UrlLimitations/MessageHandler.cs +++ b/modules/UrlLimitations/MessageHandler.cs @@ -52,7 +52,7 @@ namespace Kruzya.TelegramBot.UrlLimitations Bot.BanChatMemberAsync(new ChatId(Chat.Id), From.Id, DateTime.Now.AddDays(1)), Bot.DeleteMessageAsync(targetChat, message.MessageId), Bot.SendTextMessageAsync(targetChat, - $"Member {From.ToHtml(true)} has been banned.\nReason:
Spam suspicion
", ParseMode.Html) + $"Member {From.ToHtml(true)} has been banned.\nReason:
Spam suspicion
", parseMode: ParseMode.Html) }); } } diff --git a/modules/UserGroupTag/Handler.cs b/modules/UserGroupTag/Handler.cs index 5f26a12..889cf9f 100644 --- a/modules/UserGroupTag/Handler.cs +++ b/modules/UserGroupTag/Handler.cs @@ -49,7 +49,7 @@ namespace UserGroupTag if (memberList.Contains(fromId)) { await Bot.SendTextMessageAsync(chatId, $"{from.ToHtml()} уже находится в группе {groupName}", - ParseMode.Html); + parseMode: ParseMode.Html); return; } memberList.Add(repliedMessage.From.Id); @@ -60,7 +60,7 @@ namespace UserGroupTag _userCache.SetValue(repliedMessage.From.Id, repliedMessage.From, Int32.MaxValue); await Bot.SendTextMessageAsync(chatId, $"{from.ToHtml()} добавлен в группу {groupName}", - ParseMode.Html); + parseMode: ParseMode.Html); } [ParametrizedCommand(InChat.Public, "tag_group", CommandParseMode.Both)] @@ -88,7 +88,7 @@ namespace UserGroupTag msg.UserMention(await GetUser(userId, Chat)).Text(", "); } - await Bot.SendTextMessageAsync(Chat.Id, msg.ToString().TrimEnd(',', ' '), ParseMode.Html); + await Bot.SendTextMessageAsync(Chat.Id, msg.ToString().TrimEnd(',', ' '), parseMode: ParseMode.Html); } protected async Task GetUser(long userId, Chat chat)