mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-20 02:26:32 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
3a0d77c128
2 changed files with 8 additions and 5 deletions
|
@ -257,7 +257,6 @@ class Events(commands.Cog):
|
||||||
await voice.move_to(message.author.voice.channel)
|
await voice.move_to(message.author.voice.channel)
|
||||||
|
|
||||||
if message.guild.me.voice.self_mute or message.guild.me.voice.mute:
|
if message.guild.me.voice.self_mute or message.guild.me.voice.mute:
|
||||||
await _dc(voice)
|
|
||||||
await message.channel.trigger_typing()
|
await message.channel.trigger_typing()
|
||||||
await message.reply("Unmute me >:(", file=discord.File(_file))
|
await message.reply("Unmute me >:(", file=discord.File(_file))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -54,6 +54,7 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
bot = None
|
bot = None
|
||||||
app.state.last_sender = None
|
app.state.last_sender = None
|
||||||
|
app.state.last_sender_ts = datetime.utcnow()
|
||||||
|
|
||||||
|
|
||||||
@app.middleware("http")
|
@app.middleware("http")
|
||||||
|
@ -291,6 +292,8 @@ async def verify(code: str):
|
||||||
|
|
||||||
@app.post("/bridge", include_in_schema=False, status_code=201)
|
@app.post("/bridge", include_in_schema=False, status_code=201)
|
||||||
async def bridge(req: Request):
|
async def bridge(req: Request):
|
||||||
|
now = datetime.utcnow()
|
||||||
|
ts_diff = (now - app.state.last_sender_ts).total_seconds()
|
||||||
from discord.ext.commands import Paginator
|
from discord.ext.commands import Paginator
|
||||||
body = await req.json()
|
body = await req.json()
|
||||||
if body["secret"] != app.state.bot.http.token:
|
if body["secret"] != app.state.bot.http.token:
|
||||||
|
@ -319,7 +322,7 @@ async def bridge(req: Request):
|
||||||
paginator.add_line(textwrap.shorten(line, width=1900, placeholder="<...>"))
|
paginator.add_line(textwrap.shorten(line, width=1900, placeholder="<...>"))
|
||||||
if len(paginator.pages) > 1:
|
if len(paginator.pages) > 1:
|
||||||
msg = None
|
msg = None
|
||||||
if app.state.last_sender != body["sender"]:
|
if app.state.last_sender != body["sender"] or ts_diff >= 600:
|
||||||
msg = await channel.send(
|
msg = await channel.send(
|
||||||
f"**{body['sender']}**:"
|
f"**{body['sender']}**:"
|
||||||
)
|
)
|
||||||
|
@ -330,20 +333,21 @@ async def bridge(req: Request):
|
||||||
allowed_mentions=discord.AllowedMentions.none(),
|
allowed_mentions=discord.AllowedMentions.none(),
|
||||||
reference=msg,
|
reference=msg,
|
||||||
silent=True,
|
silent=True,
|
||||||
suppress=True
|
suppress=n != m
|
||||||
)
|
)
|
||||||
app.state.last_sender = body["sender"]
|
app.state.last_sender = body["sender"]
|
||||||
else:
|
else:
|
||||||
content = f"**{body['sender']}**:\n>>> {body['message']}"
|
content = f"**{body['sender']}**:\n>>> {body['message']}"
|
||||||
if app.state.last_sender == body["sender"]:
|
if app.state.last_sender == body["sender"] and ts_diff < 600:
|
||||||
content = f">>> {body['message']}"
|
content = f">>> {body['message']}"
|
||||||
await channel.send(
|
await channel.send(
|
||||||
content,
|
content,
|
||||||
allowed_mentions=discord.AllowedMentions.none(),
|
allowed_mentions=discord.AllowedMentions.none(),
|
||||||
silent=True,
|
silent=True,
|
||||||
suppress=True
|
suppress=False
|
||||||
)
|
)
|
||||||
app.state.last_sender = body["sender"]
|
app.state.last_sender = body["sender"]
|
||||||
|
app.state.last_sender_ts = now
|
||||||
return {"status": "ok", "pages": len(paginator.pages)}
|
return {"status": "ok", "pages": len(paginator.pages)}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue