From 5e2e063aecb8ce4c5021bb41740c6e0d1dbd8e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E6=A2=A6?= Date: Wed, 23 Aug 2023 20:29:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Functions.cs | 14 +++++++------- src/Utils/ConfigHelper.cs | 2 +- src/Utils/MarkdownHelper.cs | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Functions.cs b/src/Functions.cs index d9fb134..d42703d 100644 --- a/src/Functions.cs +++ b/src/Functions.cs @@ -1,4 +1,4 @@ -using LiteDB; +using LiteDB; using Telegram.Bot; using Telegram.Bot.Exceptions; using Telegram.Bot.Types; @@ -18,16 +18,16 @@ public static async Task OnCallback(this CallbackQuery callbackQuery) return; } Internationalization lang = Program.I18n.GetI18n(callbackQuery.From.LanguageCode); - if (!Program.GroupData.TryGetValue(callbackQuery.Message.Chat.Id, out Dictionary? data) - || !data.TryGetValue(callbackQuery.From.Id, out int historyMessageId) - || historyMessageId != callbackQuery.Message.MessageId) + if (!Program.GroupData.TryGetValue(callbackQuery.Message.Chat.Id, out Dictionary? data) || + !data.TryGetValue(callbackQuery.From.Id, out int historyMessageId) || + historyMessageId != callbackQuery.Message.MessageId) { await Program.BotClient.AnswerCallbackQueryAsync(callbackQuery.Id, lang["Failed"]); return; } try { - await Program.BotClient.ApproveChatJoinRequest(callbackQuery.Message.Chat.Id, data[callbackQuery.From.Id]); + await Program.BotClient.ApproveChatJoinRequest(callbackQuery.Message.Chat.Id, callbackQuery.From.Id); } catch (ApiRequestException) { @@ -94,13 +94,13 @@ public static async Task OnSet(this Message message) } public static async Task OnJoin(this User member, long chatId, Dictionary data) { - if (!data.ContainsKey(member.Id)) + if (!data.TryGetValue(member.Id, out int value)) { return; } try { - await Program.BotClient.DeleteMessageAsync(chatId, data[member.Id]); + await Program.BotClient.DeleteMessageAsync(chatId, value); } catch (ApiRequestException) { diff --git a/src/Utils/ConfigHelper.cs b/src/Utils/ConfigHelper.cs index 6703a17..a52fc0d 100644 --- a/src/Utils/ConfigHelper.cs +++ b/src/Utils/ConfigHelper.cs @@ -1,4 +1,4 @@ -using System.Text.Json; +using System.Text.Json; namespace Yan.Utils; public record ConfigHelper(string Token, string ProxyUrl, bool EnableAutoI18n) diff --git a/src/Utils/MarkdownHelper.cs b/src/Utils/MarkdownHelper.cs index ee71240..c18ae83 100644 --- a/src/Utils/MarkdownHelper.cs +++ b/src/Utils/MarkdownHelper.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; namespace Yan.Utils;