Show "day"/"days" alongside day count

This commit is contained in:
jesopo 2018-12-20 20:30:23 +00:00
parent ba3c1673ad
commit 03a3bdd73d

View file

@ -21,6 +21,9 @@ class Module(ModuleManager.BaseModule):
def _set_badges(self, user, badges):
user.set_setting("badges", badges)
def _day_str(self, count: int):
return "day" + ("" if count == 1 else "s")
@utils.hook("received.command.badges")
def badges(self, event):
user = event["user"]
@ -31,7 +34,8 @@ class Module(ModuleManager.BaseModule):
badges = []
for badge, date in self._get_badges(user).items():
days_since = self._days_since(now, self._parse_datetime(date))
badges.append("%s: %s" % (badge, days_since))
badges.append("%s: %s %s" % (
badge, days_since, self._day_str(days_since)))
event["stdout"].write("Badges for %s: %s" % (
user.nickname, ", ".join(badges)))