mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 17:40:46 -04:00
replay beroke
This commit is contained in:
@@ -153,7 +153,7 @@ const commands = createCommandHandlers({
|
||||
config,
|
||||
});
|
||||
|
||||
const integrations = createIntegrations({
|
||||
const integrations = createIntegrations({
|
||||
logger,
|
||||
client,
|
||||
config,
|
||||
@@ -184,6 +184,7 @@ const integrations = createIntegrations({
|
||||
clearTypingMessage: channelIO.clearTypingMessage,
|
||||
sendTypingMessage: channelIO.sendTypingMessage,
|
||||
schedulePresenceRotation: presence.schedulePresenceRotation,
|
||||
buildReplayVideo,
|
||||
});
|
||||
|
||||
const integrationHandlers = integrations.register();
|
||||
|
||||
@@ -5,7 +5,7 @@ const { EmbedBuilder, AttachmentBuilder } = require('discord.js');
|
||||
const { buildBatteryStatusEmbed, buildBatteryCaption } = require('../batteryEmbeds');
|
||||
|
||||
function createBusEventHandler(deps) {
|
||||
const { logger, discordConfig, MODES, roverManager, rovers, schedulePresenceRotation, formatDuration, sendToChannel } = deps;
|
||||
const { logger, discordConfig, MODES, roverManager, rovers, schedulePresenceRotation, formatDuration, sendToChannel, buildReplayVideo } = deps;
|
||||
const ADMIN_ALERT_EVENT_TYPES = new Set(['rover.online', 'rover.offline', 'rover.dockGuard', 'battery.warn', 'battery.urgent', 'battery.docked', 'battery.undocked', 'battery.charging.start', 'battery.charging.stop', 'battery.locked', 'battery.unlocked']);
|
||||
let skippedFirstModeAnnouncement = false;
|
||||
|
||||
@@ -26,7 +26,33 @@ function createBusEventHandler(deps) {
|
||||
await sendToChannel(channelId, `${prefix}${content || ''}`.trim(), { embeds: payloadEmbeds, files: Array.isArray(files) ? files : undefined }, { parse: [], roles: pingRoleId ? [pingRoleId] : [] }, !pingRoleId);
|
||||
}
|
||||
|
||||
return function handleBusEvent(event) {
|
||||
function sanitizeReplayTitleForFilename(title) {
|
||||
const cleaned = String(title || '').replace(/[\\/:*?"<>|]+/g, ' ').replace(/\s+/g, ' ').trim().slice(0, 96);
|
||||
return cleaned || 'replay';
|
||||
}
|
||||
|
||||
async function sendReplayToChannel(channelId, requester, sources = [], explicitTitle = '', includeSidebar = true) {
|
||||
if (!channelId) throw new Error('Replay channel not configured');
|
||||
const resolvedTitle = String(explicitTitle || '').trim() || `${String(requester || 'Someone').trim() || 'Someone'} replay`;
|
||||
const { buffer } = await buildReplayVideo({ sources, title: resolvedTitle, requester, includeSidebar });
|
||||
const attachment = new AttachmentBuilder(buffer, { name: `${sanitizeReplayTitleForFilename(resolvedTitle)}.mp4` });
|
||||
await sendToChannel(channelId, `**${resolvedTitle}**`, { files: [attachment] }, { parse: [] });
|
||||
}
|
||||
|
||||
function handleReplayRequested(event) {
|
||||
const payload = event?.payload || {};
|
||||
sendReplayToChannel(
|
||||
payload?.channelId,
|
||||
payload?.requester,
|
||||
payload?.sources || [],
|
||||
payload?.title || '',
|
||||
payload?.includeSidebar !== false,
|
||||
).catch((err) => {
|
||||
logger.warn('Replay send failed', { error: err.message });
|
||||
});
|
||||
}
|
||||
|
||||
function handleBusEvent(event) {
|
||||
const { type, payload } = event || {};
|
||||
const channels = discordConfig.channels || {};
|
||||
const roles = discordConfig.roles || {};
|
||||
@@ -84,10 +110,15 @@ function createBusEventHandler(deps) {
|
||||
announce({ channelId: channels.humanAlerts, pingRoleId: roles.humanAlertPing || null, content: payload?.message || 'Human alert button pressed.', embeds: [buildEmbed({ title: 'Human Alert Button Pressed', description: null, color: 0xe53935 })], files: attachment ? [attachment] : [] });
|
||||
break;
|
||||
}
|
||||
case 'replay.requested':
|
||||
handleReplayRequested(event);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return { handleBusEvent, handleReplayRequested };
|
||||
}
|
||||
|
||||
module.exports = { createBusEventHandler };
|
||||
|
||||
@@ -19,7 +19,7 @@ function createIntegrations(deps) {
|
||||
|
||||
const dm = createDmModerationHandlers({ ...deps, sanitizeMentions });
|
||||
const chat = createChatBridgeHandlers({ ...deps, clearTypingMessage, sendTypingMessage, formatWebhookUsername, getTypingId });
|
||||
const handleBusEvent = createBusEventHandler({ ...deps, sendToChannel, schedulePresenceRotation, formatDuration });
|
||||
const { handleBusEvent, handleReplayRequested } = createBusEventHandler({ ...deps, sendToChannel, schedulePresenceRotation, formatDuration });
|
||||
|
||||
function register() {
|
||||
client.on('typingStart', (typing) => {
|
||||
@@ -32,6 +32,7 @@ function createIntegrations(deps) {
|
||||
});
|
||||
|
||||
subscribe('*', handleBusEvent);
|
||||
subscribe('replay.requested', handleReplayRequested);
|
||||
subscribe('verification.requested', dm.sendVerificationRequestDms);
|
||||
subscribe('privateRoverAccess.requested', dm.sendPrivateRoverAccessRequestDms);
|
||||
subscribe('chat:message', chat.handleChatBridgeOutbound);
|
||||
|
||||
Reference in New Issue
Block a user