Skip to content

Commit 168e062

Browse files
committed
Fix notes
1 parent 45135ec commit 168e062

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

app/constants/commands.py

+18-1
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,13 @@ async def _map(ctx: Context) -> Optional[str]:
727727
# and are generally for managing players.
728728
"""
729729

730+
ACTION_STRINGS = {
731+
"restrict": "Restricted for",
732+
"unrestrict": "Unrestricted for",
733+
"silence": "Silenced for",
734+
"unsilence": "Unsilenced for",
735+
"note": "Note added:"
736+
}
730737

731738
@command(Privileges.MODERATOR, hidden=True)
732739
async def notes(ctx: Context) -> Optional[str]:
@@ -755,7 +762,17 @@ async def notes(ctx: Context) -> Optional[str]:
755762
if not res:
756763
return f"No notes found on {t} in the past {days} days."
757764

758-
return "\n".join(["[{time}] {action} for {reason}".format(**row, reason=row["msg"] or "no reason specified") for row in res])
765+
return "\n".join(
766+
["[{time}] {action_str} {note} by {logger}".format(
767+
**row,
768+
logger=repr(
769+
await app.state.sessions.players.from_cache_or_sql(id=row["logger"])
770+
),
771+
action_str=ACTION_STRINGS[row["action"]],
772+
note=row["msg"] or "not specified"
773+
)
774+
for row in res]
775+
)
759776

760777

761778
@command(Privileges.MODERATOR, hidden=True)

migrations/base.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ create table logs
9999
primary key,
100100
`from` int not null comment 'both from and to are playerids',
101101
`to` int not null,
102-
`action` varchar(32) null,
103-
msg varchar(2048) charset utf8 not null,
102+
`action` varchar(32) not null,
103+
msg varchar(2048) charset utf8 null,
104104
time datetime not null on update CURRENT_TIMESTAMP
105105
);
106106

0 commit comments

Comments
 (0)