From eae44695e75bdc3eebe3c715ffe3e88060bc1ea2 Mon Sep 17 00:00:00 2001 From: Basique Evangelist Date: Sat, 13 Jun 2020 02:42:54 +0300 Subject: [PATCH] Global leaderboards and specific statuses --- JetKarmaBot/Commands/LeaderboardCommand.cs | 3 ++- JetKarmaBot/Commands/StatusCommand.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/JetKarmaBot/Commands/LeaderboardCommand.cs b/JetKarmaBot/Commands/LeaderboardCommand.cs index fc82e87..439c1cc 100644 --- a/JetKarmaBot/Commands/LeaderboardCommand.cs +++ b/JetKarmaBot/Commands/LeaderboardCommand.cs @@ -18,6 +18,7 @@ namespace JetKarmaBot.Commands var currentLocale = ctx.GetFeature(); var asker = ctx.EventArgs.Message.From; var awardTypeName = ctx.Command.Parameters.FirstOrDefault(); + bool isPrivate = ctx.EventArgs.Message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Private; if (string.IsNullOrWhiteSpace(awardTypeName)) awardTypeName = "star"; @@ -30,7 +31,7 @@ namespace JetKarmaBot.Commands await ctx.SendMessage(string.Format(currentLocale["jetkarmabot.leaderboard.specifictext"], awardType.Symbol) + "\n" + string.Join('\n', await Task.WhenAll((await db.Awards - .Where(x => x.ChatId == ctx.EventArgs.Message.Chat.Id && x.AwardTypeId == awardTypeId) + .Where(x => (x.ChatId == ctx.EventArgs.Message.Chat.Id || isPrivate) && x.AwardTypeId == awardTypeId) .GroupBy(x => x.ToId) .Select(x => new { UserId = x.Key, Amount = x.Sum(y => y.Amount) }) .OrderByDescending(x => x.Amount) diff --git a/JetKarmaBot/Commands/StatusCommand.cs b/JetKarmaBot/Commands/StatusCommand.cs index 3ef93c4..2d3276f 100644 --- a/JetKarmaBot/Commands/StatusCommand.cs +++ b/JetKarmaBot/Commands/StatusCommand.cs @@ -57,7 +57,7 @@ namespace JetKarmaBot.Commands await db.Awards.Where( x => x.AwardTypeId == awardTypeId && x.ToId == asker.Id - && x.ChatId == ctx.EventArgs.Message.Chat.Id) + && (x.ChatId == ctx.EventArgs.Message.Chat.Id || isPrivate)) .SumAsync(x => x.Amount), awardType.Symbol); }