Skip to content

Commit c3bf112

Browse files
committed
sources
1 parent 01479e9 commit c3bf112

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+6528
-1
lines changed

hook.io/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

hook.io/cron.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var Hook = require('hook.io-cron').CronHook // npm install hook.io-cron
2+
;
3+
4+
var hook = new Hook({
5+
name: "NantesJSCron"
6+
});
7+
8+
hook.addJob({
9+
'event': 'twittsearch',
10+
'data': null
11+
});
12+
13+
hook.start();

hook.io/first.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Juste un premier hook simplissime
2+
var Hook = require('hook.io').Hook;
3+
var hook = new Hook({ name: 'NantesJS' });
4+
hook.on('hook::ready', function() {
5+
hook.on('*::hello', function(data) {
6+
console.log('MESSAGE RECEIVED');
7+
hook.emit('received', 'message received');
8+
});
9+
});
10+
hook.start();

hook.io/mail.conf.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"host" : "xxxxxx",
3+
"port" : "25", // 465 pour gmail, par exemple
4+
"ssl": true,
5+
"to" : "xxxx@xxx",
6+
"from" : "xxxw@xxxx",
7+
"authentication" : "login",
8+
"username" : "xxxxx",
9+
"password" : "xxxxx"
10+
}

hook.io/mailer.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
var email = require("mailer") // npm install mailer
2+
, conf = require('./mail.conf.json')
3+
, Hook = require('hook.io').Hook
4+
;
5+
6+
conf.subject = 'Nouveau tweet';
7+
8+
var hook = new Hook({
9+
name: 'NantesJSMailer'
10+
});
11+
12+
hook.on('hook::ready', function() {
13+
14+
hook.on('*::twitt', function(data) {
15+
conf.body = data;
16+
email.send(conf, function(err, result) {
17+
if (err) console.log(err);
18+
else console.log('Mail envoyé :)');
19+
});
20+
});
21+
22+
});
23+
24+
hook.start();

hook.io/twitter.conf.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"consumer_key" : "jIMMRjE4tQZqK8snkYHw",
3+
"consumer_secret" : "SDEnQycUMTQkzeVBU17IakaMVuXKtsVfWPNX8KONHyA",
4+
"access_token_key" : "153837307-KKRx4Kv85gmVUv9vJLW5Ax7W5UIdV8BsJdUXnWwM",
5+
"access_token_secret" : "x9fNaD0AKePEFfw4YgvyuwlryBkrJlFOsbqgLDPuA"
6+
}

hook.io/twitter.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var twitter = require("ntwitter") // npm install ntwitter
2+
, conf = require('./twitter.conf.json')
3+
, Hook = require('hook.io').Hook
4+
, last_id = 0;
5+
6+
var hook = new Hook({
7+
name: "NantesJSTwitter"
8+
});
9+
hook.on('hook::ready', function() {
10+
11+
hook.on('*::twittsearch', function(data) {
12+
13+
var twit = new twitter(conf);
14+
twit.search('bieber', function(err, data) {
15+
if (data && data.results && data.results.length && last_id != data.max_id) {
16+
last_id = data.max_id;
17+
hook.emit('twitt', data.results[0].text);
18+
}
19+
});
20+
21+
});
22+
23+
});
24+
25+
hook.start();

readme.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,33 @@
11
* Slides de la présentation hook.io
2-
* Exemple final
2+
* Exemple final
3+
4+
Penser à récupérer les modules nécessaires
5+
npm install hook.io
6+
npm install hook.io-cron
7+
npm install mailer
8+
npm install ntwitter
9+
10+
Note : pour un pb de compatiblité, il faut changer la version de hook.io dans hook.io-cron
11+
"hook.io" : ">= 0.8.7"
12+
13+
Pour l'exemple, penser à modifier
14+
15+
mail.conf.json
16+
{
17+
"host" : "xxxxxx",
18+
"port" : "25", // 465 pour gmail, par exemple
19+
"ssl": true,
20+
"to" : "xxxx@xxx",
21+
"from" : "xxxw@xxxx",
22+
"authentication" : "login",
23+
"username" : "xxxxx",
24+
"password" : "xxxxx"
25+
}
26+
27+
et twitter.conf.json (enregistrer l'appli sur dev.twitter.com)
28+
{
29+
"consumer_key" : "xxxx",
30+
"consumer_secret" : "xxxx",
31+
"access_token_key" : "xxxx",
32+
"access_token_secret" : "xxxx"
33+
}

0 commit comments

Comments
 (0)