Added say command with operator config.
This commit is contained in:
parent
2ddac57365
commit
18ffdefffb
|
@ -11,6 +11,7 @@ module.exports = {
|
||||||
birthdate: new Date(1952, 11, 10),
|
birthdate: new Date(1952, 11, 10),
|
||||||
avatar: 'https://i.imgur.com/IZwrjjG.png',
|
avatar: 'https://i.imgur.com/IZwrjjG.png',
|
||||||
},
|
},
|
||||||
|
operators: ['admin'],
|
||||||
uniqueUsername: true,
|
uniqueUsername: true,
|
||||||
socket: 'ws://127.0.0.1:3000/socket',
|
socket: 'ws://127.0.0.1:3000/socket',
|
||||||
api: 'http://127.0.0.1:3000/api',
|
api: 'http://127.0.0.1:3000/api',
|
||||||
|
@ -20,7 +21,7 @@ module.exports = {
|
||||||
color: 'var(--message-56)',
|
color: 'var(--message-56)',
|
||||||
},
|
},
|
||||||
channels: ['GamesNight'],
|
channels: ['GamesNight'],
|
||||||
games: ['mash', 'trivia', 'ping', 'duck'],
|
games: ['mash', 'trivia', 'duck', 'ping', 'say'],
|
||||||
trivia: {
|
trivia: {
|
||||||
mode: 'first', // first or timeout
|
mode: 'first', // first or timeout
|
||||||
rounds: 10,
|
rounds: 10,
|
||||||
|
|
|
@ -209,10 +209,10 @@ function getGames(bot) {
|
||||||
const games = config.games.reduce((acc, key) => {
|
const games = config.games.reduce((acc, key) => {
|
||||||
const game = require(`./games/${key.game || key}`); // eslint-disable-line global-require, import/no-dynamic-require
|
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', {
|
bot.socket.transmit('message', {
|
||||||
roomId,
|
roomId,
|
||||||
body: `[${game.name || key}] ${body}`,
|
body: options?.label === false ? body : `[${game.name || key}] ${body}`,
|
||||||
style: config.style,
|
style: config.style,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -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,
|
||||||
|
};
|
Loading…
Reference in New Issue