summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdict.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/dict.py b/dict.py
index aca3fbf..31676d6 100755
--- a/dict.py
+++ b/dict.py
@@ -8,7 +8,7 @@ import sys # Import for potential error handling
# Customizable word list path
WORD_LIST_PATH = "~/.local/share/vocab/words.txt"
-def get_random_word_from_urban_dictionary():
+def fetch_dict():
"""Retrieves a random word and definition from Urban Dictionary API."""
url = "http://api.urbandictionary.com/v0/random"
@@ -24,7 +24,7 @@ def get_random_word_from_urban_dictionary():
except requests.exceptions.RequestException:
return None, None
-def get_random_word_from_local_file():
+def local_dict():
"""Retrieves a random word from the local word list."""
try:
# Expand '~' for the home directory in the path
@@ -40,10 +40,10 @@ def get_random_word_from_local_file():
return None
if __name__ == "__main__":
- word, definition = get_random_word_from_urban_dictionary()
+ word, definition = fetch_dict()
if not word: # Check if word retrieval failed
- word = get_random_word_from_local_file()
+ word = local_dict()
if word:
os.system(f"cowsay '{word} -> {definition if definition else ''}'")