Add logging message text

This commit is contained in:
Ske 2018-07-14 21:16:39 +02:00
parent eb8802b453
commit 5bdd9af2e2
2 changed files with 4 additions and 3 deletions

View File

@ -150,10 +150,10 @@ async def add_webhook(conn, channel_id: str, webhook_id: str, webhook_token: str
@db_wrap @db_wrap
async def add_message(conn, message_id: str, channel_id: str, member_id: int, sender_id: str): async def add_message(conn, message_id: str, channel_id: str, member_id: int, sender_id: str, content: str):
logger.debug("Adding new message (id={}, channel={}, member={}, sender={})".format( logger.debug("Adding new message (id={}, channel={}, member={}, sender={})".format(
message_id, channel_id, member_id, sender_id)) message_id, channel_id, member_id, sender_id))
await conn.execute("insert into messages (mid, channel, member, sender) values ($1, $2, $3, $4)", int(message_id), int(channel_id), member_id, int(sender_id)) await conn.execute("insert into messages (mid, channel, member, sender, content) values ($1, $2, $3, $4, $5)", int(message_id), int(channel_id), member_id, int(sender_id), content)
@db_wrap @db_wrap
@ -255,6 +255,7 @@ async def create_tables(conn):
mid bigint primary key, mid bigint primary key,
channel bigint not null, channel bigint not null,
member serial not null references members(id) on delete cascade, member serial not null references members(id) on delete cascade,
content text not null,
sender bigint not null references accounts(uid) sender bigint not null references accounts(uid)
)""") )""")
await conn.execute("""create table if not exists switches ( await conn.execute("""create table if not exists switches (

View File

@ -123,7 +123,7 @@ async def proxy_message(conn, member, trigger_message, inner):
hook_message = await send_hook_message(member, hook_id, hook_token, text=inner, image_url=image_url) hook_message = await send_hook_message(member, hook_id, hook_token, text=inner, image_url=image_url)
# Insert new message details into the DB # Insert new message details into the DB
await db.add_message(conn, message_id=hook_message.id, channel_id=trigger_message.channel.id, member_id=member["id"], sender_id=trigger_message.author.id) await db.add_message(conn, message_id=hook_message.id, channel_id=trigger_message.channel.id, member_id=member["id"], sender_id=trigger_message.author.id, content=inner)
# Log message to logging channel if necessary # Log message to logging channel if necessary
log_channel = await get_log_channel(conn, trigger_message.server) log_channel = await get_log_channel(conn, trigger_message.server)