fix: remove another bunch of obsolete method calls

This commit is contained in:
Andriy
2025-02-09 17:50:46 +02:00
parent c3a553f68d
commit 50774e1af6
17 changed files with 40 additions and 40 deletions
+2 -2
View File
@@ -42,11 +42,11 @@ public class Ban : CommonHandler
}
catch
{
await Bot.SendTextMessageAsync(Chat.Id, "Нет прав на блокировку пользователя.");
await Bot.SendMessage(Chat.Id, "Нет прав на блокировку пользователя.");
return;
}
await Bot.SendTextMessageAsync(
await Bot.SendMessage(
Chat.Id,
$"{From.ToHtml()} <code>заблокировал</code> {RepliedUser!.ToHtml()} <code>{banEndMsg}</code>",
disableNotification: true, parseMode: ParseMode.Html);
@@ -38,7 +38,7 @@ public partial class BanStickerSet
var replyToMsgId = Message?.ReplyToMessage?.MessageId;
if (replyToMsgId != null)
{
await Bot.DeleteMessageAsync(Chat.Id, (int) replyToMsgId);
await Bot.DeleteMessage(Chat.Id, (int) replyToMsgId);
}
await Reply(FormatStickerSetAction(stickerSet.Set, "заблокирован"));
@@ -90,7 +90,7 @@ public partial class BanStickerSet
{
try
{
var stickerSet = await Bot.GetStickerSetAsync(list[i]);
var stickerSet = await Bot.GetStickerSet(list[i]);
htmlString.Text($"{i + 1}. ")
.Url("https://t.me/addstickers/" + stickerSet.Name, stickerSet.Title)
.Br();
@@ -125,7 +125,7 @@ public partial class BanStickerSet
"Этот набор стикеров заблокирован. Чтобы я мог его удалить, выдайте мне право на удаление сообщений.");
}
await Bot.DeleteMessageAsync(Chat.Id, message.MessageId);
await Bot.DeleteMessage(Chat.Id, message.MessageId);
}
}
}
@@ -14,9 +14,9 @@ public partial class BanStickerSet
{
private async Task<bool> CanBotDeleteMessages()
{
return await Bot.GetChatMemberAsync(
return await Bot.GetChatMember(
Chat.Id,
(await Bot.GetMeAsync()).Id
(await Bot.GetMe()).Id
) is ChatMemberAdministrator {CanDeleteMessages: true};
}
@@ -58,7 +58,7 @@ public partial class BanStickerSet
private async Task<bool> CanUseCommands()
{
return await Bot.GetChatMemberAsync(Chat.Id, From.Id) is ChatMemberAdministrator {CanDeleteMessages: true}
return await Bot.GetChatMember(Chat.Id, From.Id) is ChatMemberAdministrator {CanDeleteMessages: true}
or ChatMemberOwner;
}
}
+1 -1
View File
@@ -39,7 +39,7 @@ class Rules : CommonHandler
try
{
await Bot.CopyMessageAsync(Chat.Id, Chat.Id, await _rulesService.GetRulesMessageIdAsync(Chat) ?? 0);
await Bot.CopyMessage(Chat.Id, Chat.Id, await _rulesService.GetRulesMessageIdAsync(Chat) ?? 0);
}
catch (ApiRequestException)
{
+1 -1
View File
@@ -55,7 +55,7 @@ public class WhoIs : CommonHandler
return customStatus;
}
var chatMember = await Bot.GetChatMemberAsync(Chat.Id, user.Id);
var chatMember = await Bot.GetChatMember(Chat.Id, user.Id);
return chatMember.Status switch
{
ChatMemberStatus.Creator => "Владелец",
+3 -3
View File
@@ -9,14 +9,14 @@ public class Notifier
{
public static async void WarnNotify(ITelegramBotClient bot, Chat chat, User from, User to, int count, bool isBanned = false)
{
await bot.SendTextMessageAsync(chat.Id, $"{to.ToHtml()}<code>, Вам выдано предупреждение! " +
await bot.SendMessage(chat.Id, $"{to.ToHtml()}<code>, Вам выдано предупреждение! " +
$"Текущее кол-во: {count}/3</code>",
disableNotification: true,
parseMode: ParseMode.Html);
if (isBanned)
{
await bot.SendTextMessageAsync(
await bot.SendMessage(
chat.Id,
$"{from.ToHtml()} <code>заблокировал</code> {to.ToHtml()} <code>на 7 дней</code>",
disableNotification: true, parseMode: ParseMode.Html);
@@ -25,7 +25,7 @@ public class Notifier
public static async void UnWarnNotify(ITelegramBotClient bot, Chat chat, User from, User to, int count)
{
await bot.SendTextMessageAsync(chat.Id,
await bot.SendMessage(chat.Id,
$"{to.ToHtml()}<code>, с Вас снято предупреждение! " +
$"Текущее кол-во: {count}/3</code>",
disableNotification: true,
@@ -43,7 +43,7 @@ public class StickerSet
var sticker = message?.ReplyToMessage?.Sticker;
if (sticker is { SetName: { } })
{
result.Set = bot.GetStickerSetAsync(sticker.SetName).GetAwaiter().GetResult();
result.Set = bot.GetStickerSet(sticker.SetName).GetAwaiter().GetResult();
result.IsValid = true;
return true;
}
@@ -56,7 +56,7 @@ public class StickerSet
{
try
{
result.Set = bot.GetStickerSetAsync(setName.First())
result.Set = bot.GetStickerSet(setName.First())
.GetAwaiter()
.GetResult();
result.IsValid = true;
+4 -4
View File
@@ -103,9 +103,9 @@ public class Handler : BotEventHandler
public async Task UploadDetectedCode(Message message)
{
var resp = await _haste.PostDocumentAsync(message.Text!);
await Bot.DeleteMessageAsync(Chat.Id, message.MessageId);
await Bot.DeleteMessage(Chat.Id, message.MessageId);
await Bot.SendTextMessageAsync(Chat.Id,
await Bot.SendMessage(Chat.Id,
$"{message.From?.ToHtml()}, you posted something long and pre-escaped, so I decided to upload it to our paste service for you.\n" +
$"Here is the link: {_haste.GetHasteUri() + resp.Key}",
parseMode: ParseMode.Html);
@@ -113,8 +113,8 @@ public class Handler : BotEventHandler
public async Task RemoveDetectedCode(Message message)
{
await Bot.DeleteMessageAsync(Chat.Id, message.MessageId);
var notifyMsg = await Bot.SendTextMessageAsync(Chat.Id,
await Bot.DeleteMessage(Chat.Id, message.MessageId);
var notifyMsg = await Bot.SendMessage(Chat.Id,
(message.From?.ToHtml() ?? "") + ", не стоит публиковать столь большой код прямо в чат. " +
"Вместо этого загрузите его на https://pastebin.com и отправьте в виде ссылки.",
parseMode: ParseMode.Html);
+3 -3
View File
@@ -23,7 +23,7 @@ public class UserJoinHandler : BotEventHandler
[Message(MessageFlag.HasNewChatMembers)]
public async Task OnUserJoined()
{
var canKickMembers = await Bot.IsUserAdminAsync(Chat, await Bot.GetMeAsync());
var canKickMembers = await Bot.IsUserAdminAsync(Chat, await Bot.GetMe());
foreach (var member in RawUpdate.Message!.NewChatMembers!)
{
@@ -38,11 +38,11 @@ public class UserJoinHandler : BotEventHandler
messageText.Append(
$"More details you can find on <a href=\"https://cas.chat/query?u={member.Id}\">CAS site</a>.");
await Bot.SendTextMessageAsync(Chat, messageText.ToString(), parseMode: ParseMode.Html);
await Bot.SendMessage(Chat, messageText.ToString(), parseMode: ParseMode.Html);
if (canKickMembers)
{
await Bot.BanChatMemberAsync(Chat, member.Id);
await Bot.BanChatMember(Chat, member.Id);
}
}
}
+3 -3
View File
@@ -38,14 +38,14 @@ public class Store : CommonHandler
if (_reputation == null)
{
await Bot.SendTextMessageAsync(Chat.Id, "Reputation is unavailable.");
await Bot.SendMessage(Chat.Id, "Reputation is unavailable.");
return;
}
var user = From;
var reputation = await _reputation.GetUserReputationAsync(Chat, user);
await Bot.SendTextMessageAsync(Chat.Id, $"<b>{user.ToHtml()} ({reputation})</b>, чего пожелаете?", parseMode: ParseMode.Html,
await Bot.SendMessage(Chat.Id, $"<b>{user.ToHtml()} ({reputation})</b>, чего пожелаете?", parseMode: ParseMode.Html,
replyMarkup: new InlineKeyboardMarkup(
_provider.GetServices<IRandomMediaService>()
.ToAsyncEnumerable()
@@ -99,7 +99,7 @@ public class Store : CommonHandler
var reputation = await _reputation.GetUserReputationAsync(Chat, From);
if (reputation < storeItem.Price)
{
await Bot.EditMessageTextAsync(
await Bot.EditMessageText(
Chat.Id,
messageId,
$"<b>{From.ToHtml()} ({reputation})</b>, продолжай работать и тебе обязательно хватит на покупку.",
+1 -1
View File
@@ -182,7 +182,7 @@ public class Reputation : CommonHandler
i++;
}
await Bot.SendTextMessageAsync(Chat!, msg.ToString(), parseMode: ParseMode.Html,
await Bot.SendMessage(Chat!, msg.ToString(), parseMode: ParseMode.Html,
disableNotification: true);
}