File tree Expand file tree Collapse file tree 4 files changed +17
-3
lines changed Expand file tree Collapse file tree 4 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 11# Changelog
22This project adheres to [ Semantic Versioning] ( http://semver.org/ ) .
33
4+ ## [ 3.7.3] - 2016-01-12
5+ ### Fixed
6+ - Don't crash when trying to send a message to a Slack channel the bot
7+ isn't a member of.
8+
49## [ 3.7.2] - 2016-01-12
510### Changed
611- Remove babel-polyfill, use functions available in Node 0.10 and above instead.
Original file line number Diff line number Diff line change @@ -206,7 +206,7 @@ class Bot {
206206 if ( slackChannelName ) {
207207 const slackChannel = this . slack . getChannelGroupOrDMByName ( slackChannelName ) ;
208208
209- if ( ! slackChannel ) {
209+ if ( ! slackChannel || ! slackChannel . is_member ) {
210210 logger . info ( 'Tried to send a message to a channel the bot isn\'t in: ' ,
211211 slackChannelName ) ;
212212 return ;
Original file line number Diff line number Diff line change @@ -86,8 +86,16 @@ describe('Bot', function() {
8686 } ) ;
8787
8888 it ( 'should not send messages to slack if the bot isn\'t in the channel' , function ( ) {
89- this . bot . slack . getChannelGroupOrDMByName = function ( ) {
90- return null ;
89+ this . bot . slack . getChannelGroupOrDMByName = ( ) => null ;
90+ this . bot . sendToSlack ( 'user' , '#irc' , 'message' ) ;
91+ ChannelStub . prototype . postMessage . should . not . have . been . called ;
92+ } ) ;
93+
94+ it ( 'should not send messages to slack if the channel\'s is_member is false' , function ( ) {
95+ this . bot . slack . getChannelGroupOrDMByName = ( ) => {
96+ const channel = new ChannelStub ( ) ;
97+ channel . is_member = false ;
98+ return channel ;
9199 } ;
92100
93101 this . bot . sendToSlack ( 'user' , '#irc' , 'message' ) ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ class ChannelStub extends EventEmitter {
66 super ( ) ;
77 this . name = 'slack' ;
88 this . is_channel = true ;
9+ this . is_member = true ;
910 this . members = [ 'testuser' ] ;
1011 }
1112}
You can’t perform that action at this time.
0 commit comments