diff --git a/zulip_bots/zulip_bots/bots/define/define.py b/zulip_bots/zulip_bots/bots/define/define.py index ec18548..aa171c7 100644 --- a/zulip_bots/zulip_bots/bots/define/define.py +++ b/zulip_bots/zulip_bots/bots/define/define.py @@ -13,7 +13,7 @@ class DefineHandler(object): looks for messages starting with '@mention-bot'. ''' - DEFINITION_API_URL = 'https://owlbot.info/api/v1/dictionary/{}?format=json' + DEFINITION_API_URL = 'https://owlbot.info/api/v2/dictionary/{}?format=json' REQUEST_ERROR_MESSAGE = 'Could not load definition.' EMPTY_WORD_REQUEST_ERROR_MESSAGE = 'Please enter a word to define.' PHRASE_ERROR_MESSAGE = 'Definitions for phrases are not available.' @@ -64,7 +64,7 @@ class DefineHandler(object): # Show definitions line by line. for d in definitions: example = d['example'] if d['example'] else '*No example available.*' - response += '\n' + '* (**{}**) {}\n  {}'.format(d['type'], d['defenition'], html2text.html2text(example)) + response += '\n' + '* (**{}**) {}\n  {}'.format(d['type'], d['definition'], html2text.html2text(example)) except Exception as e: response += self.REQUEST_ERROR_MESSAGE diff --git a/zulip_bots/zulip_bots/bots/define/fixtures/test_incorrect_word.json b/zulip_bots/zulip_bots/bots/define/fixtures/test_incorrect_word.json index 8f56269..82ddd2d 100644 --- a/zulip_bots/zulip_bots/bots/define/fixtures/test_incorrect_word.json +++ b/zulip_bots/zulip_bots/bots/define/fixtures/test_incorrect_word.json @@ -1,6 +1,6 @@ { "request":{ - "api_url":"https://owlbot.info/api/v1/dictionary/foo?format=json" + "api_url":"https://owlbot.info/api/v2/dictionary/foo?format=json" }, "response":[ ], diff --git a/zulip_bots/zulip_bots/bots/define/fixtures/test_multi_type_word.json b/zulip_bots/zulip_bots/bots/define/fixtures/test_multi_type_word.json index 7eb1bbf..4a16b57 100644 --- a/zulip_bots/zulip_bots/bots/define/fixtures/test_multi_type_word.json +++ b/zulip_bots/zulip_bots/bots/define/fixtures/test_multi_type_word.json @@ -1,31 +1,31 @@ { "request":{ - "api_url":"https://owlbot.info/api/v1/dictionary/help?format=json" + "api_url":"https://owlbot.info/api/v2/dictionary/help?format=json" }, "response":[ { "type":"verb", - "defenition":"make it easier or possible for (someone) to do something by offering them one's services or resources.", + "definition":"make it easier or possible for (someone) to do something by offering them one's services or resources.", "example":"they helped her with domestic chores" }, { "type":"verb", - "defenition":"serve someone with (food or drink).", + "definition":"serve someone with (food or drink).", "example":"may I help you to some more meat?" }, { "type":"verb", - "defenition":"cannot or could not avoid.", + "definition":"cannot or could not avoid.", "example":"he couldn't help laughing" }, { "type":"noun", - "defenition":"the action of helping someone to do something.", + "definition":"the action of helping someone to do something.", "example":"I asked for help from my neighbours" }, { "type":"exclamation", - "defenition":"used as an appeal for urgent assistance.", + "definition":"used as an appeal for urgent assistance.", "example":"Help! I'm drowning!" } ], diff --git a/zulip_bots/zulip_bots/bots/define/fixtures/test_single_type_word.json b/zulip_bots/zulip_bots/bots/define/fixtures/test_single_type_word.json index 6f286ed..38081a6 100644 --- a/zulip_bots/zulip_bots/bots/define/fixtures/test_single_type_word.json +++ b/zulip_bots/zulip_bots/bots/define/fixtures/test_single_type_word.json @@ -1,11 +1,11 @@ { "request":{ - "api_url":"https://owlbot.info/api/v1/dictionary/cat?format=json" + "api_url":"https://owlbot.info/api/v2/dictionary/cat?format=json" }, "response":[ { "type":"noun", - "defenition":"a small domesticated carnivorous mammal with soft fur, a short snout, and retractile claws. It is widely kept as a pet or for catching mice, and many breeds have been developed.", + "definition":"a small domesticated carnivorous mammal with soft fur, a short snout, and retractile claws. It is widely kept as a pet or for catching mice, and many breeds have been developed.", "example":"their pet cat" } ],