Add initial out-of-Matrix login system

This commit is contained in:
Tulir Asokan
2018-02-18 19:44:32 +02:00
parent 7d2af0ce75
commit ad11abb56e
11 changed files with 270 additions and 42 deletions
+2 -18
View File
@@ -19,6 +19,8 @@ import logging
from telethon.errors import FloodWaitError
from .util import format_duration
command_handlers = {}
@@ -65,24 +67,6 @@ class CommandEvent:
return self.az.intent.send_notice(self.room_id, message, html=html)
def format_duration(seconds):
def pluralize(count, singular): return singular if count == 1 else singular + "s"
def include(count, word): return f"{count} {pluralize(count, word)}" if count > 0 else ""
minutes, seconds = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60)
days, hours = divmod(hours, 24)
parts = [a for a in [
include(days, "day"),
include(hours, "hour"),
include(minutes, "minute"),
include(seconds, "second")] if a]
if len(parts) > 2:
return "{} and {}".format(", ".join(parts[:-1]), parts[-1])
return " and ".join(parts)
class CommandHandler:
log = logging.getLogger("mau.commands")