From b6e7862695e37f1c83eeb43ad3e08da3782e84dd Mon Sep 17 00:00:00 2001 From: Guillaume Vagner <guillaume.vagner@supelec.fr> Date: Sun, 3 Mar 2019 21:14:13 +0100 Subject: [PATCH] customized namebot on website --- index.html | 18 +++++++++++++++++- website.js | 7 +++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 087cba5..7e2717e 100644 --- a/index.html +++ b/index.html @@ -30,11 +30,27 @@ <div class="w3-display-middle"> <h1 class="w3-jumbo w3-animate-top">HAPPY BOTDAY!</h1> <hr class="w3-border-grey" style="margin:auto;width:40%"> - <p class="w3-large w3-center">Va sur <a href="https://t.me/happyCSbot">t.me/happyCSbot</a> pour la configuration. + <p class="w3-large w3-center">Va sur <a id="link" href="" target="_blank">t.me/</a> pour la configuration. </p> </div> </div> </body> +<script> + + const Http = new XMLHttpRequest(); + const url = '/namebot'; + Http.open("GET", url); + Http.send(); + Http.onreadystatechange = (e) => { + console.log(Http.responseText) + var a = document.getElementById("link"); + console.log(a.href) + a.setAttribute('href', `https://t.me/${Http.responseText}`) + a.innerText = `t.me/${Http.responseText}` + } +</script> + + </html> \ No newline at end of file diff --git a/website.js b/website.js index bfeb5d6..375ccd4 100644 --- a/website.js +++ b/website.js @@ -12,10 +12,14 @@ var { getFirstToken } = require('./requests'); const config = require('./config'); + +// Lancement du site app.listen(config.website.port, '127.0.0.1', () => { console.log(`[express] Website is up and accessible on ${config.website.protocol}://${config.website.hostname}/`); }) + +// Page de base, si argument app.get('/', function (req, res) { // GET / : renvoie la page de base @@ -49,5 +53,8 @@ return getFirstToken(req.query.code, req.query.state).then(chan => { }) }) +app.get('/namebot', function (req, res) { + return res.send(config.telegram.name); +}) module.exports = app; \ No newline at end of file -- GitLab