Add basic HTTP API

This commit is contained in:
Ske 2018-08-02 00:36:50 +02:00
parent e831ef5921
commit 944f0093a9
13 changed files with 238 additions and 51 deletions

View file

@ -6,6 +6,7 @@ import time
import asyncpg
import asyncpg.exceptions
from discord.utils import snowflake_time
from pluralkit import System, Member, stats
@ -210,6 +211,17 @@ class MessageInfo(namedtuple("MemberInfo", ["mid", "channel", "member", "content
system_name: str
system_hid: str
def to_json(self):
return {
"id": str(self.mid),
"channel": str(self.channel),
"member": self.hid,
"system": self.system_hid,
"message_sender": str(self.sender),
"content": self.content,
"timestamp": snowflake_time(self.mid).isoformat()
}
@db_wrap
async def get_message_by_sender_and_id(conn, message_id: str, sender_id: str) -> MessageInfo:
row = await conn.fetchrow("""select