mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
fix: remove another bunch of obsolete method calls
This commit is contained in:
@@ -39,7 +39,7 @@ public class DeleteService : AbstractTimedHostedService
|
||||
{
|
||||
try
|
||||
{
|
||||
await _bot.BotClient.DeleteMessageAsync(request.ChatId, request.MessageId);
|
||||
await _bot.BotClient.DeleteMessage(request.ChatId, request.MessageId);
|
||||
}
|
||||
catch (ApiRequestException e)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ public static class BotExtension
|
||||
|
||||
if (victim != null && canUse)
|
||||
{
|
||||
var victimMember = await bot.GetChatMemberAsync(chat, victim.Id);
|
||||
var victimMember = await bot.GetChatMember(chat, victim.Id);
|
||||
canUse = victimMember is not ChatMemberOwner && victimMember is not ChatMemberAdministrator && !victim.IsBot;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public static class BotExtension
|
||||
|
||||
public static async Task<bool> IsUserAdminAsync(this ITelegramBotClient bot, Chat chat, User user)
|
||||
{
|
||||
var callerMember = await bot.GetChatMemberAsync(chat, user.Id);
|
||||
var callerMember = await bot.GetChatMember(chat, user.Id);
|
||||
var isAdmin = callerMember is ChatMemberOwner;
|
||||
|
||||
if (callerMember is ChatMemberAdministrator callerAdmin)
|
||||
@@ -34,12 +34,12 @@ public static class BotExtension
|
||||
|
||||
public static async Task<bool> CanDeleteMessagesAsync(this ITelegramBotClient bot, Chat chat)
|
||||
{
|
||||
return await CanDeleteMessagesAsync(bot, chat, await bot.GetMeAsync());
|
||||
return await CanDeleteMessagesAsync(bot, chat, await bot.GetMe());
|
||||
}
|
||||
|
||||
public static async Task<bool> CanDeleteMessagesAsync(this ITelegramBotClient bot, Chat chat, User user)
|
||||
{
|
||||
return await bot.GetChatMemberAsync(chat.Id, user.Id) is ChatMemberOwner
|
||||
return await bot.GetChatMember(chat.Id, user.Id) is ChatMemberOwner
|
||||
or ChatMemberAdministrator {CanRestrictMembers: true};
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,6 @@ public abstract class CommonHandler : BotEventHandler
|
||||
|
||||
protected async Task AnswerQuery(string id, string? message = null)
|
||||
{
|
||||
await Bot.AnswerCallbackQueryAsync(id, message);
|
||||
await Bot.AnswerCallbackQuery(id, message);
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class SettingsHandler : CommonHandler
|
||||
return;
|
||||
}
|
||||
|
||||
await Bot.SendTextMessageAsync(
|
||||
await Bot.SendMessage(
|
||||
Chat.Id,
|
||||
"What do you want to change?",
|
||||
replyMarkup: GetSettingsMarkup()
|
||||
@@ -66,7 +66,7 @@ public class SettingsHandler : CommonHandler
|
||||
if (paramList[2] == "main_menu")
|
||||
{
|
||||
await AnswerQuery(query.Id);
|
||||
await Bot.EditMessageTextAsync(Chat.Id, query.Message!.MessageId, "What do you want to change?",
|
||||
await Bot.EditMessageText(Chat.Id, query.Message!.MessageId, "What do you want to change?",
|
||||
replyMarkup: GetSettingsMarkup());
|
||||
return;
|
||||
}
|
||||
@@ -103,14 +103,14 @@ public class SettingsHandler : CommonHandler
|
||||
await onOffOpt.SetValueAsync(chatId, !await onOffOpt.GetValueAsync(chatId));
|
||||
await AnswerQuery(query.Id);
|
||||
|
||||
await Bot.EditMessageReplyMarkupAsync(chatId, messageId, GetSettingsMarkup());
|
||||
await Bot.EditMessageReplyMarkup(chatId, messageId, GetSettingsMarkup());
|
||||
break;
|
||||
|
||||
case OptionType.Select:
|
||||
var selectOpt = (IOption<string>) option;
|
||||
await AnswerQuery(query.Id);
|
||||
|
||||
await Bot.EditMessageTextAsync(Chat.Id, messageId, "Here's what you can choose:",
|
||||
await Bot.EditMessageText(Chat.Id, messageId, "Here's what you can choose:",
|
||||
replyMarkup: await GetChoiceSelectKeyboard(selectOpt));
|
||||
break;
|
||||
|
||||
@@ -133,7 +133,7 @@ public class SettingsHandler : CommonHandler
|
||||
await selectOption.SetValueAsync(Chat.Id, choice.Id);
|
||||
await AnswerQuery(query.Id);
|
||||
|
||||
await Bot.EditMessageReplyMarkupAsync(Chat.Id, query.Message!.MessageId, await GetChoiceSelectKeyboard(selectOption));
|
||||
await Bot.EditMessageReplyMarkup(Chat.Id, query.Message!.MessageId, await GetChoiceSelectKeyboard(selectOption));
|
||||
}
|
||||
|
||||
private async Task<InlineKeyboardButton> GetKeyboardButton(IOption option)
|
||||
|
||||
@@ -69,7 +69,7 @@ public class UserService
|
||||
|
||||
private async Task<User> GetUserByChat(long chatId, long userId)
|
||||
{
|
||||
return (await _bot.GetChatMemberAsync(chatId, userId)).User;
|
||||
return (await _bot.GetChatMember(chatId, userId)).User;
|
||||
}
|
||||
|
||||
public bool IsUserSuper(User user)
|
||||
|
||||
@@ -29,12 +29,12 @@ namespace Kruzya.TelegramBot.Core
|
||||
|
||||
public async Task StartAsync(CancellationToken token)
|
||||
{
|
||||
await _client.SetWebhookAsync(_config.Webhook.Url, secretToken: _secretToken, cancellationToken: token);
|
||||
await _client.SetWebhook(_config.Webhook.Url, secretToken: _secretToken, cancellationToken: token);
|
||||
}
|
||||
|
||||
public async Task StopAsync(CancellationToken token)
|
||||
{
|
||||
await _client.DeleteWebhookAsync(cancellationToken: token);
|
||||
await _client.DeleteWebhook(cancellationToken: token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user