Fetches a tech joke or returns a fallback if offline.
()
| 33 | |
| 34 | import random |
| 35 | |
| 36 | def get_startup_note(): |
| 37 | """Fetches a tech joke or returns a fallback if offline.""" |
| 38 | fallbacks = [ |
| 39 | "💡 'To err is human, to complain is even more human.'", |
| 40 | "💡 There are 10 types of people: those who understand binary and those who don't.", |
| 41 | "💡 A SQL query walks into a bar, walks up to two tables, and asks... 'Can I join you?'", |
| 42 | "💡 Cybersecurity is the only industry where the 'bad guys' have a better R&D budget.", |
| 43 | "💡 Hardware: The parts of a computer system that can be kicked." |
| 44 | ] |
| 45 | try: |
| 46 | url = "https://v2.jokeapi.dev/joke/Programming?safe-mode&type=single" |
| 47 | response = requests.get(url, timeout=1.5) |
| 48 | if response.status_code == 200: |
| 49 | return f"💡 {response.json()['joke']}" |
| 50 | except Exception: |
| 51 | pass |
| 52 | return random.choice(fallbacks) |
| 53 | |
| 54 | def _dbg(debug: bool, msg: str = "", **style_kwargs) -> None: |