-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
66 lines (53 loc) · 1.53 KB
/
main.js
File metadata and controls
66 lines (53 loc) · 1.53 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
var util = require('util');
var jerk = require('jerk');
var repl = require('repl');
var tpb = require('./tpb');
var settings = require("./settings");
var filter = /doctor|who|The Impossible Astronaut/i;
var lrepl = repl.start();
lrepl.context.util = util;
lrepl.context.jerk = jerk;
lrepl.context.filter = filter;
var bot = jerk(function (j) {
j.watch_for(/geronimo/i, function (msg) {
msg.say(msg.user + ": you look timelord.");
});
j.watch_for(/^(.*?): leave/i, function (msg) {
if (msg.match_data[1] == irc.options.nick)
bot.part(msg.source);
});
}).connect(settings);
lrepl.context.bot = bot;
// dirty hack to get a reference to the irc-js object
var irc = bot.say("","foo");
lrepl.context.irc = irc;
irc.on('invite', function (msg) {
util.debug("INVITE to " + msg.params[1] + " by " + msg.person.nick);
bot.join(msg.params[1]);
});
var channels = [];
lrepl.context.channels = channels;
irc.on('join', function (msg) {
if (msg.person.nick != irc.options.nick)
return;
channels.push(msg.params[0]);
});
irc.on('part', function (msg) {
if (msg.person.nick != irc.options.nick)
return;
delete channels[channels.indexOf(msg.params[0])];
});
//tpb.removeAllListeners('debug');
//tpb.removeAllListeners('new');
tpb.on('new', function (torrent) {
if (!filter.test(torrent.name))
return;
for (var i in channels) {
bot.say(channels[i],
"http://thepiratebay.org/torrent/" + torrent.id + "/ " +
torrent.size + " | " +
torrent.name
);
}
});
// vim:set ts=2 sw=2 smartindent et: