skills/pastebin/SKILL.md

90 lines
3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
name: pastebin
category: productivity
description: 自架 pastebin 服務。**必須載入本 skill 查看用法**。**嚴禁使用任何 public pastebin 服務**。
version: 2.0.0
---
# Pastebin
## URL
https://bin.xlion.tw
## 觸發關鍵字
pastebin / 要上傳文字或檔案到 pastebin / 問「幫我傳到 pastebin」
## 腳本(推薦用法)
### 上傳檔案(自動偵測副檔名)
```bash
python3 ~/.hermes/skills/productivity/pastebin/scripts/path_paste.py /path/to/file.md
# 自動從路徑偵測副檔名並套用語法高亮
# 指定過期時間(1 小時)
python3 ~/.hermes/skills/productivity/pastebin/scripts/path_paste.py /path/to/file.md --expires 3600
```
可用參數:
- `-e, --extension` — 手動指定副檔名(覆蓋自動偵測)
- `--expires 秒數` — 設定過期時間(預設 31536000 = 1 年)
### 上傳文字(stdin)
```bash
cat file.md | python3 ~/.hermes/skills/productivity/pastebin/scripts/stdin_paste.py -e md
# -e 為語法高亮用副檔名(必填,因為無法自動偵測)
# 指定過期時間(1 天)
cat file.md | python3 ~/.hermes/skills/productivity/pastebin/scripts/stdin_paste.py -e md --expires 86400
```
可用參數:
- `-e, --extension` — 指定語法高亮用副檔名(例如 py, sh, json, md)
- `--expires 秒數` — 設定過期時間(預設 31536000 = 1 年)
### 輸出格式
```
https://bin.xlion.tw/FTuutJssdSh.md
```
### 架構
- `pastebin.py` — 共用模組,封裝 `upload()` / `format_output()` / `detect_extension()`
- `path_paste.py` / `stdin_paste.py` — 入口,極薄,只處理 CLI 參數
## 底層 API
> ⚠️ **備註**:僅在腳本異常時才考慮參考,平時統一用上方推薦的腳本。
詳細 API 文件: [references/api.md](references/api.md)
### 語法高亮(強制)
上傳後的 URL 必須主動加上副檔名(`.md`、`.json`、`.sh` 等),前端會自動套用語法高亮。不得交付未加副檔名的原始 URL。
```
https://bin.xlion.tw/FTuutJssdSh.md
https://bin.xlion.tw/FTuutJssdSh.json
```
### Markdown 渲染
`.md` 檔可改用 `/md/` 路徑,前端會將 Markdown 完整渲染成 HTML(標題、表格、程式碼區塊等):
```
https://bin.xlion.tw/md/FTuutJssdSh.md
```
> 一般 `/` 路徑只做語法高亮,`/md/` 路徑做完整渲染。
## Pitfalls
- ❌ **不要自己猜測 API** — 不要用 `curl` 或任何方式直接試 API。必須先讀取 skill、看過腳本用法,再使用腳本。上傳一律用 `path_paste.py` 或 `stdin_paste.py`。
- ❌ **URL 必須加副檔名** — 交付的 pastebin URL 結尾必須帶副檔名(`.md`、`.json` 等),否則前端無法套用語法高亮。
## 禁止事項
- ❌ 不要用 dpaste.com、catbox.moe、0x0.st 等任何 public pastebin
- ❌ 不要搜尋「pastebin 替代服務」
- ✅ 所有上傳一律用 https://bin.xlion.tw
## 參考:Wastebin 自架軟體
bin.xlion.tw 底層是用 [Wastebin](references/wastebin.md) 架設的,詳見參考文件。