Don't mention the author in every message

This commit is contained in:
Nexus 2023-07-12 18:34:20 +01:00
parent 7a9459f89a
commit 8a4addaf63
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -53,6 +53,7 @@ try:
app.state.bot = bot
except ImportError:
bot = None
app.state.last_sender = None
@app.middleware("http")
@ -317,6 +318,8 @@ async def bridge(req: Request):
except ValueError:
paginator.add_line(textwrap.shorten(line, width=1900, placeholder="<...>"))
if len(paginator.pages) > 1:
msg = None
if app.state.last_sender != body["sender"]:
msg = await channel.send(
f"**{body['sender']}**:"
)
@ -329,13 +332,18 @@ async def bridge(req: Request):
silent=True,
suppress=True
)
app.state.last_sender = body["sender"]
else:
content = f"**{body['sender']}**:\n>>> {body['message']}"
if app.state.last_sender == body["sender"]:
content = f">>> {body['message']}"
await channel.send(
f"**{body['sender']}**:\n>>> {body['message']}"[:2000],
content,
allowed_mentions=discord.AllowedMentions.none(),
silent=True,
suppress=True
)
app.state.last_sender = body["sender"]
return {"status": "ok", "pages": len(paginator.pages)}