-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (33 loc) · 1.04 KB
/
index.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
var behest = require('behest');
var omdb = require('omdb');
function plugin() {
return function(irc) {
irc.on('message', function(evt) {
var from = evt.from;
var to = evt.to;
var message = evt.message;
if (!behest.isValid(message)) {
return;
}
var command = behest(message);
if (command.command === 'movie') {
var destination = to.charAt(0) === '#' ? to : from;
omdb.get(command.params.join(' '), function(error, movie) {
if (error) {
irc.send(destination, 'Error looking up movie.');
return;
}
if (!movie) {
irc.send(destination, 'Movie not found.');
return;
}
irc.send(destination, movie.title + ' (' + movie.year + ')');
irc.send(destination, '| ' + movie.imdb.rating + '/10');
irc.send(destination, '| ' + movie.genres.join(', '));
irc.send(destination, '| http://imdb.com/title/' + movie.imdb.id);
});
}
});
};
}
module.exports = plugin;