trivia/joke.py
Fetch a random humorous joke or one-liner (icanhazdadjoke.com, no API key).
Use when the user asks for a joke or one-liner, or a caption or meme needs one.
- the file
- trivia/joke.py
- its skill
- trivia/SKILL.md (the whole trivia pack)
- as knowledge
- okf/trivia/joke.md
- on GitHub
- trivia/joke.py ↗
Run it
1. Once per machine: install fragletc (Docker must already be running).
curl -fsSL https://raw.githubusercontent.com/ofthemachine/fraglet/main/install.sh | sh
2. Fetch the tool and print its contract.
curl -fsSLO https://tools.ofthemachine.com/trivia/joke.py && chmod +x joke.py && ./joke.py --fraglet-help
3. Run it.
./joke.py
Parameters
| name | type | requirement | description |
|---|---|---|---|
| none | |||
Outputs
stdout
Provenance
- image
- ofthemachine/python3@sha256:a015b4f9f0e7c1648f8fcd4164f6a296dd3c9189404f88f333a9764d08d13522
- reach
network=required— output depends on live external state; do not cache indefinitely.- procedure_hash
- sha256:79672dc55ca623a0c60e3940cf75e78a61595553682873a2cf9eee589408b48e
- receipt
- add
--receipt run.jsonto any run;receipt/attest.pyverifies it against this hash without re-running.
Source
joke.py · 27 lines · sha256 79672dc55ca6…
#!/usr/bin/env -S fragletc --image ofthemachine/python3@sha256:a015b4f9f0e7c1648f8fcd4164f6a296dd3c9189404f88f333a9764d08d13522
#: d=Fetch a random humorous joke or one-liner (icanhazdadjoke.com, no API key).
#: when=Use when the user asks for a joke or one-liner, or a caption or meme needs one.
#: network=required
#: stdin=none
import sys
import urllib.request
req = urllib.request.Request(
"https://icanhazdadjoke.com/",
headers={
"Accept": "text/plain",
"User-Agent": "ofthemachine-tools (https://github.com/ofthemachine/tools)",
},
)
try:
with urllib.request.urlopen(req, timeout=15) as resp:
joke = resp.read().decode("utf-8").strip()
except Exception as e:
print(f"joke request failed: {e}", file=sys.stderr)
sys.exit(1)
if not joke:
print("response missing joke text", file=sys.stderr)
sys.exit(1)
print(joke)