-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstart.js
More file actions
40 lines (34 loc) · 837 Bytes
/
start.js
File metadata and controls
40 lines (34 loc) · 837 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
var irc = require('irc');
var Bitstamp = require('./bitstamp');
var MtGox = require('./mtgox');
var Config = require('./config');
// setup IRC client.
var client = new irc.Client(Config.irc_server, Config.bot_name, {
channels: Config.channels
});
// Prepare Bitstamp lib
var bsApi = new Bitstamp({
irc: client
});
// Prepare MtGox lib
var mtApi = new MtGox({
key: Config.mtgox.key,
secret: Config.mtgox.secret
});
// Listen to messages
client.addListener('message', function (from, to, message) {
var msg = message.trim().split(' ');
// check for "!"
if (msg[0] && msg[0].substring(0,1) === "!") {
switch (msg[0]) {
case "!btc":
// bitstamp
bsApi.tracker(from, to, client.say.bind(client));
// mtgox
mtApi.tracker(from, to, client.say.bind(client));
break;
default:
return;
}
}
});