This commit is contained in:
Mirek Kratochvil 2025-10-12 14:07:08 +02:00
parent 18dea37595
commit dc30ac33ec

View file

@ -13,9 +13,9 @@ import time
VERSION = "0.1.0"
DPASTE_URL = "https://dpaste.com" # TODO any good way to parametrize this?
DPASTE_URL = "https://dpaste.com" # TODO any good way to parametrize this?
STATUS_LENGTH_LIMIT = 400 # TODO obtain from instance
STATUS_LENGTH_LIMIT = 400 # TODO obtain from instance
def trace(x):
@ -64,7 +64,7 @@ def do_pastebin_file(file):
# DPASTE API USE RULES:
# - user-agent must be set properly
# - 1 second between requests
trace(f"pasting {file}...")
trace(f"sending `{file}' to dpaste...")
r = requests.post(
DPASTE_URL + "/api/v2/",
data={
@ -75,9 +75,9 @@ def do_pastebin_file(file):
},
headers={"User-agent": f"patchodon v{VERSION}"},
)
time.sleep(1.1)
if r.status_code != 201:
raise (f"dpaste POST failed for `{file}'")
time.sleep(1.1)
return r.headers["location"] + ".txt"
@ -111,7 +111,7 @@ def do_post(args):
trace("posting the header...")
parent_post_id, url = do_post_status(
args,
f"{mayline(args.recipient)} {mayline(args.subject)}\n"
f"{mayline(args.recipient)}{mayline(args.subject)}"
f"[patchodon hash {full_hash} / {' '.join(short_hashes)}]",
)
for fn, pst, hsh, series in zip(