Skip to content

Commit

Permalink
client: some channels return empty lists #480
Browse files Browse the repository at this point in the history
  • Loading branch information
AlcaDesign committed Aug 10, 2021
1 parent ca392a0 commit a3343ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ client.prototype.handleMessage = function handleMessage(message) {

// The moderators of this room are: [..., ...]
case 'room_mods': {
const mods = msg.split(': ')[1].toLowerCase()
const listSplit = msg.split(': ');
const mods = (listSplit.length > 1 ? listSplit[1] : '').toLowerCase()
.split(', ')
.filter(n => n);

Expand All @@ -300,7 +301,8 @@ client.prototype.handleMessage = function handleMessage(message) {
if(msg.endsWith('.')) {
msg = msg.slice(0, -1);
}
const vips = msg.split(': ')[1].toLowerCase()
const listSplit = msg.split(': ');
const vips = (listSplit.length > 1 ? listSplit[1] : '').toLowerCase()
.split(', ')
.filter(n => n);

Expand Down
14 changes: 14 additions & 0 deletions test/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,20 @@ const events = [ {
'#schmoopiie',
[ 'user1', 'user2', 'user3' ]
]
}, {
name: 'mods',
data: '@msg-id=room_mods :tmi.twitch.tv NOTICE #schmoopiie :The moderators of this room are:',
expected: [
'#schmoopiie',
[]
]
}, {
name: 'mods',
data: '@msg-id=room_mods :tmi.twitch.tv NOTICE #schmoopiie :The moderators of this room are: ',
expected: [
'#schmoopiie',
[]
]
}, {
name: 'mods',
data: '@msg-id=no_mods :tmi.twitch.tv NOTICE #schmoopiie :There are no moderators of this channel.',
Expand Down

0 comments on commit a3343ec

Please sign in to comment.