UNPKG

teeworlds-econ

Version:
30 lines (26 loc) 837 B
var debug, handleChatMessage; debug = require('../utils').debug; handleChatMessage = function(econ, message) { var matches; if (matches = /^\[(teamchat|chat)\]: ([0-9]+):([0-9-]+):(.+?): (.*)$/.exec(message)) { debug.events('%s:%s econ %s event', econ.server.host, econ.server.port, 'chat'); econ.emit('chat', { type: matches[1], player: matches[4], message: matches[5], team: parseInt(matches[3]), client: econ.getClientInfo(parseInt(matches[2])) }); } if (matches = /^\[chat\]: \*\*\* (.*)$/.exec(message)) { debug.events('%s:%s econ %s event', econ.server.host, econ.server.port, 'chat'); return econ.emit('chat', { type: 'server', player: null, message: matches[1], team: null, client: null }); } }; module.exports = handleChatMessage;