mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
Build in matrix bridge
This commit is contained in:
parent
c7a89dbe46
commit
cde359461f
4 changed files with 48 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="dataSourceStorageLocal" created-in="PY-231.9011.38">
|
||||
<component name="dataSourceStorageLocal" created-in="PY-231.9161.41">
|
||||
<data-source name="main" uuid="28efee07-d306-4126-bf69-01008b4887e2">
|
||||
<database-info product="SQLite" version="3.39.2" jdbc-version="2.1" driver-name="SQLite JDBC" driver-version="3.39.2.0" dbms="SQLITE" exact-version="3.39.2" exact-driver-version="3.39">
|
||||
<identifier-quote-string>"</identifier-quote-string>
|
||||
|
|
|
@ -365,6 +365,29 @@ class Events(commands.Cog):
|
|||
if not message.guild:
|
||||
return
|
||||
|
||||
if message.channel.name == "femboy-hole":
|
||||
if Path("/tmp/jimmy-bridge").exists():
|
||||
payload = {
|
||||
"author": str(message.user),
|
||||
"content": message.content,
|
||||
"attachments": [
|
||||
{
|
||||
"url": a.url,
|
||||
"filename": a.filename,
|
||||
"size": a.size,
|
||||
"width": a.width,
|
||||
"height": a.height,
|
||||
"content_type": a.content_type,
|
||||
}
|
||||
for a in message.attachments
|
||||
]
|
||||
}
|
||||
dumped = json.dumps(payload, separators=(",", ":")).encode()
|
||||
buffer_need = 8192 - len(dumped)
|
||||
if buffer_need > 0:
|
||||
dumped += b"\0" * buffer_need
|
||||
Path("/tmp/jimmy-bridge").write_bytes(dumped)
|
||||
|
||||
if message.channel.name == "pinboard":
|
||||
if message.type == discord.MessageType.pins_add:
|
||||
await message.delete(delay=0.01)
|
||||
|
|
|
@ -1540,6 +1540,8 @@ class OtherCog(commands.Cog):
|
|||
use_tor: bool = False
|
||||
):
|
||||
"""Sherlocks a username."""
|
||||
# git clone https://github.com/sherlock-project/sherlock.git && cd sherlock && docker build -t sherlock .
|
||||
|
||||
if re.search(r"\s", username) is not None:
|
||||
return await ctx.respond("Username cannot contain spaces.")
|
||||
|
||||
|
|
|
@ -281,3 +281,25 @@ async def verify(code: str):
|
|||
GENERAL,
|
||||
status_code=308
|
||||
)
|
||||
|
||||
|
||||
@app.post("/bridge")
|
||||
async def bridge(req: Request):
|
||||
body = await req.json()
|
||||
if body["secret"] != app.state.bot.http.token:
|
||||
raise HTTPException(
|
||||
status_code=401,
|
||||
detail="Invalid secret."
|
||||
)
|
||||
|
||||
channel = app.state.bot.get_channel(1032974266527907901)
|
||||
if not channel:
|
||||
raise HTTPException(
|
||||
status_code=404,
|
||||
detail="Channel does not exist."
|
||||
)
|
||||
|
||||
await channel.send(
|
||||
f"**{body['sender']}**:\n>>> {body['message']}"
|
||||
)
|
||||
return {"status": "ok"}
|
||||
|
|
Loading…
Reference in a new issue