Commit 124c24ccc9f1a6d3df51cfaa24add7d8aa87d2ff
1 parent
6ecb8371be
Exists in
master
sasl dan autojoin channel
Showing 1 changed file with 20 additions and 14 deletions Side-by-side Diff
index.js
1 | 1 | var fs = require('fs'); |
2 | 2 | var ini = require('ini'); |
3 | 3 | var config = ini.parse(fs.readFileSync(__dirname + '/config.ini', 'utf-8')); |
4 | +var redis = require('redis'); | |
4 | 5 | |
5 | 6 | var irc = require('irc'); |
6 | -var client = new irc.Client(config.globals.irc_server, config.globals.irc_nick); | |
7 | -var redis = require('redis'); | |
7 | +var options = { | |
8 | + userName: config.globals.irc_nick, | |
9 | + password: config.globals.nickserv_password, | |
10 | + sasl: true, | |
11 | + stripColors: true, | |
12 | + channels: [config.globals.aaa_pull_channel, config.globals.topup_message_channel] | |
13 | +}; | |
14 | +var client = new irc.Client(config.globals.irc_server, config.globals.irc_nick, options); | |
8 | 15 | |
9 | 16 | var redisClient = redis.createClient(config.globals.redis_port, config.globals.redis_host); |
10 | 17 | |
... | ... | @@ -13,30 +20,31 @@ client.addListener('message', function (from, to, message) { |
13 | 20 | }); |
14 | 21 | |
15 | 22 | client.addListener('registered', function () { |
16 | - console.log('onRegistered'); | |
17 | - client.say('NickServ', 'identify ' + config.globals.nickserv_password); | |
23 | + console.log('Connected'); | |
24 | + //client.say('NickServ', 'identify ' + config.globals.nickserv_password); | |
18 | 25 | }); |
19 | 26 | |
20 | 27 | client.addListener('join', function (channel, nick, message) { |
21 | 28 | console.log('JOIN ' + channel); |
22 | 29 | |
23 | - if (channel == '#' + config.globals.aaa_pull_channel) { | |
30 | + if (channel == config.globals.aaa_pull_channel) { | |
24 | 31 | redisClient.psubscribe('kimochi.*.text'); |
25 | 32 | } |
26 | - else if (channel == '#' + config.globals.topup_message_channel) { | |
33 | + else if (channel == config.globals.topup_message_channel) { | |
27 | 34 | redisClient.psubscribe('echi.topup_report.*.message'); |
28 | 35 | } |
29 | 36 | }); |
30 | 37 | |
31 | 38 | client.addListener('notice', function (from, to, message) { |
32 | 39 | console.log('NOTICE ' + from + ' => ' + to + ': ' + message); |
40 | + return; | |
33 | 41 | |
34 | 42 | if (from == 'NickServ' && message.match('You are now identified for')) { |
35 | - console.log('Joining #' + config.globals.aaa_pull_channel); | |
36 | - client.join('#' + config.globals.aaa_pull_channel); | |
43 | + console.log('Joining ' + config.globals.aaa_pull_channel); | |
44 | + client.join(config.globals.aaa_pull_channel); | |
37 | 45 | |
38 | - console.log('Joining #' + config.globals.topup_message_channel); | |
39 | - client.join('#' + config.globals.topup_message_channel); | |
46 | + console.log('Joining ' + config.globals.topup_message_channel); | |
47 | + client.join(config.globals.topup_message_channel); | |
40 | 48 | } |
41 | 49 | }); |
42 | 50 | |
... | ... | @@ -47,12 +55,10 @@ client.addListener('pm', function (from, message) { |
47 | 55 | redisClient.on("pmessage", function (pattern, channel, message) { |
48 | 56 | if (channel.match(/^kimochi/)) { |
49 | 57 | var gateway = channel.match(/gw:(.*)\.text/)[1]; |
50 | - //console.log(message + ' (' + gateway + ')'); | |
51 | - client.say('#' + config.globals.aaa_pull_channel, message + ' (' + gateway + ')'); | |
58 | + client.say(config.globals.aaa_pull_channel, message + ' (' + gateway + ')'); | |
52 | 59 | } |
53 | 60 | else if (channel.match(/^echi/)) { |
54 | 61 | var gateway = channel.match(/gw:(.*)\.message$/)[1]; |
55 | - //console.log(message + ' (' + gateway + ')'); | |
56 | - client.say('#' + config.globals.topup_message_channel, message + ' (' + gateway + ')'); | |
62 | + client.say(config.globals.topup_message_channel, message + ' (' + gateway + ')'); | |
57 | 63 | } |
58 | 64 | }); |