-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
44 lines (38 loc) · 1.17 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var Twitter = require("twitter");
var five = require("johnny-five");
var arduino = new five.Board();
var clientTwitter = new Twitter({
consumer_key: '',
consumer_secret: '',
access_token_key: '',
access_token_secret: ''
});
arduino.on("ready", function() {
var moisture = new five.Sensor("A0");
moisture.scale(0,100);
var lampe = new five.Pin(7);
lampe.low();
clientTwitter.stream('statuses/filter', {track: '@simplonnatacha'}, function(stream) {
stream.on('data', function(tweet) {
console.log(tweet.text);
var motifWesh = new RegExp("wesh");
if(motifWesh.test(tweet.text)){
// Retweet
clientTwitter.post('statuses/update', {status: "Je suis Natacha, mon taux d'humidité est de " + moisture.value}, function(error, tweet, response){
if(error) throw error;
console.log(tweet); // Tweet body.
});
}
var motifArrosage = new RegExp("arrosage");
if(motifArrosage.test(tweet.text)){
// Arrosage
lampe.high();
}
var motifEteindre = new RegExp("éteindre");
if (motifEteindre.test(tweet.text)) {
// Eteindre
lampe.low();
}
});
});
});