2013-12-30 10:05:22 -05:00
|
|
|
var mc = require('../')
|
|
|
|
, states = mc.protocol.states
|
|
|
|
|
2013-01-02 03:30:33 -05:00
|
|
|
var client = mc.createClient({
|
|
|
|
username: process.env.MC_USERNAME,
|
|
|
|
password: process.env.MC_PASSWORD,
|
|
|
|
});
|
|
|
|
client.on('connect', function() {
|
2013-07-09 02:11:09 -04:00
|
|
|
console.info('connected');
|
2013-01-02 03:30:33 -05:00
|
|
|
});
|
2014-01-14 00:56:56 -05:00
|
|
|
client.on('chat', function(packet) {
|
2013-07-09 02:11:09 -04:00
|
|
|
var jsonMsg = JSON.parse(packet.message);
|
|
|
|
if (jsonMsg.translate == 'chat.type.announcement' || jsonMsg.translate == 'chat.type.text') {
|
2013-12-30 10:05:22 -05:00
|
|
|
var username = jsonMsg.with[0];
|
|
|
|
var msg = jsonMsg.with[1];
|
2013-07-09 02:11:09 -04:00
|
|
|
if (username === client.username) return;
|
2014-03-16 13:06:57 -04:00
|
|
|
client.write('chat', {message: msg});
|
2013-07-09 02:11:09 -04:00
|
|
|
}
|
2013-12-30 10:05:22 -05:00
|
|
|
});
|