Permalink
Browse files

Add an example of using the source.

  • Loading branch information...
1 parent 3d8e39f commit 6a063dee1cd8903509b5a72b2495834dd3f68ecb @michaeltwofish michaeltwofish committed Apr 3, 2012
Showing with 21 additions and 0 deletions.
  1. +21 −0 examples/source.js
View
21 examples/source.js
@@ -0,0 +1,21 @@
+var jerk = require( '../lib/jerk' ), util = require('util');
+var options =
+ { server: 'localhost'
+ , port: 6667
+ , nick: 'Bot9121'
+ , channels: [ '#jerkbot' ]
+ };
+
+jerk( function( j ) {
+ j.watch_for( 'cake', function( message ) {
+ var out = 'Cake is a lie!'
+ , channel = message.source;
+ for ( client in channel.clients ) {
+ if ( 'GlaDOS' == channel.clients[client] ) {
+ out = 'psst, I have something to tell you but I can\'t say it while GlaDOS is in ' + String(channel);
+ }
+ }
+ message.say( message.user + ': ' + out );
+ });
+}).connect( options );
+

0 comments on commit 6a063de

Please sign in to comment.