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/textmode-panel.html
View on GitHub<style>body{margin:0}canvas{display:block;width:100%;touch-action:pan-y}</style><canvas id="c"></canvas><script>const t=window.TelegramWidget,e=document,f=Math,{sin:n,cos:o,hypot:c,floor:i,min:s,max:l}=f,r=e.getElementById("c"),a=r.getContext("2d"),p=r.clientWidth||360,d=Math.round(9*p/16),g=s(devicePixelRatio||1,2);r.style.height=d+"px",r.width=p*g,r.height=d*g,a.scale(g,g);const h=p<340?38:44,m=p/h;a.font="14px ui-monospace,monospace";const u=14*m/a.measureText("M").width,b=i(d/(1.2*u)),y=d/b,x=h*b,v=m/y,S=u+"px ui-monospace,monospace";a.font=S,a.textBaseline="middle";const I={rgb:["#00f","#00f","#000","#000","#f22","#f22","#f0f","#0ff","#7f3","#7f3","#0ff","#f0f","#fff","#fff"],mono:["#000","#000","#000","#333","#333","#777","#777","#bbb","#bbb","#fff","#fff","#fff","#fff","#fff"],heat:["#000","#000","#300","#700","#c00","#f22","#f60","#f90","#fc0","#fe5","#ff9","#fff","#fff","#fff"]},T=Object.keys(I),w=["плазма","кольца","муар"],E=["яркий","серый","жар"],O=t=>(t=t.slice(1),3*parseInt(t[0],16)+6*parseInt(t[1],16)+parseInt(t[2],16)>80?"#000":"#fff");let k={f:0,s:3,v:2,p:0};try{k=Object.assign(k,JSON.parse(localStorage.getItem("s")||"{}"))}catch(t){}const F=Array(x),j=new Int16Array(x);let A=[.6*h,.55*b],B=[...A],C=0,H=15,L=0,M=-1;const R=[.5,1,1.5,2,3],q=[["ПОЛЕ",()=>w[k.f],t=>k.f=(k.f+t+3)%3],["МАСШТАБ",()=>k.s,t=>k.s=l(1,s(9,k.s+t))],["СКОРОСТЬ",()=>R[k.v],t=>k.v=l(0,s(4,k.v+t))],["ЦВЕТ",()=>E[k.p],t=>k.p=(k.p+t+3)%3]],J=(t,e,f,n)=>{for(let o=0;o<f.length;o++){const c=e*h+t+o;c>=0&&c<x&&(F[c]=f[o],j[c]=n)}},N=14,W=t=>{const e=r.getBoundingClientRect();return[(t.clientX-e.left)/m,(t.clientY-e.top)/y]},P=(t,e)=>t>=1&&t<24&&e>=1&&e<=1+2*q.length+3;r.addEventListener("pointerdown",e=>{const[f,n]=W(e);P(f,n)||(A=[f,n],t&&t.HapticFeedback.selectionChanged())}),r.addEventListener("pointermove",t=>{if(!t.buttons&&"touch"!=t.pointerType)return;const[e,f]=W(t);P(e,f)||(A=[e,f])}),r.addEventListener("click",e=>{const[f,n]=W(e);if(!P(f,n))return;const o=i((n-1-.5)/2);if(n>=9.5){M=9;let e="";for(let t=0;t<b;t++)e+=F.slice(t*h,t*h+h).join("")+"\n";t&&t.copyText(e),t&&t.HapticFeedback.notificationOccurred("success")}else o>=0&&o<q.length&&(q[o][2](f<17?-1:1),M=o,(()=>{try{localStorage.setItem("s",JSON.stringify(k))}catch(t){}})(),t&&t.HapticFeedback.impactOccurred("light"));setTimeout(()=>M=-1,160)}),requestAnimationFrame(function t(e){if(requestAnimationFrame(t),e-L<60)return;const f=s((e-L)/1e3,.2);H+=.1*(1/f-H),L=e,C+=f*R[k.v],B[0]+=(A[0]-B[0])*s(1,6*f),B[1]+=(A[1]-B[1])*s(1,6*f),function(t){const e=.7*k.s,f=s(h*v,b),l=2*(B[0]-h/2)/f*v,r=2*(B[1]-b/2)/f,a=.9*t,p=.3*t;let d=0;for(let g=0;g<b;g++){const m=2*(g-b/2)/f;for(let g=0;g<h;g++,d++){const u=2*(g-h/2)/f*v;let b;b=0==k.f?.25*(n((u*n(a)+m*o(a))*e+p)+o(c(u-l,m-r)*e*1.6-2*p))+.5:1==k.f?.5*n(c(u-l,m-r)*e*2.6-2.2*t)+.5:.25*(n(c(u-l,m-r)*e*4.2+t)+n(c(u+l,m+r)*e*4.2-t))+.5;const y=s(13,i(14*b));F[d]="$?01#abc+-><:."[y],j[d]=y}}}(C),function(){const t=2*q.length+2,e="─".repeat(21);J(1,1,"┌"+e+"┐",N);for(let e=1;e<t;e++)J(1,1+e,"│"+" ".repeat(21)+"│",N);J(1,1+t,"└"+e+"┘",N),q.forEach((t,e)=>{const f=2+2*e,n=String(t[1]()),o=M==e,c="‹ "+n.padStart((6+n.length)/2|0).padEnd(6)+" ›";J(3,f,t[0],N),J(12,f,c,o?15:N)});const f=1+2*q.length+1;J(3,f,"[ КОПИЯ ]",9==M?15:N),J(14,f,(0|H)+" к/с",N)}(),function(){const t=I[T[k.p]];let e=0;for(let f=0;f<b;f++){let n=0;for(let o=1;o<=h;o++)if(o==h||j[e+o]!=j[e+n]){const c=j[e+n],i=c==N?"#fff":15==c?"#000":t[c],s=c==N?"#000":15==c?"#fff":O(i);a.fillStyle=i,a.fillRect(n*m,f*y,(o-n)*m+.5,y+.5);const l=F.slice(e+n,e+o).join("");if(l.trim())if(a.fillStyle=s,c>=N)for(let t=0;t<l.length;t++)" "!=l[t]&&a.fillText(l[t],(n+t)*m,f*y+y/2);else a.fillText(l,n*m,f*y+y/2);n=o}e+=h}}()}),t&&t.ready();
</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 |