<commit_before>var mineflayer = require('mineflayer');
var argv = require('minimist')(process.argv.slice(2));

console.log("Starting bot.");

console.log(argv.host);
console.log(argv.port);
console.log(argv.username);
console.log(argv.password);
console.log("--------------");

var bot = mineflayer.createBot({
  host: argv.host, // optional
  port: argv.port,       // optional
  username: argv.username, // email and password are required only for
  password: <PASSWORD>,          // online-mode=true servers
});
bot.on('chat', function(username, message) {
  if (username === bot.username) return;
  bot.chat(message);
});
bot.on('error', function(error) {
  console.error(error.stack);
});<commit_msg>got chat and whisper working for civcraft<commit_after>var mineflayer = require('mineflayer');
var argv = require('minimist')(process.argv.slice(2));

var bot = mineflayer.createBot({
  host: argv.host,
  port: argv.port,
  username: argv.username,
  password: <PASSWORD>,
});

//clear the vanilla patterns from the list to scan. V7+ all use json anyway.
//bot.chatPatterns = [];

bot.chatAddPattern(/^([a-zA-Z0-9_]{1,16}):\s(.+)/, "chat", "CivCraft chat");
bot.chatAddPattern(/^From\s(.+):\s(.+)/, "whisper", "CivCraft pm");
//bot.chatAddPattern(/^(.*)$/, "chat", "CivCraft chat");

//TODO: it's picking up 'hi' as the wisper username and not getting a message.


bot.on('chat', function(username, message) {  
  if (username === bot.username) return;  
  bot.chat(message);
});

bot.on('whisper', function(username, message) {
  console.log("username: "+username);
  console.log("whisper:"+message);
  if (username === bot.username) return;  
  bot.chat("/r "+message);
});

bot.on('error', function(error) {
  console.error(error.stack);
});

bot.on('spawn', function() {
  console.log("spawn.");
  bot.chat("I have awoken.");
});

bot.on('kicked', function(reason) {
  console.log("We were kicked, because:");
  console.error(reason);
});

bot.on('health', function() {
  console.warn("Health change: "+bot.health);
});
{'fraction_non_alphanumeric': 0.20710059171597633, 'fraction_numerical': 0.0039447731755424065, 'mean_word_length': 4.4837837837837835, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2661110', 'n_tokens_mistral': 696, 'n_tokens_neox': 683, 'n_words': 151}