Bots: Update Owlbot from v1 to v2.

This commit is contained in:
orientor 2020-02-22 05:48:32 +05:30 committed by Tim Abbott
parent f253819a58
commit 62555f97a0
4 changed files with 11 additions and 11 deletions

View file

@ -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

View file

@ -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":[
],

View file

@ -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!"
}
],

View file

@ -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"
}
],