コード例 #1
0
        public static async Task AddChat(long chatID)
        {
            if (Chats.All(x => x.Id != chatID))
            {
                await using (var db = new Database())
                {
                    var chat = new Chat
                    {
                        Id = chatID,
                        DisableAnnouncements = false,
                        DisableEvents        = true,
                        Locale = "ru"
                    };
                    Chats.Add(chat);
                    await db.Chats.AddAsync(chat);

                    await db.SaveChangesAsync();

                    Log.Information($"Added chat '{chatID}' to the chat list");
                }
            }
        }