Skip to content

Commit

Permalink
moderation: fix whisper emote moderation
Browse files Browse the repository at this point in the history
PR #1763
Fixes #1761
  • Loading branch information
sogehige committed Jan 31, 2019
1 parent 5087cb3 commit 3c18bfb
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/bot/api.js
Expand Up @@ -933,7 +933,11 @@ class API {
if (global.panel && global.panel.io) global.panel.io.emit('api.stats', { data: request.data, timestamp: _.now(), call: 'getCurrentStreamData', api: 'helix', endpoint: url, code: request.status, remaining: this.calls.bot.remaining })

let justStarted = false
global.log.debug('API: ' + JSON.stringify(request.data))

if (__DEBUG__.STREAM) {
global.log.debug('API: ' + JSON.stringify(request.data))
}

if (request.status === 200 && !_.isNil(request.data.data[0])) {
// correct status and we've got a data - stream online
let stream = request.data.data[0]
Expand Down
5 changes: 3 additions & 2 deletions src/bot/cluster.js
Expand Up @@ -113,11 +113,12 @@ function cluster () {

if (!skip && sender['message-type'] === 'whisper' && (!(await global.configuration.getValue('disableWhisperListener')) || global.commons.isOwner(sender))) {
global.log.whisperIn(message, { username: sender.username })
} else if (!skip && !await global.commons.isBot(sender.username)) global.log.chatIn(message, { username: sender.username })
} else if (!skip && !await global.commons.isBot(sender.username)) {
global.log.chatIn(message, { username: sender.username })
}

const isModerated = await parse.isModerated()
const isIgnored = await global.commons.isIgnored(sender)

if (!isModerated && !isIgnored) {
if (!skip && !_.isNil(sender.username)) {
let user = await global.db.engine.findOne('users', { id: sender.userId })
Expand Down
4 changes: 2 additions & 2 deletions src/bot/logging.js
Expand Up @@ -41,7 +41,7 @@ const levels = {
info: 12,
start: 12,
stop: 12,
debug: 13,
debug: 12,
process: 99999
}

Expand All @@ -62,7 +62,7 @@ if (cluster.isWorker) {
format.printf(info => {
let level
if (info.level === 'error') level = '!!! ERROR !!!'
if (info.level === 'debug') level = 'DEBUG:'
if (info.level === 'debug') level = chalk.bgRed.bold('DEBUG:')
if (info.level === 'chatIn') level = '<<<'
if (info.level === 'chatOut') level = '>>>'
if (info.level === 'whisperIn') level = '<w<'
Expand Down
6 changes: 6 additions & 0 deletions src/bot/parser.js
Expand Up @@ -4,6 +4,9 @@ const _ = require('lodash')

const constants = require('./constants')

const __DEBUG__ =
(process.env.DEBUG && process.env.DEBUG.includes('parser'));

class Parser {
constructor (opts) {
opts = opts || {}
Expand Down Expand Up @@ -36,6 +39,9 @@ class Parser {
}
const isOk = await parser['fnc'].apply(parser.this, [opts])
if (!isOk) {
if (__DEBUG__) {
global.log.debug(parser['fnc']);
}
return true
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/bot/systems/moderation.js
Expand Up @@ -417,7 +417,7 @@ class Moderation extends System {
}

async emotes (opts) {
if (!(Symbol.iterator in Object(opts.sender.emotes))) return
if (!(Symbol.iterator in Object(opts.sender.emotes))) return true
let [isEnabled, isEnabledForSubs, isOwner, isMod, timeout, maxCount] = await Promise.all([
this.settings.emotes.enabled,
this.settings.emotes.moderateSubscribers,
Expand Down

0 comments on commit 3c18bfb

Please sign in to comment.