serejaris/telegram-skills / skills/tg-widgets
tg-widgets
VerifiedUse when building or sending a Telegram message widget (HTML bubble, HTMLBubbles, `sendWidget`, `messageMediaWidget`, Bot API 10.4): an interactive HTML, CSS and JS program inside a chat bubble, such as a game, poll, calculator or live ticker. Teaches everything needed to write one: size, bubble, input, sandbox rules, state and requests, sending, and which chats accept a widget in production. Not for Mini Apps or Rich Messages.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 12.3 KB |
| examples/aquarium-pixel.html | other | 7.4 KB |
| examples/index.html | other | 5.3 KB |
| examples/night-deploy-pixel.html | other | 6.9 KB |
| examples/night-deploy-textmode.html | other | 7.2 KB |
| examples/textmode-panel.html | other | 3.7 KB |
| scripts/widget_tool.py | script | 2.3 KB |
| tests/test_widget_tool.py | script | 883 B |
examples/night-deploy-pixel.html
View on GitHub<style>body{margin:0}#e{position:relative;overflow:hidden;background:#000;touch-action:none;user-select:none}canvas{position:absolute;top:0;left:0;image-rendering:pixelated}#f,#u{width:100%;height:100%}</style><div id=e><canvas id=b></canvas><canvas id=f></canvas><canvas id=u></canvas></div><script>const o=document,e=e=>o.getElementById(e),f=e("e"),t=e("b"),{sin:h,cos:l,hypot:s,random:c,min:d,max:n,floor:r,ceil:i,round:m}=Math,a=6.283,u=80,g=56,x=f.clientWidth||390,y=i(x/3),p=m(9*y/16),v=x/y,k=s(y,p)/2+8,w=(o,e,f)=>(o.width=e,o.height=f,o.getContext("2d")),L=()=>o.createElement("canvas"),z=w(e("f"),y,p),b=w(e("u"),y,p),j=w(t,y+u,p+g),E=L(),R=w(E,69,70),S=L(),I=w(S,u,g),A=(o,e,f,t,h,l=z)=>{l.fillStyle=o,l.fillRect(0|e,0|f,t,h)},B=(o,e,f,t,h=1)=>{b.fillStyle=t,[...o].forEach((o,t)=>{const l="АБВДЕЖИЙКЛМНПРСТУХЧЯФЩЬ0123456789:.+!*".indexOf(o);if(l>=0){const o=parseInt("ehvhhvguhuuhuhueaavhvgugvllellhjlphljlphhisihf999hhrlhhhhvhhvhhhhuhuggfgggfv4444hhf1uha4ahhhf11fhf9helle4lllv1gguhuehhhe4c44eu1cgvu1e1uhhv11vgu1ueguhev1244eheheehf1e040400000404e4044404level".substr(5*l,5),32);for(let l=0;25>l;l++)o>>24-l&1&&b.fillRect(e+6*t*h+l%5*h,f+r(l/5)*h,h,h)}})},C=(o,e,f,t=1)=>B(o,y-(6*o.length-1)*t>>1,e,f,t);let q=0;const F=["312 823 e45 f98 .o... ..ohh .owkm lohmm Lohmd lommd ..odd .ssss","410 b51 f81 fd6 ....o ...oh ..ohm .owkm ohmmd l.L.o .ssss","032 174 3c6 afa ....o ...oh ..ohh .ohhm .owkm ohmmm ommmd .oddd ..l.L .ssss","301 812 e34 f98 ..o......... ...o....oooo ....o.oohhhh oo...ohhhhhh ohoo.ohwwwhh ohho.ohwkkhh .oooohhwkkhm lL.oohhhhhmm l.ohmddddddd L.ohmddddddd L.ohmmdddddd ...ooddddddd ..l.L.oooooo .sssssssssss","112 249 37e 6bf ..ooo .oddd .odff .odkf .oddf ommhh ofcccccfo ofckkkcfo oocckccoo .oddd ..o.. ..l.. .ssss"].map(o=>{const e=o.split(" "),f=e.splice(0,4),t=2*e[0].length-1,h=q;for(let o=0;3>o;o++)setTimeout(()=>e.forEach((e,l)=>{t>e.length&&(e+=[...e.slice(0,-1)].reverse().map(o=>({h:"m",m:"d",l:"L",L:"l"}[o]||o)).join("")),[...e].forEach((e,s)=>{const c="l"==e?1!=o&&f[0]:"L"==e?o&&f[0]:"."==e?0:{w:"fff",k:"012",s:"0005",f:"fca",c:"5ef"}[e]||f["odmh".indexOf(e)];c&&A("#"+(o>1&&"s"!=e?"fff":c),o*t+s,h+l,1,1,R)})}),o);return q+=e.length,[h,t,e.length]}),O=(o,e,f,t)=>{const h=F[o];z.drawImage(E,e*h[1],h[0],h[1],h[2],m(f-h[1]/2),m(t-h[2]/2),h[1],h[2])},T="#012 #113 #124 #235 #256 #378".split(" "),$="#0003 #324 #435 #546 #012 #288 #7fe #fd6 #f78 #345 #236 #123 #4f8 #853 #296 #4c7".split(" ");let D=0;!function o(){for(let o=d(g,D+16);o>D;D++){let o,e=0;for(let f=0;u>=f;f++){const t=n(0,1-s(f-24,1.25*(D-20))/34),h=u>f&&T[r(4*(.28+(f%16&&D%16?0:.13)+t*t*.8)+.5*(1&(f^D))+.25*(1&D))];h!=o&&(o&&A(o,e,D,f-e,1,I),e=f,o=h)}}if(g>D)setTimeout(o);else{const o="(3@L+)2<L,*22L2+22L),3@*+,S@*+,7):3-8*81.9+/)/:-1).:/.)0912),?4++1;83+/N5++2<D2.,@J**(cB6*,b*6@3c+4>1d-2*4e-))1d42*0g4))";for(let e=0;o.length>e;e+=5){const f=f=>o.charCodeAt(e+f)-40;A($[f(0)],f(1),f(2),f(3),f(4),I)}for(let o=0;9>o;o++)j.drawImage(S,o%3*u,(o/3|0)*g)}}();const J=[[3,11,7,1],[2,25,4,1],[4,8.5,28,2],[10,10,300,8]],M=[["ПР0МПТ","+ПУЛЯ"],["К0ММИТ","КРУЖАТ"],["К0ФЕ","+СК0Р0СТЬ"],["П0СПАТЬ","+30"]];let N,W,X,Y,G,H,K,P,Q,U,V,Z,_,oo,eo,fo,to,ho,lo,so,co,no,ro,io,mo,ao,uo,go,xo,yo=0,po=0,vo=-1,ko=0,wo=0,Lo=0,zo=+localStorage.b||0;const bo=(o,e=c()*a,f=k,t=K,s=P)=>{const d=J[o],n={x:t+l(e)*f,y:s+h(e)*f,k:o,r:d[0],s:d[1],z:d[2]*(o>2?_:1+po/45),j:c()-.5,c:0};return(90>mo.length||o>2)&&mo.push(n),n},jo=()=>{Q=K+ro-y/2,U=P+io-p/2},Eo=o=>(o/60|0)+":"+("0"+(o%60|0)).slice(-2),Ro=(o,e)=>{o.z>0&&(o.f=.06,0>=(o.z-=e))&&(H++,uo.push({x:o.x,y:o.y,w:J[o.k][3],z:1}),uo.length>40&&uo.shift())},So=()=>{const o=2.5*wo&1,e=eo?eo.z/(300*_)*(y-41):-1,f=[yo,yo%3?0:o,X,Eo(po),H,N,Y,G,0|e,fo>0&&to]+"",t=(o,e,f,t,h)=>A(o,e,f,t,h,b),h=(p>>1)-22;if(f!=xo)if(xo=f,b.clearRect(0,0,y,p),1>yo%3)if(t("#000",0,0,y,p),yo)C("0РДА П0БЕДИЛА",h-1,"#f56"),C(Eo(po)+" *"+H,h+10,"#fff"),C("РЕК0РД "+Eo(zo),h+21,"#78a"),o&&C("ЕЩЕ РА3",h+34,"#4cf");else{const e=y-96>>1;B("Н0ЧН0Й",e,h+4,"#f56",2),B("ДЕПЛ0Й",e,h+16,"#4cf",2),B(".ЕХЕ",e+72,h+21,"#fd6"),o&&C("НАЖМИ",h+34,"#fff")}else if(2>yo&&(t("#0009",0,0,y,10),B("УР"+X,1,1,"#fff"),C(Eo(po),1,"#fff"),B("*"+H,y-6*(H+"").length-6,1,"#fd6"),t("#6d8",1,7,34*n(N,0)/W,2),0>e||t("#f56",38,7,e,2),t("#4cf",0,p-2,y*Y/G,2),fo>0&&C(to,13,"#fd6")),2==yo){const o=(p-9)/3|0;t("#012c",0,0,y,p),C("УР0ВЕНЬ "+X,1,"#4cf"),co.forEach((e,f)=>{const h=8+f*o,l=M[e],s=2>e?"#4cf":"#fd6";t(s,1,h,y-2,o-1),t("#124",2,h+1,y-4,o-3),B(l[0]+" "+(ho[e]+1),4,h+2+(o-13>>1),"#fff"),B(l[1],4,h+8+(o-13>>1),s)})}},Io=o=>{requestAnimationFrame(Io);const e=o-Lo;55>e||(Lo=o,wo+=e/1e3,1==yo&&((o=>{let e,f,t,r,i,m=k;po+=o,V-=o,fo-=o,so+=3.2*o,oo-=o,no&&jo(),e=Q-K,f=U-P,t=s(e,f),t&&(r=d(t,(30+4*ho[2])*o)/t,K+=e*r,P+=f*r),0>oo&&(oo=n(.11,.5/(1+po/25))*(eo?1.6:1),bo(c()*d(po/14,3)|0)),po>Z&&(Z+=60,_++,eo=bo(3),to="ПР0Д УПАЛ!",fo=2);for(const c of mo){e=K-c.x,f=P-c.y;const r=s(e,f)||1,u=c.u=e/r,g=c.v=f/r;if(c.f-=o,c.c-=o,r>1.5*k&&(c.x+=1.7*e,c.y+=1.7*f),c.x+=(u-g*c.j)*c.s*o,c.y+=(g+u*c.j)*c.s*o,m>r&&(m=r,i=c),1==yo&&c.r+3>r&&0>=V&&(N-=6+1.5*c.r|0,V=.6,N>0||(yo=3,vo=wo,localStorage.b=zo=n(po,zo))),0>c.c)for(let o=0;ho[1]>o;o++)t=so+o*a/ho[1],e=K+17*l(t)-c.x,f=P+17*h(t)-c.y,(c.r+3)**2>e*e+f*f&&(Ro(c,5+3*ho[1]),c.c=.3);c.k>2&&(c.x=n(K-y/2+12,d(K+y/2-12,c.x)),c.y=n(P-p/2+18,d(P+p/2-9,c.y)))}if(0>(lo-=o)&&i){lo=.62-.05*ho[0],eo&&.5>c()&&(i=eo),r=1+(ho[0]>>1);for(let o=0;r>o;o++)f=.2*(o-(r-1)/2),ao.push({x:K,y:P,u:95*(i.v*f-i.u),v:95*(-i.u*f-i.v),z:.8})}for(const t of ao){t.x+=t.u*o,t.y+=t.v*o,t.z-=o;for(const o of mo)e=t.x-o.x,f=t.y-o.y,t.z>0&&(o.r+1)**2>e*e+f*f&&(Ro(o,5+3*ho[0]),t.z=0)}for(const t of uo)e=K-t.x,f=P-t.y,r=s(e,f)||1,40>r&&(t.x+=e/r*80*o,t.y+=f/r*80*o,5>r&&(t.z=0,Y+=t.w));eo&&0>=eo.z&&(eo=0,N=d(W,N+25),Y+=20),mo=mo.filter(o=>o.z>0),ao=ao.filter(o=>o.z>0),uo=uo.filter(o=>o.z>0),G>Y||1!=yo||(Y-=G,X++,G=X*X/8+2*X+3|0,co=[0,1,2,3].sort(()=>c()-.5).slice(0,3),yo=2,vo=wo)})(d(e,100)/1e3),1==yo&&(()=>{const o=m(K-y/2),e=m(P-p/2),f=(o%u+u)%u*v,s=(e%g+g)%g*v,c=f+"px,"+-s;c!=go&&(go=c,t.style.transform=`translate(${-f}px,${-s}px)`),z.clearRect(0,0,y,p);for(const f of uo)A("#4cf",f.x-o,f.y-e,2,2);for(const f of mo)O(f.k,f.f>0?2:6*wo+9*f.j&1,f.x-o,f.y-e);for(const f of ao)A("#fd6",f.x-o-1,f.y-e-1,2,2);O(4,V>0?2:8*wo&1,K-o,P-e);for(let f=0;ho[1]>f;f++)A("#fd6",K-o+17*l(so+f*a/ho[1])-1,P-e+17*h(so+f*a/ho[1])-1,3,3)})()),So())},Ao=o=>{const e=f.getBoundingClientRect();ro=(o.clientX-e.left)/v,io=(o.clientY-e.top)/v},Bo=(o,e)=>f.addEventListener(o,e);f.style.height=m(9*x/16)+"px",t.style.width=(y+u)*v+"px",Bo("pointerdown",o=>{ko=wo,Ao(o),1==yo&&(jo(),no=1)}),Bo("pointermove",o=>{no&&Ao(o)}),Bo("pointerup",()=>{no=0}),Bo("pointercancel",()=>{no=0,Q=K,U=P}),Bo("click",o=>{if(1!=yo&&ko-vo>=.35)if(Ao(o),2==yo){const o=co[r((io-8)/((p-9)/3|0))];o+1&&(ho[o]++,o>2&&(N=W+=30),yo=1)}else{mo=[],ao=[],uo=[],po=Y=H=K=P=Q=U=V=oo=lo=so=fo=_=no=eo=0,N=W=100,X=1,G=5,Z=60,ho=[1,0,0,0];for(let o=0;8>o;o++)bo(0,.8*o);yo=1}}),So(),requestAnimationFrame(Io);
</script>Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |