Added say command with operator config.
This commit is contained in:
@@ -209,10 +209,10 @@ function getGames(bot) {
|
||||
const games = config.games.reduce((acc, key) => {
|
||||
const game = require(`./games/${key.game || key}`); // eslint-disable-line global-require, import/no-dynamic-require
|
||||
|
||||
const sendMessage = (body, roomId) => {
|
||||
const sendMessage = (body, roomId, options) => {
|
||||
bot.socket.transmit('message', {
|
||||
roomId,
|
||||
body: `[${game.name || key}] ${body}`,
|
||||
body: options?.label === false ? body : `[${game.name || key}] ${body}`,
|
||||
style: config.style,
|
||||
});
|
||||
};
|
||||
|
||||
23
src/games/say.js
Normal file
23
src/games/say.js
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
const config = require('config');
|
||||
|
||||
function onCommand([rawRoomName, ...words], context) {
|
||||
if (!config.operators?.includes(context.user.username)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const roomName = rawRoomName.replace(/#+/, '');
|
||||
const message = words.join(' ');
|
||||
const room = Object.values(context.bot.rooms).find((botRoom) => botRoom.name === roomName);
|
||||
|
||||
if (!room) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.sendMessage(message, room.id, { label: false });
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
onCommand,
|
||||
};
|
||||
Reference in New Issue
Block a user