Skip to content

Commit

Permalink
lib/events: Order attributes to replace by length
Browse files Browse the repository at this point in the history
_ref: #875
  • Loading branch information
sogehige committed Mar 27, 2018
1 parent 4d1f96d commit 079c91e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/events.js
Expand Up @@ -183,6 +183,8 @@ class Events {
const d = debug('events:fireSendChatMessageOrWhisper')
let username = _.isNil(attributes.username) ? global.parser.getOwner() : attributes.username
let message = operation.messageToSend

attributes = _(attributes).toPairs().sortBy((o) => -o[0].length).fromPairs().value() // reorder attributes by key length
_.each(attributes, function (val, name) {
if (_.isObject(val) && _.size(val) === 0) return true // skip empty object
d(`Replacing $${name} with ${val}`)
Expand Down

0 comments on commit 079c91e

Please sign in to comment.