mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
replay in web UI
This commit is contained in:
@@ -300,6 +300,24 @@ async function buildReplayVideo() {
|
||||
}
|
||||
}
|
||||
|
||||
function buildReplayCaption(requester) {
|
||||
const requesterLabel = requester || 'unknown';
|
||||
return [
|
||||
`Replay requested by ${requesterLabel}.`,
|
||||
buildDriverCaption(),
|
||||
].join(' ');
|
||||
}
|
||||
|
||||
async function sendReplayToChannel(channelId, requester) {
|
||||
if (!channelId) {
|
||||
throw new Error('Replay channel not configured');
|
||||
}
|
||||
const buffer = await buildReplayVideo();
|
||||
const attachment = new AttachmentBuilder(buffer, { name: 'replay.mp4' });
|
||||
const caption = buildReplayCaption(requester);
|
||||
await sendToChannel(channelId, caption, { files: [attachment] }, { parse: [] });
|
||||
}
|
||||
|
||||
async function handleReplayCommand(message) {
|
||||
if (getMode() === MODES.LOCKDOWN) {
|
||||
await message.reply({
|
||||
@@ -325,10 +343,7 @@ async function handleReplayCommand(message) {
|
||||
try {
|
||||
const buffer = await buildReplayVideo();
|
||||
const attachment = new AttachmentBuilder(buffer, { name: 'replay.mp4' });
|
||||
const caption = [
|
||||
`Replay requested by ${requester}.`,
|
||||
buildDriverCaption(),
|
||||
].join(' ');
|
||||
const caption = buildReplayCaption(requester);
|
||||
await message.reply({
|
||||
content: sanitizeMentions(caption),
|
||||
files: [attachment],
|
||||
@@ -701,6 +716,11 @@ function handleBusEvent(event) {
|
||||
});
|
||||
updatePresence();
|
||||
break;
|
||||
case 'replay.requested':
|
||||
sendReplayToChannel(payload?.channelId, payload?.requester).catch((err) => {
|
||||
logger.warn('Replay send failed', err.message);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user