forked from totallymike/ircnode_plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisup.js
43 lines (34 loc) · 949 Bytes
/
isup.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
// A little website checking plugin for IRC Node.
// Author: thevdude ([email protected])
//
// Hits isup.me to check if a website is down or not.
var http = require('http');
var irc = global.irc;
var isup_handler = function (act) {
if (act.params.length === 0) {
irc.privmsg(act.source, 'Gimme a URL to check');
}
else {
var options = {
host: 'www.isup.me',
port: 80,
path: '/' + act.params
};
var req = http.request(options, function (res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
if (chunk.indexOf('It\'s just you') !== -1) {
irc.privmsg(act.source, 'It\'s up! http://' + act.params);
} else {
irc.privmsg(act.source, 'It\'s down!');
}
});
});
req.on('error', function (e) {
console.log('error: ' + e.message);
});
req.end();
}
};
exports.name = ['isup'];
exports.handler = [isup_handler];