Telegram companion bot, phase 1

New tgbot.js (raw Bot API, zero deps, private-chats only so the
group feeds are untouched): wallet-verified linking via dashboard
deep-link codes, personal payout + joined-on-your-link DMs, a
message bridge that delivers site messages natively in Telegram
with reply-to-answer routing (matrix-line permissions enforced by
the existing messages.js rules), and links/msg/help commands.
Webhook self-registers; secret derived from the token. Config key
companionBotToken overrides the feed bot token when Marty creates
a dedicated bot. Dashboard Messages panel gains Connect Telegram;
chatbot + AI prompt synced.
This commit is contained in:
martbost
2026-08-22 19:39:55 -05:00
parent 89a7e60fcb
commit 6ac1bcab55
4 changed files with 202 additions and 0 deletions
+17
View File
@@ -295,6 +295,23 @@
st.textContent='Sent ✓';setTimeout(function(){loadMsgUI(d);},700);
}catch(e){st.textContent='Send failed — try again.';sb.disabled=false;}
});
// Telegram companion link — payout pings + team messages in Telegram
try{
const foot=document.createElement('div');
foot.style.cssText='margin-top:12px;padding-top:10px;border-top:1px solid var(--line, #24425d)';
foot.innerHTML='<button id="tgLinkBtn" class="btn btn-secondary btn-sm">✈️ Connect Telegram — payout pings + team chat</button><span class="micro" id="tgLinkNote" style="margin-left:8px"></span>';
el.appendChild(foot);
const tb=document.getElementById('tgLinkBtn');
tb.addEventListener('click',async function(){
tb.disabled=true;
try{
const r=await(await fetch('/api/public/tg-link',{method:'POST'})).json();
if(r.url){window.open(r.url,'_blank','noopener');document.getElementById('tgLinkNote').textContent='Tap START in Telegram to finish linking.';}
else document.getElementById('tgLinkNote').textContent=r.error||'Try again shortly.';
}catch(e){document.getElementById('tgLinkNote').textContent='Network hiccup — try again.';}
tb.disabled=false;
});
}catch(e){}
}
async function msgAuth(d){
const err=document.getElementById('msgAuthErr');