asdqwex/discobot

View on GitHub
src/modules/table_flip.js

Summary

Maintainability
B
4 hrs
Test Coverage
'use strict'

module.exports = {
  names: '(╯°□°)╯︵ ┻━┻',
  onMessage: function (bot, user, userID, channelID, message, rawEvent) {
    //
    // Table flipper!
    //
    if (message.indexOf('(╯°□°)╯︵ ┻━┻') > -1 && message.indexOf('will flip all table back upright') === -1) {
      const count = (message.match(/\(\╯\°\□\°\)\╯\︵ \┻\━\┻/g) || []).length
      const tableArray = []
      for (let i = 0; i < count; i++) {
        tableArray.push('┬─┬ ノ( ゜-゜ノ)')
      }
      return bot.sendMessage({
        to: channelID,
        message: tableArray.join(' ')
      })
    }
  }
}