Why not?
npm inpm run starttelnet localhost 1337
npm run test
- the latest version of telnet is unfortunately not on NPM, so using git url as dependency instead.
You can define middleware to create interactions between the client and the server. server exposes use which takes two arguments:
matchCommand: string or regex used to match the user's command, e.g./join/would match user inputjoinandjointbut notjoiresponse: callback that is executed when the command matches. The callback is executed with a single argument which is an object:
{
command, // the user's input
client, // object representing user's connection to server
l, // write a line to the client
prompt, // show the user's prompt
}
Note:
- You can define as many middleware functions as you want
- Middleware is matched and executed in the order of which they are defined
- If
matchCommandisundefined, oruseis called with a single argument, the middleware is executed when no middleware was matched with the user's input - You can use colors when outputting text to the client using 'l()', e.g.
l('Connected to MUD!'.red.bold);outputsConnected to MUDin bold, red text