netresearch/matrix-skill / skills/matrix-communication
matrix-communication
FlaggedUse when communicating via Matrix chat, notifying teams, or managing E2EE. Triggers on #room:server references, Matrix URLs, and chat requests.
scripts/_lib/downloads.py
View on GitHub# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Netresearch DTT GmbH
"""Where a downloaded attachment is written. Stdlib only."""
import os
from pathlib import Path
DEFAULT_NAME = "media_download"
def download_target(directory, name) -> Path:
"""The path a download is saved to: the last component of ``name`` only.
The name usually comes from the message (its ``body``), so any directory
part is dropped, and a name that is empty or a directory reference
(``.``/``..``) is replaced by a fixed one.
"""
base = Path(name or "").name
if base in ("", ".", ".."):
base = DEFAULT_NAME
return Path(directory) / base
def write_download(path: Path, data: bytes, overwrite: bool = False) -> None:
"""Write ``data`` to ``path`` with mode 0600 without following a symlink.
An existing file is kept (FileExistsError) unless ``overwrite`` is set.
"""
flags = os.O_WRONLY | os.O_CREAT | os.O_NOFOLLOW
flags |= os.O_TRUNC if overwrite else os.O_EXCL
fd = os.open(path, flags, 0o600)
with os.fdopen(fd, "wb") as handle:
handle.write(data)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |