Skip to content

Commit

Permalink
feat: add special bang 'define' so define <word> can be used to def…
Browse files Browse the repository at this point in the history
…ine a word (merge pull request #75 from davidovski/definition_keyword)

QOL: Add define (keyword) to make a dictionary search
  • Loading branch information
Ahwxorg authored Nov 1, 2023
2 parents 2c74237 + 88bdcb1 commit 965d8b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions engines/special/definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ class DefinitionRequest extends EngineRequest {
public function get_request_url() {
$split_query = explode(" ", $this->query);
$reversed_split_q = array_reverse($split_query);
$word_to_define = $reversed_split_q[1];
$word_to_define = $reversed_split_q[1] == "define" ? $reversed_split_q[0] : $reversed_split_q[1];
return "https://api.dictionaryapi.dev/api/v2/entries/en/$word_to_define";
}

public function parse_results($response) {
$json_response = json_decode($response, true);

Expand All @@ -23,7 +23,7 @@ public function parse_results($response) {
)
);
}

}
}
?>
2 changes: 1 addition & 1 deletion engines/special/special.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function check_for_special_search($query) {
if ($amount_to_convert != 0)
return 1;
}
else if (strpos($query_lower, "mean") && count($split_query) >= 2) // definition
else if ((strpos($query_lower, "mean") || strpos($query_lower, "define") == 0) && count($split_query) >= 2) // definition
{
return 2;
}
Expand Down

0 comments on commit 965d8b0

Please sign in to comment.