Skip to content

Commit

Permalink
client: add "automod" event for related msg-id's
Browse files Browse the repository at this point in the history
Closes #273, replacing the change by c3e1294
  • Loading branch information
AlcaDesign committed Jun 16, 2019
1 parent 6afd8b8 commit ee07ce3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ client.prototype.handleMessage = function handleMessage(message) {
case "no_permission":
case "msg_banned":
case "msg_room_not_found":
case "msg_rejected_mandatory":
case "msg_channel_suspended":
case "tos_ban":
this.log.info(basicLog);
Expand Down Expand Up @@ -566,15 +565,18 @@ client.prototype.handleMessage = function handleMessage(message) {
"_promiseEmoteonlyoff"
], [noticeArr, [msgid, channel]]);
break;

// Automod-related..
case "msg_rejected":
case "msg_rejected_mandatory":
this.log.info(basicLog);
this.emit("automod", channel, msgid, msg);
break;

// Unrecognized command..
case "unrecognized_cmd":
this.log.info(basicLog);
this.emit("notice", channel, msgid, msg);

if (msg.split(" ").splice(-1)[0] === "/w") {
this.log.warn("You must be connected to a group server to send or receive whispers.");
}
break;

// Send the following msg-ids to the notice event listener..
Expand All @@ -593,7 +595,6 @@ client.prototype.handleMessage = function handleMessage(message) {
case "msg_followersonly":
case "msg_followersonly_followed":
case "msg_followersonly_zero":
case "msg_rejected":
case "msg_slowmode":
case "msg_suspended":
case "no_help":
Expand Down
16 changes: 16 additions & 0 deletions test/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ var events = [{
},
'Hello :)'
]
}, {
name: 'automod',
data: "@msg-id=msg_rejected :tmi.twitch.tv NOTICE #schmoopiie :Hey! Your message is being checked by mods and has not been sent.",
expected: [
'#schmoopiie',
'msg_rejected',
'Hey! Your message is being checked by mods and has not been sent.'
]
}, {
name: 'automod',
data: "@msg-id=msg_rejected_mandatory :tmi.twitch.tv NOTICE #schmoopiie :Your message wasn't posted due to conflicts with the channel's moderation settings.",
expected: [
'#schmoopiie',
'msg_rejected_mandatory',
"Your message wasn't posted due to conflicts with the channel's moderation settings."
]
}, {
name: 'ban',
data: '@room-id=20624989;target-user-id=20624989 :tmi.twitch.tv CLEARCHAT #schmoopiie :schmoopiie',
Expand Down

0 comments on commit ee07ce3

Please sign in to comment.