Skip to content

Commit 7749dac

Browse files
authored
Merge pull request #1 from OSWeekends/develop
v0.1.0
2 parents c970b9e + 387eb17 commit 7749dac

22 files changed

+2269
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ jspm_packages
3535

3636
# Optional REPL history
3737
.node_repl_history
38+
39+
# Ignore new data in config file
40+
config.js

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,79 @@
11
# OSWaldito
2+
![oswaldito-front](images/oswaldito-front.jpg)
3+
24
Robot Open Source que utilizamos en OSWeekends para gestionar redes sociales, telepresencia, etc....
5+
6+
**Redes Sociales**
7+
- [Twitter (@OSWaldito_bot)](https://twitter.com/oswalditobot)
8+
9+
### Equipo
10+
![oswaldito-team](images/osweekends-team.jpg)
11+
12+
OSWaldito es un proyecto de Open Source Weekends. Y es considerado un miembro más de la organización.
13+
14+
### Importante
15+
16+
**Arranque manual de FFMPEG**
17+
18+
```bash
19+
sudo ffmpeg -s 320x240 -y -f v4l2 -i /dev/video0 -update 1 -r 30 /home/pi/Desktop/oswaldito/public/cam.jpg
20+
```
21+
22+
23+
### Software
24+
25+
**Sistema Operativo**
26+
- [Raspbian Jessie](https://www.raspberrypi.org/blog/raspbian-jessie-is-here/)
27+
- [Nodejs](https://nodejs.org/)
28+
- [FFMPEG](https://www.ffmpeg.org/)
29+
30+
**Servidor**
31+
- [pillars](https://www.npmjs.com/package/pillars)
32+
- [rpio](https://www.npmjs.com/package/rpio)
33+
- [socket.io](https://www.npmjs.com/package/socket.io)
34+
- [hangouts-bot](https://www.npmjs.com/package/hangouts-bot)
35+
- [scheduled](https://www.npmjs.com/package/scheduled)
36+
- [slack-node](https://www.npmjs.com/package/slack-node)
37+
- [twitter](https://www.npmjs.com/package/twitter)
38+
39+
40+
**Cliente**
41+
- [three.js](https://threejs.org/)
42+
43+
### Funcionalidades
44+
45+
**Robótica**
46+
- Desplazamiento con WebSocket
47+
- Simulación de VR en Cliente
48+
- Simulación de voz en Cliente (parcial - En desarrollo)
49+
- WebCam Stream frame a frame
50+
51+
**Comunicación**
52+
- Escucha activamente ciertos hashtags de Twitter.
53+
- Escucha activamente conversaciones en Google Hangouts
54+
- Envia mensajes en Google Hangouts
55+
- Envia mensajes en Slack
56+
- Envia mensajes al azar clasificados por prioridad en Slack
57+
- Envia mensajes de Error y estado al administrador en Goolgle Hangouts
58+
- Puede ser desplegado en multiples entornos (Raspbian, Linux, OSX, Windows, C9...)
59+
- Permite desplegar multiples avatares y personalidades desde la configuración para comunicarse en Slack
60+
61+
### Hardware
62+
![hardware](images/hardware.jpg)
63+
64+
**Componentes**
65+
- [Raspberry Pi 3 modelo B](https://www.amazon.es/dp/B01CD5VC92)
66+
- [Pantalla - SunFounder 7" HD 1024*600 TFT LCD](https://www.amazon.es/gp/product/B012ZRYDYY)
67+
- [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)
68+
- [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)
69+
- [Puente H - Módulo L298N doble puente H DC Stepper para Arduino](https://www.amazon.es/gp/product/B00HNHUYSG)
70+
71+
### Construcción
72+
73+
![chasis-1](images/chasis-1.jpg)
74+
![chasis-2](images/chasis-2.jpg)
75+
76+
### Agradecimientos
77+
78+
- [Reloj](public/clock.html) *Gracias a [dtinth en Codepen](http://codepen.io/dtinth/pen/tDihg)*
79+
- [VR simulación](public/vr.html) *Gracias a [sgang007/vrStreamer en Github](https://github.com/sgang007/vrStreamer)*

config.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
var config = {
2+
socialConnectionEnable: true,
3+
hangouts: {
4+
usuarioId: "",
5+
usuarioAutorizado: "",
6+
botEmail: "",
7+
botPassword: ""
8+
},
9+
slack: {
10+
webhookUri: "",
11+
channel: "",
12+
defaultMessage: "",
13+
username: "",
14+
icon: ""
15+
},
16+
twitter : {
17+
consumer_key: "",
18+
consumer_secret: "",
19+
access_token_key: "",
20+
access_token_secret: ""
21+
},
22+
event: {
23+
hashtags: [],
24+
timerPriority: {
25+
high: 0,
26+
medium: 0,
27+
low: 0,
28+
},
29+
messagesByPriority: {
30+
high: [],
31+
medium: [],
32+
low: [],
33+
},
34+
messagesScheduled: [
35+
{cron: "", job: "", msg: ""}
36+
]
37+
}
38+
};
39+
40+
module.exports = config;

directo.js

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
var config = require('./config'),
2+
credentials = require('./config').twitter,
3+
eventConfig = require('./config').event,
4+
SlackConfig = require('./config').slack,
5+
Scheduled = require("scheduled"),
6+
twitter = require('twitter'),
7+
hangoutsBot = require("hangouts-bot"),
8+
Slack = require('slack-node');
9+
10+
var twitterStream = new twitter(credentials),
11+
hashtags = eventConfig.hashtags,
12+
slack = new Slack(),
13+
masterUserRegex = new RegExp(config.hangouts.usuarioId),
14+
masterUser = config.hangouts.usuarioAutorizado,
15+
bot = new hangoutsBot(config.hangouts.botEmail, config.hangouts.botPassword),
16+
slackRegex = /^[Ss]lack /;
17+
18+
19+
// Slack
20+
slack.setWebhook(SlackConfig.webhookUri);
21+
22+
function slackNotify(msg, details) {
23+
details = details || {};
24+
slack.webhook({
25+
channel: details.channel || SlackConfig.channel,
26+
text: msg || SlackConfig.defaultMessage,
27+
username: details.username || SlackConfig.username,
28+
icon_emoji: details.icon || SlackConfig.icon
29+
}, function(err, response) {
30+
if (err) {
31+
bot.sendMessage(masterUser, "[Error] SLACK: " + err);
32+
}
33+
});
34+
}
35+
36+
// Google Hangouts
37+
bot.on('online', function() {
38+
bot.sendMessage(masterUser, "Hola de nuevo, Jefe!");
39+
});
40+
41+
bot.on('message', function(from, message) {
42+
if (message === "Quien soy?") {
43+
bot.sendMessage(from, "Yo te conozco como " + from);
44+
} else if (slackRegex.test(message)) {
45+
if (masterUserRegex.test(from)) {
46+
message = message.replace(slackRegex, '');
47+
slackNotify(message);
48+
} else {
49+
bot.sendMessage(from, 'Buen intento.. pero con esas zapatillas no envío mensajes!');
50+
bot.sendMessage(masterUser, 'Intento de lanzar un mensaje por parte de ' + from + '\n Contenido: ' + message);
51+
}
52+
} else {
53+
bot.sendMessage(from, "No te entiendo... Explicate mejor, Humano!");
54+
}
55+
});
56+
57+
58+
// Twitter
59+
twitterStream.stream('statuses/filter', {
60+
track: hashtags.join(',')
61+
}, function(stream) {
62+
63+
stream.on('data', function(tweet) {
64+
if (tweet.text !== undefined) {
65+
66+
var data = {
67+
username: "Twitter",
68+
icon: "https://cdn3.iconfinder.com/data/icons/social-icons-5/607/Twitterbird.png"
69+
};
70+
71+
slackNotify('https://twitter.com/' + tweet.user.screen_name + '/status/' + tweet.id_str, data);
72+
}
73+
});
74+
75+
stream.on('error', function(error, code) {
76+
bot.sendMessage(masterUser, "[ERROR][Twitter-Stream] Código: " + code + ". Detalle: " + error + ". CC: @ulisesgascon");
77+
});
78+
79+
});
80+
81+
82+
// Bienvenida
83+
slackNotify("Ya estoy Aquí! Se abren las notificaciones automáticas.\n¡Salvemos el mundo haciendo Software Libre!");
84+
85+
86+
// Temporización via config.js
87+
var messageManager = [];
88+
89+
for (var messages in eventConfig.messagesByPriority){
90+
setTimer(messages);
91+
}
92+
93+
function setTimer (key) {
94+
if(eventConfig.timerPriority[key] && eventConfig.messagesByPriority[key]){
95+
setInterval(function(){
96+
slackNotify(eventConfig.messagesByPriority[key][Math.floor(Math.random() * eventConfig.messagesByPriority[key].length)]);
97+
}, eventConfig.timerPriority[key]);
98+
}
99+
100+
}
101+
102+
for (var item in eventConfig.messagesScheduled){
103+
if(item.cron && item.job && item.msg){
104+
messageManager.push(new Scheduled({
105+
id: item.job,
106+
pattern: item.cron,
107+
task: function(){
108+
slackNotify(item.msg);
109+
}
110+
}).start());
111+
}
112+
}
113+
114+
115+
// Eventos
116+
process.on('SIGINT', function() {
117+
slackNotify("Me expulsan del canal! Ya no me quereis como antes... \ncc: @ulisesgascon te portas mal conmigo.");
118+
bot.sendMessage(masterUser, "Me piro! Ya no me quieres como antes...");
119+
process.exit();
120+
});
121+
122+
process.on('exit', function() {
123+
slackNotify("Salgo del canal! Pasarlo bien amigos.... \n¡Paz, amor y Open Source! \ncc: @ulisesgascon");
124+
bot.sendMessage(masterUser, "Me piro! Vaciones por fín!");
125+
process.exit();
126+
});
127+
128+
process.on('uncaughtException', function() {
129+
slackNotify("Salgo del canal! Cierre inesperado... \n¡Paz, amor y Open Source!\ncc: @ulisesgascon");
130+
bot.sendMessage(masterUser, "Me piro! Cierre inesperado...");
131+
process.exit();
132+
});

images/chasis-1.jpg

329 KB
Loading

images/chasis-2.jpg

250 KB
Loading

images/hardware.jpg

306 KB
Loading

images/oswaldito-front.jpg

269 KB
Loading

images/osweekends-team.jpg

270 KB
Loading

package.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "oswaldito",
3+
"version": "0.1.0",
4+
"description": "Robot Open Source que utilizamos en OSWeekends para gestionar redes sociales, telepresencia, etc....",
5+
"main": "server",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/OSWeekends/OSWaldito.git"
12+
},
13+
"keywords": [
14+
"robot",
15+
"raspberry",
16+
"pi",
17+
"iot",
18+
"hardware",
19+
"slack",
20+
"socialbot"
21+
],
22+
"author": "Open Source Weekends",
23+
"contributors": [
24+
{
25+
"name": "Ulises Gascón",
26+
"url": "https://github.com/ulisesGascon"
27+
}
28+
],
29+
"license": "GPL-3.0",
30+
"bugs": {
31+
"url": "https://github.com/OSWeekends/OSWaldito/issues"
32+
},
33+
"homepage": "https://github.com/OSWeekends/OSWaldito#readme",
34+
"dependencies": {
35+
"pillars": "0.3.7",
36+
"rpio": "0.9.12",
37+
"socket.io": "1.5.0",
38+
"hangouts-bot": "0.2.1",
39+
"scheduled": "0.4.5",
40+
"slack-node": "0.1.8",
41+
"twitter": "1.4.0"
42+
}
43+
}

0 commit comments

Comments
 (0)