File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ <!--
2+ Simple static Telegram WebApp. Does not verify the WebAppInitData, as a bot token would be needed for that.
3+ -->
4+ <!DOCTYPE html>
5+ < html lang ="en ">
6+ < head >
7+ < meta charset ="UTF-8 ">
8+ < title > python-telegram-bot Example WebApp</ title >
9+ < script src ="https://telegram.org/js/telegram-web-app.js "> </ script >
10+ < script src ="https://cdn.jsdelivr.net/npm/@jaames/iro@5 "> </ script >
11+ </ head >
12+ < script type ="text/javascript ">
13+ const colorPicker = new iro . ColorPicker ( '#picker' , {
14+ borderColor : "#ffffff" ,
15+ borderWidth : 1 ,
16+ width : Math . round ( document . documentElement . clientWidth / 2 ) ,
17+ } ) ;
18+ colorPicker . on ( 'color:change' , function ( color ) {
19+ document . body . style . background = color . hexString ;
20+ } ) ;
21+
22+ Telegram . WebApp . ready ( ) ;
23+ Telegram . WebApp . MainButton . setText ( 'Choose Color' ) . show ( ) . onClick ( function ( ) {
24+ const data = JSON . stringify ( { hex : colorPicker . color . hexString , rgb : colorPicker . color . rgb } ) ;
25+ Telegram . WebApp . sendData ( data ) ;
26+ Telegram . WebApp . close ( ) ;
27+ } ) ;
28+ </ script >
29+ < body style ="background-color: #ffffff ">
30+ < div style ="position: absolute; margin-top: 5vh; margin-left: 5vw; height: 90vh; width: 90vw; border-radius: 5vh; background-color: var(--tg-theme-bg-color); box-shadow: 0 0 2vw
31+ #000000; ">
32+ < div id ="picker "
33+ style ="display: flex; justify-content: center; align-items: center; height: 100%; width: 100% "> </ div >
34+ </ div >
35+ </ body >
36+ < script type ="text/javascript ">
37+ Telegram . WebApp . expand ( ) ;
38+ </ script >
39+ </ html >
You can’t perform that action at this time.
0 commit comments