mirror of
https://github.com/leon-ai/leon.git
synced 2024-12-01 03:15:58 +03:00
feat(package/trend): add answer when the Product Hunt developer token is not provided
This commit is contained in:
parent
24c153aa57
commit
f40b479b29
@ -22,7 +22,7 @@
|
||||
"test:unit": "cross-env PIPENV_PIPFILE=bridges/python/Pipfile jest --silent --projects test/unit/unit.jest.json",
|
||||
"test:e2e": "npm run test:e2e:nlp-modules && npm run test:e2e:modules",
|
||||
"test:e2e:modules": "npm run train expressions:en && cross-env PIPENV_PIPFILE=bridges/python/Pipfile jest --silent --verbose --projects test/e2e/modules/e2e.modules.jest.json && npm run train expressions",
|
||||
"test:e2e:nlp-modules": "npm run train expressions:en && cross-env PIPENV_PIPFILE=bridges/python/Pipfile jest --silent --verbose --setupTestFrameworkScriptFile=./test/paths.setup.js test/e2e/nlp-modules.spec.js && npm run train expressions",
|
||||
"test:e2e:nlp-modules": "cross-env PIPENV_PIPFILE=bridges/python/Pipfile jest --silent --verbose --setupTestFrameworkScriptFile=./test/paths.setup.js test/e2e/nlp-modules.spec.js && npm run train expressions",
|
||||
"test:json": "jest --silent --projects test/json/json.jest.json",
|
||||
"test:module": "babel-node scripts/test-module.js",
|
||||
"setup:offline": "babel-node scripts/setup-offline/setup-offline.js",
|
||||
|
@ -65,6 +65,10 @@
|
||||
"not_found": [
|
||||
"There is no product on that date.",
|
||||
"I did not find any product on that date."
|
||||
],
|
||||
"invalid_developer_token": [
|
||||
"Your Product Hunt developer token is invalid. Please provide a valid one by <a href=\"https://github.com/leon-ai/leon/blob/develop/packages/trend/README.md#product-hunt\" target=\"_blank\">reading this</a>.",
|
||||
"You did not set a valid Product Hunt developer token. Please set a valid one by <a href=\"https://github.com/leon-ai/leon/blob/develop/packages/trend/README.md#product-hunt\" target=\"_blank\">reading this</a>."
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -65,6 +65,10 @@
|
||||
"not_found": [
|
||||
"Il n'y a pas de produit à cette date.",
|
||||
"Je n'ai trouvé aucun produit à cette date."
|
||||
],
|
||||
"invalid_developer_token": [
|
||||
"Votre jeton de développeur Product Hunt est invalide. Merci d'en fournir un valide en <a href=\"https://github.com/leon-ai/leon/blob/develop/packages/trend/README.md#product-hunt\" target=\"_blank\">lisant ceci</a>.",
|
||||
"Vous n'avez pas bien configuré votre jeton de développeur Product Hunt. Veuillez en installer un valide en <a href=\"https://github.com/leon-ai/leon/blob/develop/packages/trend/README.md#product-hunt\" target=\"_blank\">lisant ceci</a>."
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,12 @@ def producthunt(string, entities):
|
||||
url = url + '?day=' + daydate
|
||||
|
||||
r = utils.http('GET', url, { 'Authorization': 'Bearer ' + developertoken })
|
||||
posts = list(enumerate(r.json()['posts']))
|
||||
response = r.json()
|
||||
|
||||
if 'error' in response and response['error'] == 'unauthorized_oauth':
|
||||
return utils.output('end', 'invalid_developer_token', utils.translate('invalid_developer_token'))
|
||||
|
||||
posts = list(enumerate(response['posts']))
|
||||
result = ''
|
||||
|
||||
if len(posts) == 0:
|
||||
|
@ -11,7 +11,8 @@ describe('trend:producthunt', async () => {
|
||||
expect([
|
||||
'reaching',
|
||||
'today',
|
||||
'unreachable'
|
||||
'unreachable',
|
||||
'invalid_developer_token'
|
||||
]).toIncludeAnyMembers(global.brain.finalOutput.codes)
|
||||
})
|
||||
})
|
||||
|
@ -165,7 +165,7 @@ class Brain {
|
||||
this.socket.emit('is-typing', false)
|
||||
|
||||
log.title(packageName)
|
||||
reject({ type: 'error', obj: data })
|
||||
reject({ type: 'error', obj: new Error(data) })
|
||||
})
|
||||
|
||||
// Catch the end of the module execution
|
||||
|
Loading…
Reference in New Issue
Block a user