summaryrefslogtreecommitdiff
path: root/oedquery.sh
diff options
context:
space:
mode:
authorAsa Venton <asav1410@gmail.com>2020-10-19 17:17:39 +0100
committerAsa Venton <asav1410@gmail.com>2020-10-19 17:17:39 +0100
commite55219115930fc4c0505cef6a5f876a402562ed3 (patch)
tree35d375595bcf89945c6424b2bd08d6ced3277d84 /oedquery.sh
parentc70c04a07db87ed46675461edb162117293d24a4 (diff)
Add additional checks, adjust help output to reflect new name of command in the IRC bot.
Diffstat (limited to 'oedquery.sh')
-rwxr-xr-xoedquery.sh14
1 files changed, 12 insertions, 2 deletions
diff --git a/oedquery.sh b/oedquery.sh
index 6bdad65..50e9fd2 100755
--- a/oedquery.sh
+++ b/oedquery.sh
@@ -16,6 +16,10 @@ _jq() {
_getdata() {
# Take everything after final space as the requested word (assuming everything before the last space is a flag)
word=$(echo $word | sed 's/.* //')
+ if [[ "$word" = "null" ]]
+ then
+ echo "Missing word. Usage: !oed [option] [word]. Use -h for help."
+ fi
lemmasUrl=https://od-api.oxforddictionaries.com/api/v2/lemmas/$language/$word
# get lemmas to link an inflected form back to its headword (required to get definition)
result=$(eval curl $OPTS $lemmasUrl)
@@ -94,7 +98,12 @@ _thes() {
_audio() {
_getdata
output=$(echo "${result}" | jq '.results[0].lexicalEntries[0].entries[0].pronunciations[0].audioFile' | tr -d \")
- echo $output
+ if [[ "$output" != "null" ]]
+ then
+ echo $output
+ else
+ echo "No audio file found."
+ fi
exit 0
}
@@ -109,6 +118,7 @@ _wod() {
# Remove surrounding quotes
definition=$(echo "${definition:1: -1}")
lexicalCategory=$(echo "${lexicalCategory:1: -1}")
+ # Don't output example sentence if not returned from OED
if [[ "$examplePhrase" != "null" ]]
then
output=$word" - "$lexicalCategory" - "$definition" - "$examplePhrase
@@ -120,7 +130,7 @@ _wod() {
}
_help() {
- echo "Usage: !oeddefine [option] [word]. Options: -h help -t thesaurus -e etymology -d define -a audio -s source"
+ echo "Usage: !oed [option] [word]. Options: -h help -t thesaurus -e etymology -d define -a audio -s source"
exit 0
}