forked from totallymike/ircnode_plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitly.js
More file actions
26 lines (23 loc) · 723 Bytes
/
bitly.js
File metadata and controls
26 lines (23 loc) · 723 Bytes
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
// A url shortening plugin.
// Author: thevdude (rb.cubed@gmail.com)
//
// `npm install bitly` in the plugins folder before using this.
var Bitly = require('bitly');
var bitly = new Bitly('bitly username', 'bitly api_key');
var irc = global.irc;
var bitly_handler = function (act) {
if (act.params.length === 0) {
irc.privmsg(act.source, 'no url to shorten');
} else {
bitly.shorten(act.params, function (err, response) {
if (err) throw err;
if (response.data.url === undefined) {
irc.privmsg(act.source, 'bad url');
} else {
irc.privmsg(act.source, 'Shortened url: ' + response.data.url);
}
});
}
};
exports.name = ['bitly'];
exports.handler = [bitly_handler];