public static void LikeWithLimited(this Server core, IUser user, int incrementation = 1) { var span = DateTime.Now - new DateTime(core.Storage[user].Get(StorageKey.LastPlayingDate, 0L)); if (span < new TimeSpan(0, 0, 30)) { return; } core.Like(user.Id, incrementation); core.Storage[user].Set(StorageKey.LastPlayingDate, DateTime.Now.Ticks); }
public static bool TryApologyze(this Server core, IUser user, int incrementation = 1) { if (core.Storage[user].Get(StorageKey.HarrasmentedCount, 0) < 3) { core.Like(user.Id, incrementation); return(true); } else { return(false); } }
public override async Task <string> OnActivatedAsync(ICommandSender sender, Server core, IShell shell, string[] args, string body) { if (sender is not PostCommandSender p) { return("use from post"); } if (args.Length < 1) { throw new CommandException(); } switch (args[0].ToLowerInvariant().Trim()) { case "set": if (!sender.IsAdmin) { throw new AdminOnlyException(); } core.SetRatingValueOf(p.User.Id, int.Parse(args[1])); break; case "add": if (!sender.IsAdmin) { throw new AdminOnlyException(); } core.Like(p.User.Id, int.Parse(args[1])); break; case "get": return(core.GetRatingValueOf(p.User.Id).ToString()); case "status": return(core.GetRatingOf(p.User.Id).ToString()); } return("ok"); }