Skip to content

Instantly share code, notes, and snippets.

@t3h2mas
Created June 17, 2014 16:33
Show Gist options
  • Save t3h2mas/ba27c722afd14dcb37e2 to your computer and use it in GitHub Desktop.
Save t3h2mas/ba27c722afd14dcb37e2 to your computer and use it in GitHub Desktop.
var blessed = require('blessed');
var screen = blessed.screen();
var irc = require('irc');
var client = new irc.Client('irc.esper.net', 'nodecli', {
channels: ['#smth'],
});
var box = blessed.box({
bottom: 0,
left: 'center',
height: 3,
width: '100%',
tags: true,
});
screen.append(box);
var buffer = blessed.Text({
top: 0,
width: '100%',
height: '93%',
border: {
type: 'line'
}
});
screen.append(buffer)
var form = blessed.Form({
});
box.append(form);
var text = blessed.Textbox({
name: 'input',
inputOnFocus: true,
keys: true,
border: {
type: 'line'
}
});
box.append(text);
text.key('enter', function (ch, key) {
// do work with text.getValue()
msg = text.getValue()
if (msg == '/quit')
process.exit(0);
buffer.setText(buffer.getText() + '\n' +msg);
client.say('#smth', text.getValue());
text.clearValue()
text.focus()
screen.render();
});
// irc
client.on('message', function (from, to, message) {
buffer.setText(buffer.getText() + '\n' + to + ':' + from + ' > ' + message);
screen.render();
});
screen.key(['escape'], function (ch, key) {
process.exit(0);
});
text.focus();
screen.render();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment