Comparing version 1.0.8 to 1.0.9
@@ -57,3 +57,3 @@ 'use strict'; | ||
self.channels = body.channels; | ||
self.self = body.self; | ||
self.myId = body.self.id; | ||
self.ws = new WebSocket(wsUrl); | ||
@@ -238,2 +238,5 @@ | ||
var self = this; | ||
if( message.user == self.myId && !matcher.self ) { return false; } | ||
delete matcher.self; | ||
var keys = Object.keys(matcher); | ||
@@ -240,0 +243,0 @@ var matches; |
{ | ||
"name": "tinybot", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "A tiny wrapper around the Slack RTM API that provides methods to listen for and send slack messages.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -39,3 +39,3 @@ # tinybot | ||
Basic listener | ||
Basic listener: fires for every message over slack websocket | ||
@@ -42,0 +42,0 @@ ```js |
@@ -39,3 +39,4 @@ var expect = require('expect'); | ||
slackTest.serve(6969, { | ||
channels: [{ name: 'general', id: 'CG0' }] | ||
channels: [{ name: 'general', id: 'CG0' }], | ||
self: { id: 'DISBOT' } | ||
}, function(err) { | ||
@@ -62,3 +63,3 @@ if( err ) { return cb(err); } | ||
it('matches a regexp', function(cb) { | ||
bot.hears({filename: /n(.*)e/}, function(message, matches) { | ||
bot.hears({'file.name': /n(.*)e/}, function(message, matches) { | ||
expect(matches[1]).toEqual('op'); | ||
@@ -115,2 +116,14 @@ cb(); | ||
it('ignores messages from self', function(cb) { | ||
var spy = expect.createSpy(); | ||
bot.hears({'text': /.+/}, spy); | ||
bot.hearsOnce({'text': /.+/, self: true}, function() { | ||
expect(spy).toNotHaveBeenCalled(); | ||
cb(); | ||
}) | ||
slackTest.socket.send({ text: 'foo', user: 'DISBOT'}); | ||
}) | ||
it('allows sending messages to channel based on name', function(cb) { | ||
@@ -117,0 +130,0 @@ bot.hears({channel: '#general'}, function(message) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18758
438