mirror of
https://github.com/Jetsparrow/karmabot.git
synced 2026-01-21 09:06:09 +03:00
Global leaderboards and specific statuses
This commit is contained in:
parent
0b40235c9b
commit
eae44695e7
@ -18,6 +18,7 @@ namespace JetKarmaBot.Commands
|
|||||||
var currentLocale = ctx.GetFeature<Locale>();
|
var currentLocale = ctx.GetFeature<Locale>();
|
||||||
var asker = ctx.EventArgs.Message.From;
|
var asker = ctx.EventArgs.Message.From;
|
||||||
var awardTypeName = ctx.Command.Parameters.FirstOrDefault();
|
var awardTypeName = ctx.Command.Parameters.FirstOrDefault();
|
||||||
|
bool isPrivate = ctx.EventArgs.Message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Private;
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(awardTypeName))
|
if (string.IsNullOrWhiteSpace(awardTypeName))
|
||||||
awardTypeName = "star";
|
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 ctx.SendMessage(string.Format(currentLocale["jetkarmabot.leaderboard.specifictext"], awardType.Symbol) + "\n" + string.Join('\n',
|
||||||
await Task.WhenAll((await db.Awards
|
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)
|
.GroupBy(x => x.ToId)
|
||||||
.Select(x => new { UserId = x.Key, Amount = x.Sum(y => y.Amount) })
|
.Select(x => new { UserId = x.Key, Amount = x.Sum(y => y.Amount) })
|
||||||
.OrderByDescending(x => x.Amount)
|
.OrderByDescending(x => x.Amount)
|
||||||
|
|||||||
@ -57,7 +57,7 @@ namespace JetKarmaBot.Commands
|
|||||||
await db.Awards.Where(
|
await db.Awards.Where(
|
||||||
x => x.AwardTypeId == awardTypeId
|
x => x.AwardTypeId == awardTypeId
|
||||||
&& x.ToId == asker.Id
|
&& 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);
|
.SumAsync(x => x.Amount), awardType.Symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user