From 0beaf1146d93c2f867232576976538e0c3fffd41 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Fri, 5 Aug 2022 15:19:45 +0200 Subject: [PATCH] make an osm message --- helpers/wiki_osm.mjs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/helpers/wiki_osm.mjs b/helpers/wiki_osm.mjs index f8aa645..75afee2 100644 --- a/helpers/wiki_osm.mjs +++ b/helpers/wiki_osm.mjs @@ -48,7 +48,7 @@ export default function getElementCartographique() { const titleSelector = "" - fs.readFile(__dirname + '/assets/documents/elements_carto_osm.html', 'utf8', function (err, html) { + return fs.readFile(__dirname + '/assets/documents/elements_carto_osm.html', 'utf8', function (err, html) { if (err) { return console.log(err); } @@ -121,12 +121,23 @@ export default function getElementCartographique() { // aller chercher le lien // image de description: let imgSelector = ".description a.image img" + const message = makePostMessageFromObj(result) + console.log("message", message) + return result; }); } +function makePostMessageFromObj(result) { + return ` +# [Le tag OSM du jour : ${result.key}=${result.value}](${result.link}) +> ${result.description.trim()} +#osm #openstreetmap #wiki #rtfw +` +} + function getQuery() { // var url = "https://wiki.openstreetmap.org/w/api.php"; var url = "https://fr.wikipedia.org/w/api.php"; @@ -165,4 +176,10 @@ function getQuery() { }); -} \ No newline at end of file +} + + +// run + +const res = getElementCartographique() +console.log("res", res) \ No newline at end of file