Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add: Method to forget watchers. Version bump.

  • Loading branch information...
commit 5d9c677fce1f0620c1620bdc555e9bca58d3a8d6 1 parent 688e5c6
@gf3 authored
Showing with 15 additions and 5 deletions.
  1. +1 −0  .gitignore
  2. +1 −0  README.md
  3. +12 −4 lib/jerk.js
  4. +1 −1  package.json
View
1  .gitignore
@@ -1,2 +1,3 @@
*.swp
tmp*.js
+node_modules
View
1  README.md
@@ -70,6 +70,7 @@ The `connect` method returns an object with some handy methods that you can use
```javascript
{ say: Function( destination, message )
, action: Function( destination, action )
+, forget: Function( pattern )
, part: Function( channel )
, join: Function( channel )
, quit: Function( message )
View
16 lib/jerk.js
@@ -16,12 +16,12 @@ Jerk = new ( function Jerk() {
, leave_watchers = []
, connect = _connect.bind( this )
, watch_for = _watch_for.bind( this )
- , user_join = _user_join.bind(this)
- , user_leave = _user_leave.bind(this)
+ , user_join = _user_join.bind( this )
+ , user_leave = _user_leave.bind( this )
/* ------------------------------ Public Methods ------------------------------ */
this.addWatchers = function( block ) {
- block( { watch_for: watch_for, user_join: user_join, user_leave: user_leave} )
+ block( { watch_for: watch_for, user_join: user_join, user_leave: user_leave } )
return { connect: connect }
}
@@ -39,6 +39,7 @@ Jerk = new ( function Jerk() {
})
.connect( _on_connect.bind( bot ) )
return { say: _privmsg_protected.bind( this )
+ , forget: _forget.bind( this )
, action: _bot_do( function( to, msg ) { return bot.privmsg( to, '\001ACTION ' + msg + '\001' ) } ).bind( this )
, part: _bot_do( 'part' ).bind( this )
, join: _bot_do( 'join' ).bind( this )
@@ -84,7 +85,7 @@ Jerk = new ( function Jerk() {
, md
while ( i-- )
- if ( md = message.params.slice( -1 ).toString().match( watchers[i][0] ) )
+ if ( typeof watchers[i] != 'undefined' && ( md = message.params.slice( -1 ).toString().match( watchers[i][0] ) ) )
watchers[i][1]( _make_message( message, md ) )
}
@@ -119,6 +120,13 @@ Jerk = new ( function Jerk() {
return bot.privmsg( receiver, msg, true )
}
+ function _forget( pattern ) {
+ var i, l, pattern = String( pattern )
+ for ( i = 0, l = watchers.length; i < l; i++ )
+ if ( pattern == String( watchers[i][0] ) )
+ delete watchers[i]
+ }
+
function _to_string() {
return new Date().strftime( '[%H:%M]' ) + ' <' + this.user + '> ' + this.text
}
View
2  package.json
@@ -8,7 +8,7 @@
, "Tomás Senart <tsenart@me.com> http://about.me/tsenart"
]
, "homepage" : "http://github.com/gf3/Jerk"
-, "version" : "1.1.16"
+, "version" : "1.1.17"
, "main" : "./lib/jerk"
, "dependencies" :
{ "irc-js": "=0.2.27"
Please sign in to comment.
Something went wrong with that request. Please try again.