Hi, I'm Santiago Trigo Porres, I'm a web developer. I work in the big data world, creating graphics for data representation.
trigoporres / bot-telegram Goto Github PK
View Code? Open in Web Editor NEWCreating and testing bot telegram || Node Js
Creating and testing bot telegram || Node Js
/help: mostrara al usuario las posibilidades de uso del bot.
mensajes de conversación, probar posibilidad de usar dialogflow.
Guardar datos de usuario para una conversación mas fluida y personal.
Información del tiempo que hara ese día.
El bot tiene la funcionalidad de cuando envias "Parada 2340" (por ejemplo) te devuelve el tiempo y la distancia restante, también ofrece la posibilidad de enviar la ubicación de dicho autobus en ese momento.
El problema que me he encontrado (que hasta el momento no he podido resolver), la petición a la api de emt devuelve los autobuses en orden de llegada a la parada. Pero cuando dichos mensajes llegan a telegram aparecen desordenados.
`var busStopNumber = msg.text.replace("Parada",'');
emtmadApi.getIncomingBusesToStop( busStopNumber, (output) => {
if (output.status == 200 && output.arrives != undefined){
const chatId = msg.chat.id;
console.log(output.arrives)
for(var i = 0; i < output.arrives.length; i++){
bot.sendMessage(chatId, i + " El proximo autobus de la linea " +output.arrives[i] .lineId + " con destino " + output.arrives[i].destination + " va a tardar " + Math.trunc(output.arrives[i].busTimeLeft/60) + " minutos " + output.arrives[i].busDistance + " metros")
//bot.sendLocation(chatId,output.arrives[i].latitude,output.arrives[i].longitude);
console.log("prueba" + i)
}
}
else if (output.status == 400){
console.log(output.error);
}
else{
console.log("unknown error");
}
}); `
Este archivo correspondera a esos mensajes "predefinidos" que admite telegram, los cuales se inician con /.... Dichos mensajes llevaran una respuesta definida, puede utilizarse a modo de ayuda al usuario, para acciones mas comunes...
Estas funciones estarán deshabilitadas por el momento, ya que me parece que utilizarlas haría que se pierda la utilización fluida que debe tener un bot.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.