···
import { version } from "../package.json";
import { registerCommands } from "./commands";
import { channelMappings, userMappings } from "./db";
6
+
import { uploadToCDN } from "./lib/cdn";
import { parseIRCFormatting, parseSlackMarkdown } from "./parser";
import type { CachetUser } from "./types";
···
254
-
console.log(`IRC → Slack: <${nick}> ${text}`);
255
+
console.log(`IRC (${to}) → Slack: <${nick}> ${text}`);
console.error("Error posting to Slack:", error);
···
345
-
console.log(`IRC → Slack (action): ${actionText}`);
346
+
console.log(`IRC (${to}) → Slack (action): ${actionText}`);
350
-
slackApp.event("message", async ({ payload, context }) => {
351
+
slackApp.event("message", async ({ payload }) => {
// Ignore bot messages and threaded messages
if (payload.subtype && payload.subtype !== "file_share") return;
if (payload.bot_id) return;
···
if (payload.files && payload.files.length > 0) {
434
-
// Extract private file URLs
const fileUrls = payload.files.map((file) => file.url_private);
437
-
// Upload to Hack Club CDN
438
-
const response = await fetch("https://cdn.hackclub.com/api/v3/new", {
441
-
Authorization: `Bearer ${process.env.CDN_TOKEN}`,
442
-
"X-Download-Authorization": `Bearer ${process.env.SLACK_BOT_TOKEN}`,
443
-
"Content-Type": "application/json",
445
-
body: JSON.stringify(fileUrls),
436
+
const data = await uploadToCDN(fileUrls);
449
-
const data = await response.json();
451
-
// Send each uploaded file URL to IRC
452
-
for (const file of data.files) {
453
-
const fileMessage = `<${username}> ${file.deployedUrl}`;
454
-
ircClient.say(mapping.irc_channel, fileMessage);
455
-
console.log(`Slack → IRC (file): ${fileMessage}`);
458
-
console.error("Failed to upload files to CDN:", response.statusText);
438
+
for (const file of data.files) {
439
+
const fileMessage = `<${username}> ${file.deployedUrl}`;
440
+
ircClient.say(mapping.irc_channel, fileMessage);
441
+
console.log(`Slack → IRC (file): ${fileMessage}`);
console.error("Error uploading files to CDN:", error);