-
Notifications
You must be signed in to change notification settings - Fork 0
/
tele-muc-pump.js
executable file
·52 lines (49 loc) · 1.3 KB
/
tele-muc-pump.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
45
46
47
48
49
50
51
52
#!/usr/bin/env node
var
assert= require("assert"),
Telestreamitize = require("telestreamitize")
var
Context= require( "webpush-pump/Context"),
Push= require( "webpush-pump/push/Push"),
RouteMaker= require( "webpush-pump/util/route-maker"),
Server= require( "webpush-pump/server"),
subscribe= require( "webpush-pump/subscribe/subscribe"),
Subscribe= require( "webpush-pump/subscribe/Subscribe")
// create a server
var
ctx= new Context(),
router= RouteMaker( subscribe)( ctx)
opts= {
ctx: ctx,
routes: router.routes(),
port: 8090
},
server= Server( opts)
Push.warn= true
Push.okEmpty= true
console.log( "server created")
// make a Subscribeable for "messages"
var
messages= new Subscribe()
messages.id= "messages"
ctx.accept( messages)
console.log( "subscribeable 'messages' created")
// collect & stream irc messages to "messages"
var
room= "#node-dc.dev"
Telestreamitize({
channelFilter: room
}).then(function( telestream){
console.log( "listening for irc messages in '"+ room+ "'")
telestream.on( "message", function( msg){
var
push= new Push({
subscribe: messages
}),
headers= {
"Location": ["messages", msg.room.substring(1), msg.time].join( "/")
}
push.send( JSON.stringify( msg), headers, ctx)
console.log(msg.time, msg.sender, msg.content)
})
})