Mirror Telegram group posts into the Crypto Team Build Discord
Discord relaunch 2026-10-09: the shared discord-relay.cjs fans every post that goes to the community group out to the matching Discord channel (achievements topic -> #achievements, payments topic -> #payment-proofs) through DISCORD_WEBHOOK_* webhooks. Telegram HTML is converted to Discord markdown, buttons become links, cards post as images. DMs and alert chats are not mirrored. Fire-and-forget; off when the env is unset. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
// Faucet: HUNT_WALLET_KEY + HUNT_RPC (+ HUNT_CHAIN_ID). Admin: ADMIN_KEY. Hand-off: HUNT_SSO_SECRET.
|
||||
'use strict';
|
||||
const http = require('http');
|
||||
const discordRelay = require('./discord-relay.cjs'); // mirror group posts into the CTB Discord (2026-10-09)
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
@@ -62,6 +63,7 @@ async function telegram(text, topicOverride) {
|
||||
if (!outbound()) return false; // the gate
|
||||
const tok = process.env.HUNT_TG_TOKEN, chat = process.env.HUNT_TG_CHAT, topic = topicOverride || process.env.HUNT_TG_TOPIC;
|
||||
if (!tok || !chat) return false;
|
||||
discordRelay.mirror({ chatId: chat, threadId: topic ? Number(topic) : undefined, text });
|
||||
const body = JSON.stringify(Object.assign({ chat_id: chat, text, parse_mode: 'HTML', disable_web_page_preview: true }, topic ? { message_thread_id: Number(topic) } : {}));
|
||||
try { const r = await fetch('https://api.telegram.org/bot' + tok + '/sendMessage', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body }); return r.ok; } catch (e) { return false; }
|
||||
}
|
||||
@@ -69,6 +71,7 @@ async function telegramPhoto(file, caption, general, topicOverride) {
|
||||
if (!outbound()) return false; // the gate
|
||||
const tok = process.env.HUNT_TG_TOKEN, chat = process.env.HUNT_TG_CHAT, topic = topicOverride || process.env.HUNT_TG_TOPIC;
|
||||
if (!tok || !chat || !file) return false;
|
||||
discordRelay.mirror({ chatId: chat, threadId: topic && !general ? Number(topic) : undefined, text: caption, photo: fs.readFileSync(file) });
|
||||
try {
|
||||
const fd = new FormData(); fd.append('chat_id', chat); fd.append('caption', caption); fd.append('parse_mode', 'HTML'); if (topic && !general) fd.append('message_thread_id', String(topic));
|
||||
fd.append('photo', new Blob([fs.readFileSync(file)], { type: 'image/jpeg' }), 'badge.jpg');
|
||||
|
||||
Reference in New Issue
Block a user