Build in matrix bridge

This commit is contained in:
Nexus 2023-06-28 22:19:40 +01:00
parent c7a89dbe46
commit cde359461f
Signed by: nex
GPG key ID: 0FA334385D0B689F
4 changed files with 48 additions and 1 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <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"> <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"> <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>&quot;</identifier-quote-string> <identifier-quote-string>&quot;</identifier-quote-string>

View file

@ -365,6 +365,29 @@ class Events(commands.Cog):
if not message.guild: if not message.guild:
return 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.channel.name == "pinboard":
if message.type == discord.MessageType.pins_add: if message.type == discord.MessageType.pins_add:
await message.delete(delay=0.01) await message.delete(delay=0.01)

View file

@ -1540,6 +1540,8 @@ class OtherCog(commands.Cog):
use_tor: bool = False use_tor: bool = False
): ):
"""Sherlocks a username.""" """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: if re.search(r"\s", username) is not None:
return await ctx.respond("Username cannot contain spaces.") return await ctx.respond("Username cannot contain spaces.")

View file

@ -281,3 +281,25 @@ async def verify(code: str):
GENERAL, GENERAL,
status_code=308 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"}