superscriptjs / superscript

A dialogue engine for creating chat bots
http://superscriptjs.com
MIT License
1.65k stars 209 forks source link

Getting user input data by character #393

Closed khhwang838 closed 7 years ago

khhwang838 commented 7 years ago

Hi, I'm new to superscript and I followed the installation instructions. And I could run superscript telnet server by running the command below But I cannot type a sentence to talk with a bot. It seems like it sends data by a character to server not by a word.

Expected Behavior

I was expecting to type a sentence on the client console.

Current Behavior

Client sends data character by character as soon as I type. Looks like this.

Hello ::1:57330! Type /quit to disconnect.

You> H Bot> You> H Bot> You> e Bot> You> l Bot> You> l Bot> You> o Bot> You> w Bot>

Possible Solution

Steps to Reproduce (for bugs)

  1. Follow the installation instruction on readme.md file
  2. npm run start-telnet (cmd window no.1)
  3. telnet localhost 2000 (cmd window no.2)
  4. type any words (cmd window no.2)

Context

I am looking for some good open source chatbot project and trying to test each of them to find out their pros and cons.

Your Environment

I'm running superscript on Windows 10, cmd window, localhost.

npm, node versions are C:\Users\dev>npm --version 5.5.1 C:\Users\dev>node --version v8.9.0

khhwang838 commented 7 years ago

Problem solved. I changed some code in newSocket(socket) function in ~/myBotname/server-telnet.js Modified part is below.

socket.write('You> ');

var message='';
socket.on('data', (data) => {
  message = message.concat(data);
  if ( data.includes("\n") ) {
    receiveData(socket, bot, message);
    message = '';
  }
});

// Handle disconnects.
socket.on('end', () => {
  closeSocket(socket, bot);
});