iniciando o IFRO-aqs google Actions

parents
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
}
}
{
"parserOptions": {
// Required for certain syntax usages
"ecmaVersion": 6
},
"plugins": [
"promise"
],
"extends": "eslint:recommended",
"rules": {
// Removed rule "disallow the use of console" from recommended eslint rules
"no-console": "off",
// Removed rule "disallow multiple spaces in regular expressions" from recommended eslint rules
"no-regex-spaces": "off",
// Removed rule "disallow the use of debugger" from recommended eslint rules
"no-debugger": "off",
// Removed rule "disallow unused variables" from recommended eslint rules
"no-unused-vars": "off",
// Removed rule "disallow mixed spaces and tabs for indentation" from recommended eslint rules
"no-mixed-spaces-and-tabs": "off",
// Removed rule "disallow the use of undeclared variables unless mentioned in /*global */ comments" from recommended eslint rules
"no-undef": "off",
// Warn against template literal placeholder syntax in regular strings
"no-template-curly-in-string": 1,
// Warn if return statements do not either always or never specify values
"consistent-return": 1,
// Warn if no return statements in callbacks of array methods
"array-callback-return": 1,
// Require the use of === and !==
"eqeqeq": 2,
// Disallow the use of alert, confirm, and prompt
"no-alert": 2,
// Disallow the use of arguments.caller or arguments.callee
"no-caller": 2,
// Disallow null comparisons without type-checking operators
"no-eq-null": 2,
// Disallow the use of eval()
"no-eval": 2,
// Warn against extending native types
"no-extend-native": 1,
// Warn against unnecessary calls to .bind()
"no-extra-bind": 1,
// Warn against unnecessary labels
"no-extra-label": 1,
// Disallow leading or trailing decimal points in numeric literals
"no-floating-decimal": 2,
// Warn against shorthand type conversions
"no-implicit-coercion": 1,
// Warn against function declarations and expressions inside loop statements
"no-loop-func": 1,
// Disallow new operators with the Function object
"no-new-func": 2,
// Warn against new operators with the String, Number, and Boolean objects
"no-new-wrappers": 1,
// Disallow throwing literals as exceptions
"no-throw-literal": 2,
// Require using Error objects as Promise rejection reasons
"prefer-promise-reject-errors": 2,
// Enforce “for” loop update clause moving the counter in the right direction
"for-direction": 2,
// Enforce return statements in getters
"getter-return": 2,
// Disallow await inside of loops
"no-await-in-loop": 2,
// Disallow comparing against -0
"no-compare-neg-zero": 2,
// Warn against catch clause parameters from shadowing variables in the outer scope
"no-catch-shadow": 1,
// Disallow identifiers from shadowing restricted names
"no-shadow-restricted-names": 2,
// Enforce return statements in callbacks of array methods
"callback-return": 2,
// Require error handling in callbacks
"handle-callback-err": 2,
// Warn against string concatenation with __dirname and __filename
"no-path-concat": 1,
// Prefer using arrow functions for callbacks
"prefer-arrow-callback": 1,
// Return inside each then() to create readable and reusable Promise chains.
// Forces developers to return console logs and http calls in promises.
"promise/always-return": 2,
//Enforces the use of catch() on un-returned promises
"promise/catch-or-return": 2,
// Warn against nested then() or catch() statements
"promise/no-nesting": 1
}
}
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless
exports.get = (conv) => {
conv.ask('Eu não consigo ajudar agora');
}
\ No newline at end of file
const { dialogflow, SimpleResponse,BasicCard, Carousel, BrowseCarousel, BrowseCarouselItem, Image, Item, List } = require('actions-on-google');
const request = require('sync-request');
const base_url = 'https://api.colorado.ifro.edu.br/academico';
exports.get = (conv) => {
let params = conv.parameters;
//Selecionando o curso
var req = request('GET', `${base_url}/unidade/4/cursos`, {
headers: {
Authorization: 'key=Bi479DxWjsNFFcZOVyySbx2vZ7rhhdU4Gr8OeJ0W1qvE7hGHxsQlwhbUZVRttmsQ'
}
});
const cursos = JSON.parse(req.getBody('utf8')).cursos;
let curso = cursos.filter(c => c.nome.toLowerCase().includes(params.curso));
curso = curso[0];
//Selecionando a turma
req = request('GET', `${base_url}/curso/${curso.cursoId}/turmas/abertas`, {
headers: {
Authorization: 'key=Bi479DxWjsNFFcZOVyySbx2vZ7rhhdU4Gr8OeJ0W1qvE7hGHxsQlwhbUZVRttmsQ'
}
});
const turmas = JSON.parse(req.getBody('utf8')).turmas;
console.log(`Turmas` + JSON.stringify(turmas));
let turma = turmas.filter(t =>
t.identificador.includes(params.ano + params.turma.toUpperCase()));
turma = turma[0];
//Buscando os horários
req = request('GET', `${base_url}/turma/${turma.turmaId}/horarios`, {
headers: {
Authorization: 'key=Bi479DxWjsNFFcZOVyySbx2vZ7rhhdU4Gr8OeJ0W1qvE7hGHxsQlwhbUZVRttmsQ'
}
});
const horarios = JSON.parse(req.getBody('utf8')).horarios;
let horario = horarios[0];
let text = `Dia **${horario.dataHorario}**, *${horario.diaSemana}*: \n`;
let speech = "Encontrei essas aulas: ";
horario.aulas.forEach(a => {
var naula = a.nomeClasse.substring(a.nomeClasse.indexOf("-") +1, a.nomeClasse.length );
text = text.concat(`__${naula}__, às *${a.horarioInicio}*; \n`);
speech = speech.concat(`às ${a.horarioInicio}, aula de ${naula}. `);
});
conv.ask(new SimpleResponse({
speech: speech,
text: 'aqui está:'
}));
conv.ask(new BasicCard({
text: text, // Note the two spaces before '\n' required for
// a line break to be rendered in the card.
subtitle: `${curso.nome}`,
title: `horário de ${horario.dataHorario} `,
display: 'CROPPED',
//speech: speech,
}));
}
\ No newline at end of file
const functions = require('firebase-functions');
const {dialogflow} = require('actions-on-google');
const horario = require('./horario');
const help = require('./help');
let app = dialogflow({debug: true});
app.intent('horario', horario.get);
app.intent('help',(conv) => {
conv.ask('eu ajudo sim, agora mesmo');
});
exports.actionsifro = functions.https.onRequest(app);
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint .",
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"actions-on-google": "^2.3.0",
"axios": "^0.18.0",
"dialogflow-fulfillment": "^0.5.0",
"firebase-admin": "~5.13.0",
"firebase-functions": "^2.0.0",
"sync-request": "^6.0.0"
},
"devDependencies": {
"eslint": "^4.12.0",
"eslint-plugin-promise": "^3.6.0"
},
"private": true
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment