mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-10 07:47:53 +00:00
Add basic HTTP API
This commit is contained in:
parent
e831ef5921
commit
944f0093a9
13 changed files with 238 additions and 51 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue