Download builder.html from DMTuit/psy_vk2: direct link, hf CLI and curl.
- Browser
- Download file 1.79 kB
-
https://huggingface.co/spaces/DMTuit/psy_vk2/resolve/main/builder.html
- Command line
-
hf download hf://spaces/DMTuit/psy_vk2/builder.html
-
curl -L -o builder.html https://huggingface.co/spaces/DMTuit/psy_vk2/resolve/main/builder.html
1.79 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Telegram Bot Visual Editor</title> | |
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/drawflow/dist/drawflow.min.css"> | |
| <script src="https://cdn.jsdelivr.net/npm/drawflow/dist/drawflow.min.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> | |
| </head> | |
| <body> | |
| <div id="drawflow" style="width: 800px; height: 600px; border: 1px solid black;"></div> | |
| <script> | |
| const id = document.getElementById("drawflow"); | |
| const editor = new Drawflow(id); | |
| editor.start(); | |
| // Добавление узлов | |
| editor.addNode('StartCommand', 0, 1, 150, 300, 'telegram', { command: '/start', response: 'Привет! Я ваш бот.' }); | |
| editor.addNode('EchoCommand', 0, 1, 400, 300, 'telegram', { response: '{{message}}' }); | |
| // Генерация и отправка кода на сервер | |
| function generateAndSendPythonCode() { | |
| const nodes = editor.getNodes(); | |
| let code = ''; | |
| nodes.forEach(node => { | |
| if (node.data.command) { | |
| code += `def ${node.data.command.slice(1)}(update: Update, context: CallbackContext) -> None:\n`; | |
| code += ` update.message.reply_text('${node.data.response}')\n`; | |
| code += `\n`; | |
| } else if (node.data.response) { | |
| code += `def echo(update: Update, context: CallbackContext) -> None:\n`; | |
| code += ` update.message.reply_text(update.message.text)\n`; | |
| code += `\n`; | |
| } | |
| }); | |
| axios.post('/execute', { command: '/start', code: code }) | |
| .then(response => { | |
| console.log(response.data); | |
| }) | |
| .catch(error => { | |
| console.error(error); | |
| }); | |
| } | |
| </script> | |
| </body> | |
| </html> |