- Live job card widget (progress bar, in-widget cancel via widget_query) and live invoice widget (QR drawn from a bitmap, countdown, paid state), Bot API 10.4 sendWidget, private chats only - Automatic fallback to the ordinary message when sendWidget fails, with a breaker that pauses widgets after repeated failures or on servers without the method; TELEGRAM_WIDGETS - Prometheus metrics on the core (/metrics) and on every worker: queue depth and wait, slots, heartbeats, job outcomes, errors per site, deliveries, cache, invoices, Lightning, ledger check, widgets - Example Prometheus config and alert rules, Caddyfile, dashboard notes - Load test: cmd/loadtest and deploy/loadtest (make loadtest) - Browser check of the widgets' HTML, including decoding a drawn QR - docs/DEPLOY.md (production in under an hour) and docs/MONITORING.md Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
38 lines
2.0 KiB
HTML
38 lines
2.0 KiB
HTML
<style>
|
|
body{margin:0;padding:10px 12px 0;text-align:center}
|
|
#t{color:var(--tg-theme-hint-color);font-size:13px}
|
|
#a{font-size:26px;font-weight:700;margin:2px 0 6px}
|
|
canvas{display:block;margin:4px auto;border-radius:8px;background:#fff}
|
|
#w{color:var(--tg-theme-hint-color);font-size:13px;font-variant-numeric:tabular-nums;margin:6px 0 0}
|
|
#k{display:none;width:56px;height:56px;margin:8px auto 4px;border-radius:50%;background:#2e9e5b;color:#fff;font-size:32px;line-height:56px}
|
|
#m{font-weight:600;white-space:pre-wrap}
|
|
.paid #k{display:block}.paid canvas,.paid #w,.closed canvas,.closed #w{display:none}
|
|
#e{padding-bottom:max(10px,env(safe-area-inset-bottom))}
|
|
</style>
|
|
<div id="t"></div><div id="a"></div><div id="k">✓</div><canvas id="q" width="0" height="0"></canvas><div id="m"></div><div id="w"></div><div id="e"></div>
|
|
<script>
|
|
var W=window.TelegramWidget,$=function(i){return document.getElementById(i)},P={},C={},drawn=0;
|
|
function j(v){try{return JSON.parse(v)||{}}catch(e){return{}}}
|
|
function qr(){
|
|
if(drawn||!P.q||!P.n)return;drawn=1;
|
|
var n=P.n,s=Math.max(2,Math.floor(208/(n+4))),c=$("q"),x=c.getContext("2d"),b=atob(P.q);
|
|
c.width=c.height=(n+4)*s;x.fillStyle="#fff";x.fillRect(0,0,c.width,c.height);x.fillStyle="#000";
|
|
for(var r=0;r<n;r++){var run=-1;for(var k=0;k<=n;k++){var i=r*n+k,on=k<n&&(b.charCodeAt(i>>3)>>(7-(i&7))&1);
|
|
if(on&&run<0)run=k;if(!on&&run>=0){x.fillRect((run+2)*s,(r+2)*s,(k-run)*s,s);run=-1}}}
|
|
}
|
|
function tick(){
|
|
if(C.s&&C.s!=="pending")return;
|
|
var l=Math.max(0,Math.floor(P.e-Date.now()/1000)),m=Math.floor(l/60),z=l%60;
|
|
$("w").textContent=l>0?(P.w||"").replace("{T}",m+":"+(z<10?"0":"")+z):(P.c||"");
|
|
}
|
|
function draw(){
|
|
P=j(W.publicData);C=j(W.chatData);
|
|
document.documentElement.dir=P.r?"rtl":"ltr";
|
|
$("t").textContent=P.t||"";$("a").textContent=P.a||"";$("m").textContent=C.m||"";
|
|
document.body.className=C.s==="paid"?"paid":(C.s&&C.s!=="pending"?"closed":"");
|
|
qr();tick();
|
|
}
|
|
W.onEvent("chatDataChanged",draw);W.onEvent("publicDataChanged",draw);
|
|
draw();setInterval(tick,1000);W.ready();
|
|
</script>
|