1.0.5 • Published 9 years ago

node-snarl v1.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

node-snarl

Plugin for node to send notifications on Snarl4

Basic Usage

// Getting the plugin
var Snarl = require('node-snarl')();

// Function to register messages on an app name.
Snarl.register(name);

// If you want to check if the server is available
if(Snarl.isAvailable()){
  // if its everything ok

  // Send many notifications as you want.
  Snarl.notify(name, options);
  // Or send notifications with a default icon "done".
  Snarl.done(name, options);
  // Or send notifications with a default icon "fail".
  Snarl.fail(name, options);
  // Or send notifications with a default icon "log".
  Snarl.log(name, options);
}

Options

These options must be used to set server params and set default message options

{
  server: 'localhost'
, port: '8080'
, name: 'Snarl4'
, iconPath: __dirname+'\\..\\icon'
, messageOptions: {
    timeout: 3
  , title: 'Custom default Title'
  , text: 'Custom default message'
  }
}

Message Options

{
  title: 'Snarl - Title Example'
, text: 'This is message body'
, sound: 'path/to/sound'
, icon: 'path/to/image'
}

These options can be used in these functions:


Advanced Usage

If you have been registered a new Snarl app, you can ommit name parameter. Putting it all together.

// Getting the plugin
var Snarl = require('node-snarl')({
    server: 'localhost'
  , port: '8080'
  , name: 'Snarl4'
  , iconPath: __dirname+'\\..\\icon'
  , messageOptions: {
      timeout: 3
    , title: 'Custom default Title'
    , text: 'Custom default message'
    }
  }
});

// Function to register messages on an app name.
Snarl.register(name);

// If you want to check if the server is available
if(Snarl.isAvailable()){
  // if its everything ok

  // Send many notifications as you want.
  Snarl.notify({
    title: 'No icon'
  , text: 'This is a notification with no icon'
  , sound: 'path/to/sound'
  , icon: 'path/to/image'
  });

  // Or send notifications with a default icon "done".
  Snarl.done({
    title: 'Done icon'
  , text: 'A done icon example'
  , sound: 'path/to/sound'
  , icon: 'path/to/image'
  });

  // Or send notifications with a default icon "fail".
  Snarl.fail({
    title: 'Snarl - Title Example'
  , text: 'A done fail example'
  , sound: 'path/to/sound'
  , icon: 'path/to/image'
  });

  // Or send notifications with a default icon "log".
  Snarl.log({
    title: 'Snarl - Title Example'
  , text: 'A done log example'
  , sound: 'path/to/sound'
  , icon: 'path/to/image'
  });
}
1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.1.0

9 years ago