├── .gitattributes ├── .gitignore ├── package.json ├── README.md ├── LICENSE └── minechat.js /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /npm-debug.log 3 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "minechat", 3 | "version": "0.1.0", 4 | "description": "Command-line Minecraft chat client", 5 | "main": "minechat.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "git://github.com/llbit/minechat.git" 9 | }, 10 | "license": "MIT", 11 | "dependencies": { 12 | "mineflayer": ">=0.1.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | minechat 2 | ======== 3 | 4 | Command-line Minecraft chat client. 5 | 6 | 7 | Fetch dependencies using npm: 8 | 9 | $ npm install 10 | 11 | Run minechat: 12 | 13 | $ node minechat.js 14 | 15 | License & Copyright 16 | ------------------- 17 | 18 | minechat is Copyright (c) 2013 Jesper Öqvist , and 19 | is covered by the MIT License. The full license text is included in the 20 | companion `LICENSE` file. 21 | 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Jesper Öqvist 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /minechat.js: -------------------------------------------------------------------------------- 1 | var readline = require('readline'); 2 | var mineflayer = require('mineflayer'); 3 | 4 | var rl = readline.createInterface({ 5 | input: process.stdin, 6 | output: process.stdout, 7 | terminal: false 8 | }); 9 | 10 | function print_help() { 11 | console.log("usage: PASSWORD= node minechat.js [:port] "); 12 | } 13 | 14 | if (process.argv.length < 4 || !("PASSWORD" in process.env)) { 15 | console.log("Too few arguments!"); 16 | print_help(); 17 | process.exit(1); 18 | } 19 | 20 | process.argv.forEach(function(val, index, array) { 21 | if (val == "-h") { 22 | print_help(); 23 | process.exit(0); 24 | } 25 | }); 26 | 27 | var host = process.argv[2]; 28 | var port = 25565; 29 | var user = process.argv[3]; 30 | var passwd = process.env.PASSWORD; 31 | 32 | if (host.indexOf(':') != -1) { 33 | port = host.substring(host.indexOf(':')+1); 34 | host = host.substring(0, host.indexOf(':')); 35 | } 36 | 37 | console.log("connecting to " + host + ":" + port); 38 | console.log("user: " + user); 39 | 40 | var bot = mineflayer.createBot({ 41 | host: host, 42 | port: port, 43 | username: user, 44 | password: passwd 45 | }); 46 | 47 | rl.on('line', function(line) { 48 | bot.chat(line); 49 | }); 50 | 51 | bot.on('chat', function(username, message) { 52 | console.log(username + ": " + message); 53 | }); 54 | --------------------------------------------------------------------------------