Bots: Update Owlbot from v1 to v2.
MODIFY
zulip_bots/zulip_bots/bots/define/define.py
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&nbsp;&nbsp;{}'.format(d['type'], d['defenition'], html2text.html2text(example))
+ response += '\n' + '* (**{}**) {}\n&nbsp;&nbsp;{}'.format(d['type'], d['definition'], html2text.html2text(example))
except Exception as e:
response += self.REQUEST_ERROR_MESSAGE

MODIFY
zulip_bots/zulip_bots/bots/define/fixtures/test_incorrect_word.json
zulip_bots/zulip_bots/bots/define/fixtures/test_incorrect_word.json
{
"request":{
- "api_url":"https://owlbot.info/api/v1/dictionary/foo?format=json"
+ "api_url":"https://owlbot.info/api/v2/dictionary/foo?format=json"
},
"response":[
],

MODIFY
zulip_bots/zulip_bots/bots/define/fixtures/test_multi_type_word.json
zulip_bots/zulip_bots/bots/define/fixtures/test_multi_type_word.json
{
"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!"
}
],

MODIFY
zulip_bots/zulip_bots/bots/define/fixtures/test_single_type_word.json
zulip_bots/zulip_bots/bots/define/fixtures/test_single_type_word.json
{
"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"
}
],

Bots: Update Owlbot from v1 to v2.