New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gu

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gu

An IRC bot addon to 'irc' with live code reloading and regex handlers.

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Gu Build Status

Gu is a minimalistic bot makers wrapper for the irc module.

It adds two key features to the irc module module:

  • regular expression handlers in the style of hubot (but without all those annoying environment variables and coffee-script..)
  • hot code reloading of specified files (without the bot having to leave the server)

Usage

Create a main file, bot.js say:

var gu = require('gu')(server, "botName", ircOpts, scriptPath, files);

The first three arguments to Gu are simply passed through to the irc module. The fourth and fifth is the script path, and the files in the scriptpath that will be watched for changes (and is assumed to contain handlers exported behind a function).

Then, put a file in your scriptpath, like.js, say, and add handlers therein:

module.exports = function (gu) {
  gu.on(/^i like your (\w*)$/, function (what) {
    gu.say('i has ' + what + ' :O');
  });
};

Then fire up the bot with node bot.js, navigate to the specified server and channel (in ircOpts), and try saying botName: i like your charisma in the channel.

Changing the handler in like.js will result in different behaviour without having to restart bot.js.

A more extensive example is avaiable in the example directory.

Complete examples

The following personal bots are all built on gu:

Future

Since gu handlers are essentially transportless response functions, if your handler packages does not include the gu dependency, you can essentially release the behaviour, and let people include it using the gu transport they want. XMPP should be a easy to implement as a drop in replacement for gu (TODO).

Caveats

The script path you specify to gu should only contain the handler functions. If you point the path at your lib dir, then it may reload all the files in that directory when you change one of your handlers.

Installation

$ npm install gu --save

Running tests

Install development dependencies

$ npm install

Run the tests

$ npm test

License

MIT-Licensed. See LICENSE file for details.

Keywords

FAQs

Package last updated on 12 Sep 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc