Skip to content

Commit

Permalink
Merge pull request #1 from OSWeekends/develop
Browse files Browse the repository at this point in the history
v0.1.0
  • Loading branch information
UlisesGascon authored Nov 20, 2016
2 parents c970b9e + 387eb17 commit 7749dac
Show file tree
Hide file tree
Showing 22 changed files with 2,269 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ jspm_packages

# Optional REPL history
.node_repl_history

# Ignore new data in config file
config.js
77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,79 @@
# OSWaldito
![oswaldito-front](images/oswaldito-front.jpg)

Robot Open Source que utilizamos en OSWeekends para gestionar redes sociales, telepresencia, etc....

**Redes Sociales**
- [Twitter (@OSWaldito_bot)](https://twitter.com/oswalditobot)

### Equipo
![oswaldito-team](images/osweekends-team.jpg)

OSWaldito es un proyecto de Open Source Weekends. Y es considerado un miembro más de la organización.

### Importante

**Arranque manual de FFMPEG**

```bash
sudo ffmpeg -s 320x240 -y -f v4l2 -i /dev/video0 -update 1 -r 30 /home/pi/Desktop/oswaldito/public/cam.jpg
```


### Software

**Sistema Operativo**
- [Raspbian Jessie](https://www.raspberrypi.org/blog/raspbian-jessie-is-here/)
- [Nodejs](https://nodejs.org/)
- [FFMPEG](https://www.ffmpeg.org/)

**Servidor**
- [pillars](https://www.npmjs.com/package/pillars)
- [rpio](https://www.npmjs.com/package/rpio)
- [socket.io](https://www.npmjs.com/package/socket.io)
- [hangouts-bot](https://www.npmjs.com/package/hangouts-bot)
- [scheduled](https://www.npmjs.com/package/scheduled)
- [slack-node](https://www.npmjs.com/package/slack-node)
- [twitter](https://www.npmjs.com/package/twitter)


**Cliente**
- [three.js](https://threejs.org/)

### Funcionalidades

**Robótica**
- Desplazamiento con WebSocket
- Simulación de VR en Cliente
- Simulación de voz en Cliente (parcial - En desarrollo)
- WebCam Stream frame a frame

**Comunicación**
- Escucha activamente ciertos hashtags de Twitter.
- Escucha activamente conversaciones en Google Hangouts
- Envia mensajes en Google Hangouts
- Envia mensajes en Slack
- Envia mensajes al azar clasificados por prioridad en Slack
- Envia mensajes de Error y estado al administrador en Goolgle Hangouts
- Puede ser desplegado en multiples entornos (Raspbian, Linux, OSX, Windows, C9...)
- Permite desplegar multiples avatares y personalidades desde la configuración para comunicarse en Slack

### Hardware
![hardware](images/hardware.jpg)

**Componentes**
- [Raspberry Pi 3 modelo B](https://www.amazon.es/dp/B01CD5VC92)
- [Pantalla - SunFounder 7" HD 1024*600 TFT LCD](https://www.amazon.es/gp/product/B012ZRYDYY)
- [Chasis Robótico - ALSRobot 4WD Aluminum Mobile Robot Platform (Car)](https://www.amazon.com/ALSRobot-Aluminum-Mobile-Robot-Platform/dp/B00ME4FI2U/ref=pd_sbs_21_4?_encoding=UTF8&pd_rd_i=B00ME4FI2U&pd_rd_r=HDKE8MN2G3KJDYD8DKWG&pd_rd_w=w3u5s&pd_rd_wg=Sk1We&psc=1&refRID=HDKE8MN2G3KJDYD8DKWG)
- [WebCam - Logitech C525](https://www.amazon.es/Logitech-C525-Webcam-Micr%C3%B3fono-Negro/dp/B0050FBISI/ref=sr_1_5?s=computers&ie=UTF8&qid=1479673606&sr=1-5&keywords=webcam+logitech)
- [Puente H - Módulo L298N doble puente H DC Stepper para Arduino](https://www.amazon.es/gp/product/B00HNHUYSG)

### Construcción

![chasis-1](images/chasis-1.jpg)
![chasis-2](images/chasis-2.jpg)

### Agradecimientos

- [Reloj](public/clock.html) *Gracias a [dtinth en Codepen](http://codepen.io/dtinth/pen/tDihg)*
- [VR simulación](public/vr.html) *Gracias a [sgang007/vrStreamer en Github](https://github.com/sgang007/vrStreamer)*
40 changes: 40 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var config = {
socialConnectionEnable: true,
hangouts: {
usuarioId: "",
usuarioAutorizado: "",
botEmail: "",
botPassword: ""
},
slack: {
webhookUri: "",
channel: "",
defaultMessage: "",
username: "",
icon: ""
},
twitter : {
consumer_key: "",
consumer_secret: "",
access_token_key: "",
access_token_secret: ""
},
event: {
hashtags: [],
timerPriority: {
high: 0,
medium: 0,
low: 0,
},
messagesByPriority: {
high: [],
medium: [],
low: [],
},
messagesScheduled: [
{cron: "", job: "", msg: ""}
]
}
};

module.exports = config;
132 changes: 132 additions & 0 deletions directo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
var config = require('./config'),
credentials = require('./config').twitter,
eventConfig = require('./config').event,
SlackConfig = require('./config').slack,
Scheduled = require("scheduled"),
twitter = require('twitter'),
hangoutsBot = require("hangouts-bot"),
Slack = require('slack-node');

var twitterStream = new twitter(credentials),
hashtags = eventConfig.hashtags,
slack = new Slack(),
masterUserRegex = new RegExp(config.hangouts.usuarioId),
masterUser = config.hangouts.usuarioAutorizado,
bot = new hangoutsBot(config.hangouts.botEmail, config.hangouts.botPassword),
slackRegex = /^[Ss]lack /;


// Slack
slack.setWebhook(SlackConfig.webhookUri);

function slackNotify(msg, details) {
details = details || {};
slack.webhook({
channel: details.channel || SlackConfig.channel,
text: msg || SlackConfig.defaultMessage,
username: details.username || SlackConfig.username,
icon_emoji: details.icon || SlackConfig.icon
}, function(err, response) {
if (err) {
bot.sendMessage(masterUser, "[Error] SLACK: " + err);
}
});
}

// Google Hangouts
bot.on('online', function() {
bot.sendMessage(masterUser, "Hola de nuevo, Jefe!");
});

bot.on('message', function(from, message) {
if (message === "Quien soy?") {
bot.sendMessage(from, "Yo te conozco como " + from);
} else if (slackRegex.test(message)) {
if (masterUserRegex.test(from)) {
message = message.replace(slackRegex, '');
slackNotify(message);
} else {
bot.sendMessage(from, 'Buen intento.. pero con esas zapatillas no envío mensajes!');
bot.sendMessage(masterUser, 'Intento de lanzar un mensaje por parte de ' + from + '\n Contenido: ' + message);
}
} else {
bot.sendMessage(from, "No te entiendo... Explicate mejor, Humano!");
}
});


// Twitter
twitterStream.stream('statuses/filter', {
track: hashtags.join(',')
}, function(stream) {

stream.on('data', function(tweet) {
if (tweet.text !== undefined) {

var data = {
username: "Twitter",
icon: "https://cdn3.iconfinder.com/data/icons/social-icons-5/607/Twitterbird.png"
};

slackNotify('https://twitter.com/' + tweet.user.screen_name + '/status/' + tweet.id_str, data);
}
});

stream.on('error', function(error, code) {
bot.sendMessage(masterUser, "[ERROR][Twitter-Stream] Código: " + code + ". Detalle: " + error + ". CC: @ulisesgascon");
});

});


// Bienvenida
slackNotify("Ya estoy Aquí! Se abren las notificaciones automáticas.\n¡Salvemos el mundo haciendo Software Libre!");


// Temporización via config.js
var messageManager = [];

for (var messages in eventConfig.messagesByPriority){
setTimer(messages);
}

function setTimer (key) {
if(eventConfig.timerPriority[key] && eventConfig.messagesByPriority[key]){
setInterval(function(){
slackNotify(eventConfig.messagesByPriority[key][Math.floor(Math.random() * eventConfig.messagesByPriority[key].length)]);
}, eventConfig.timerPriority[key]);
}

}

for (var item in eventConfig.messagesScheduled){
if(item.cron && item.job && item.msg){
messageManager.push(new Scheduled({
id: item.job,
pattern: item.cron,
task: function(){
slackNotify(item.msg);
}
}).start());
}
}


// Eventos
process.on('SIGINT', function() {
slackNotify("Me expulsan del canal! Ya no me quereis como antes... \ncc: @ulisesgascon te portas mal conmigo.");
bot.sendMessage(masterUser, "Me piro! Ya no me quieres como antes...");
process.exit();
});

process.on('exit', function() {
slackNotify("Salgo del canal! Pasarlo bien amigos.... \n¡Paz, amor y Open Source! \ncc: @ulisesgascon");
bot.sendMessage(masterUser, "Me piro! Vaciones por fín!");
process.exit();
});

process.on('uncaughtException', function() {
slackNotify("Salgo del canal! Cierre inesperado... \n¡Paz, amor y Open Source!\ncc: @ulisesgascon");
bot.sendMessage(masterUser, "Me piro! Cierre inesperado...");
process.exit();
});
Binary file added images/chasis-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/chasis-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/hardware.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/oswaldito-front.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/osweekends-team.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "oswaldito",
"version": "0.1.0",
"description": "Robot Open Source que utilizamos en OSWeekends para gestionar redes sociales, telepresencia, etc....",
"main": "server",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/OSWeekends/OSWaldito.git"
},
"keywords": [
"robot",
"raspberry",
"pi",
"iot",
"hardware",
"slack",
"socialbot"
],
"author": "Open Source Weekends",
"contributors": [
{
"name": "Ulises Gascón",
"url": "https://github.com/ulisesGascon"
}
],
"license": "GPL-3.0",
"bugs": {
"url": "https://github.com/OSWeekends/OSWaldito/issues"
},
"homepage": "https://github.com/OSWeekends/OSWaldito#readme",
"dependencies": {
"pillars": "0.3.7",
"rpio": "0.9.12",
"socket.io": "1.5.0",
"hangouts-bot": "0.2.1",
"scheduled": "0.4.5",
"slack-node": "0.1.8",
"twitter": "1.4.0"
}
}
Loading

0 comments on commit 7749dac

Please sign in to comment.