From 26d89136b15babd46cf874e7d1eac641f686be2a Mon Sep 17 00:00:00 2001 From: Ske Date: Fri, 20 Jul 2018 22:56:32 +0200 Subject: [PATCH] Add a command for backdating switches --- bot/pluralkit/commands.py | 69 +++++++++++++++++++++++++++++++++++++-- bot/pluralkit/db.py | 5 +++ bot/pluralkit/help.py | 12 +++++++ bot/requirements.txt | 1 + 4 files changed, 85 insertions(+), 2 deletions(-) diff --git a/bot/pluralkit/commands.py b/bot/pluralkit/commands.py index 6bc6bf42..d56a9719 100644 --- a/bot/pluralkit/commands.py +++ b/bot/pluralkit/commands.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, timezone import io import itertools import json @@ -6,6 +6,7 @@ import os import re from urllib.parse import urlparse +import dateparser import discord from discord.utils import oauth_url import humanize @@ -464,7 +465,7 @@ async def switch_member(conn, message, args): if len(members) == 1: return False, "{} is already fronting.".format(members[0]["name"]) return False, "Members {} are already fronting.".format(", ".join([m["name"] for m in members])) - + # Log the switch async with conn.transaction(): switch_id = await db.add_switch(conn, system_id=system["id"]) @@ -492,6 +493,70 @@ async def switch_out(conn, message, args): await db.add_switch(conn, system_id=system["id"]) return True, "Switch-out registered." +@command(cmd="switch move", usage="