<commit_before>let r = require('rethinkdbdash')();
let readline = require('readline');

let rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});


// Display stuff from the chat
r.table('Message').run({cursor: true}).then((cursor) => {
  cursor.each((err, message) => {
    if (message) {
      console.log(message.content);
    }
  });
});

// Typing stuff in should create a new message
rl.on('line', (content) => {
  console.log('readlined content:', content);
});<commit_msg>improve chat functionality a bit<commit_after>let r = require('rethinkdbdash')();
let readline = require('readline');

let rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});


// Display stuff from the chat
r.table('Message').run({cursor: true}).then((cursor) => {
  cursor.each((err, message) => {
    if (message) {
      console.log(message.content);
    }
  });
});

// Typing stuff in should create a new message
rl.on('line', (content) => {
  console.log('inserting ' + content);
  r.table('Message').insert({content}).run().done();
});

// TODO: sort by time, make the display stuff listen for liveness
{'fraction_non_alphanumeric': 0.18197573656845753, 'fraction_numerical': 0.0, 'mean_word_length': 4.202702702702703, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1148764', 'n_tokens_mistral': 365, 'n_tokens_neox': 360, 'n_words': 91}