Socket
Socket
Sign inDemoInstall

tinybot

Package Overview
Dependencies
52
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.0.5

10

index.js

@@ -152,4 +152,4 @@ 'use strict';

* bot.hears('baz', function() {})
* bot.drop('cool*') // drops 'foo' and 'bar' listener
* bot.drop('*') // drops all listeners
* bot.drop(/cool/) // drops 'foo' and 'bar' listener
* bot.drop(/^/) // drops all listeners
*

@@ -161,6 +161,8 @@ * @param {(RegExp|string)} functionPattern Pattern of listener function names to remove

if( !functionPattern ) { return console.warn("Pass * to remove all listeners"); }
if( !functionPattern ) { return console.warn("Pass /.*/ to remove all listeners"); }
if( functionPattern == '*' ) { functionPattern = '.*' }
self.listeners.filter(function(l) {
return l.name.match(functionPattern);
return typeof functionPattern === 'string' ?
l.name === functionPattern :
l.name.match(functionPattern)
}).forEach(function(l) {

@@ -167,0 +169,0 @@ self.removeListener('message', l.listener);

2

package.json
{
"name": "tinybot",
"version": "1.0.4",
"version": "1.0.5",
"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",

@@ -69,3 +69,3 @@ # tinybot

bot.drop('foo*'); // deregister functions named foo and fooBar
bot.drop('*'); // deregister all listeners
bot.drop(/foo.*/); // deregister functions named foo and fooBar
bot.drop(/.*/); // deregister all listeners

@@ -46,3 +46,3 @@ var expect = require('expect');

afterEach(function() {
bot.drop('*');
bot.drop(/.*/);
})

@@ -125,4 +125,2 @@

slackTest.socket.send({text: 'nice'});
// TODO: desired api
// waitFor(function() { return true}, function done())
setTimeout(function wait() {

@@ -155,8 +153,33 @@ if( counter < 1 ) { return setTimeout(wait, 10); }

if( counter < 1 ) { return setTimeout(wait, 10); }
bot.drop('cool*');
bot.drop(/cool.*/);
slackTest.socket.send({text: 'nice'});
}, 10);
})
it('drops exact string matches properly', function(cb) {
var counter = 0, coolCounter = 0;
bot.hears({text: 'nice'}, function cool(message) {
coolCounter++;
})
bot.hears({text: 'nice'}, function yepcoolgreat(message) {
coolCounter++;
})
bot.hears({text: 'nice'}, function (message) {
if( ++counter == 2 ) {
expect(coolCounter).toEqual(3);
cb();
}
})
slackTest.socket.send({text: 'nice'});
setTimeout(function wait() {
if( counter < 1 ) { return setTimeout(wait, 10); }
bot.drop('cool');
slackTest.socket.send({text: 'nice'});
}, 10);
})
})
})
})
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc