Major command handling refactor

This commit is contained in:
Ske 2018-09-07 17:34:38 +02:00
parent 0869f94cdf
commit f067485e88
15 changed files with 463 additions and 355 deletions

View file

@ -1,9 +1,14 @@
from datetime import datetime
from datetime import datetime, timezone
from typing import List, Tuple
from pluralkit import db, Member
def fix_time(time: datetime):
# Assume we're receiving a naive datetime set to UTC, returns naive time zone set to local
return time.replace(tzinfo=timezone.utc).astimezone().replace(tzinfo=None)
async def get_fronter_ids(conn, system_id) -> (List[int], datetime):
switches = await db.front_history(conn, system_id=system_id, count=1)
if not switches:
@ -41,4 +46,4 @@ async def get_front_history(conn, system_id, count) -> List[Tuple[datetime, List
timestamp = switch["timestamp"]
members = [all_members[id] for id in switch["members"]]
out.append((timestamp, members))
return out
return out