|
| 1 | +#!/usr/bin/nodejs |
| 2 | +/* jshint browser:true, mocha:true, node:true, devel:true */ |
| 3 | +/* globals */ |
| 4 | + |
| 5 | +/* |
| 6 | + * @author Xunnamius |
| 7 | + */ |
| 8 | + |
| 9 | +"use strict"; |
| 10 | + |
| 11 | +const globals = {}; |
| 12 | + |
| 13 | +globals.reuse = (strings) => (...vars) => strings.map((v, i) => `${v}${vars[i] || ''}`).join(''); |
| 14 | + |
| 15 | +globals.LAX_PREVIEW_CHANNEL_ID = '316789032447377423'; |
| 16 | +globals.PUBLIC_WARNING_SLEEP = 5000; |
| 17 | +globals.TYPING_RESPONSE_SLEEP = 2000; |
| 18 | +globals.CMD_PREFIX = '!'; |
| 19 | +globals.TYPING_RESPONSE_DELAY = 2000; |
| 20 | +globals.TYPING_RESPONSE_DELAY_DECAY = 3; |
| 21 | +globals.TYPING_RESPONSE_DELAY_MIN = 500; |
| 22 | + |
| 23 | +globals.IS_RUNNING_WINDOWS = process.platform == 'win32'; |
| 24 | +globals.DEBUG_MODE = parseInt(process.env.APP_DEBUG_LEVEL || 0); |
| 25 | +globals.SUPER_DEBUG_MODE = DEBUG_MODE > 1; |
| 26 | +globals.APP_ENV = process.env.APP_ENV; |
| 27 | + |
| 28 | +globals.inspect = obj => |
| 29 | +{ |
| 30 | + return util.inspect(obj, false, DEBUG_MODE || 1, true); |
| 31 | +}; |
| 32 | + |
| 33 | +globals.implementMessageExtras = (message) => |
| 34 | +{ |
| 35 | + message.forUs = false; |
| 36 | + message.mentions.byName = false; |
| 37 | + message.mentions.byPrefix = false; |
| 38 | + |
| 39 | + message.sender = message.member ? message.member.displayName : `${message.author.tag} (member not on server)`; |
| 40 | + |
| 41 | + if(message.isMentioned(client.user.id) && message.cleanContent.indexOf('@') == message.cleanContent.lastIndexOf('@')) |
| 42 | + message.mentions.byName = true; |
| 43 | + |
| 44 | + if(message.cleanContent.startsWith(CMD_PREFIX)) |
| 45 | + message.mentions.byPrefix = true; |
| 46 | + |
| 47 | + message.forUs = message.member |
| 48 | + && client.user.id != message.member.id |
| 49 | + && (message.mentions.byName || message.mentions.byPrefix); |
| 50 | + |
| 51 | + message.text = message.cleanContent.replace(`@${client.nickname}`, '') |
| 52 | + .replace(`@${client.user.username}`, '') |
| 53 | + .replace(`@${client.user.tag}`, '') |
| 54 | + .replace(' ', ' ') |
| 55 | + .trim(); |
| 56 | + |
| 57 | + if(message.mentions.byPrefix) |
| 58 | + message.text = message.cleanContent.substring(CMD_PREFIX.length).trim(); |
| 59 | +}; |
| 60 | + |
| 61 | +globals.implementChannelExtras = (channel) => |
| 62 | +{ |
| 63 | + channel.typeAndSend = (...msg) => responseQueues.get(channel.id).add(...msg); |
| 64 | +}; |
| 65 | + |
| 66 | +module.exports = globals; |
0 commit comments