Bots: Update Owlbot from v1 to v2.
This commit is contained in:
parent
f253819a58
commit
62555f97a0
|
@ -13,7 +13,7 @@ class DefineHandler(object):
|
||||||
looks for messages starting with '@mention-bot'.
|
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.'
|
REQUEST_ERROR_MESSAGE = 'Could not load definition.'
|
||||||
EMPTY_WORD_REQUEST_ERROR_MESSAGE = 'Please enter a word to define.'
|
EMPTY_WORD_REQUEST_ERROR_MESSAGE = 'Please enter a word to define.'
|
||||||
PHRASE_ERROR_MESSAGE = 'Definitions for phrases are not available.'
|
PHRASE_ERROR_MESSAGE = 'Definitions for phrases are not available.'
|
||||||
|
@ -64,7 +64,7 @@ class DefineHandler(object):
|
||||||
# Show definitions line by line.
|
# Show definitions line by line.
|
||||||
for d in definitions:
|
for d in definitions:
|
||||||
example = d['example'] if d['example'] else '*No example available.*'
|
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:
|
except Exception as e:
|
||||||
response += self.REQUEST_ERROR_MESSAGE
|
response += self.REQUEST_ERROR_MESSAGE
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"request":{
|
"request":{
|
||||||
"api_url":"https://owlbot.info/api/v1/dictionary/foo?format=json"
|
"api_url":"https://owlbot.info/api/v2/dictionary/foo?format=json"
|
||||||
},
|
},
|
||||||
"response":[
|
"response":[
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,31 +1,31 @@
|
||||||
{
|
{
|
||||||
"request":{
|
"request":{
|
||||||
"api_url":"https://owlbot.info/api/v1/dictionary/help?format=json"
|
"api_url":"https://owlbot.info/api/v2/dictionary/help?format=json"
|
||||||
},
|
},
|
||||||
"response":[
|
"response":[
|
||||||
{
|
{
|
||||||
"type":"verb",
|
"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"
|
"example":"they helped her with domestic chores"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type":"verb",
|
"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?"
|
"example":"may I help you to some more meat?"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type":"verb",
|
"type":"verb",
|
||||||
"defenition":"cannot or could not avoid.",
|
"definition":"cannot or could not avoid.",
|
||||||
"example":"he couldn't help laughing"
|
"example":"he couldn't help laughing"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type":"noun",
|
"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"
|
"example":"I asked for help from my neighbours"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type":"exclamation",
|
"type":"exclamation",
|
||||||
"defenition":"used as an appeal for urgent assistance.",
|
"definition":"used as an appeal for urgent assistance.",
|
||||||
"example":"Help! I'm drowning!"
|
"example":"Help! I'm drowning!"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"request":{
|
"request":{
|
||||||
"api_url":"https://owlbot.info/api/v1/dictionary/cat?format=json"
|
"api_url":"https://owlbot.info/api/v2/dictionary/cat?format=json"
|
||||||
},
|
},
|
||||||
"response":[
|
"response":[
|
||||||
{
|
{
|
||||||
"type":"noun",
|
"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"
|
"example":"their pet cat"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue