From 9e4c707112b342fb10d21cb31e0811210cc3de1d Mon Sep 17 00:00:00 2001 From: Tykayn Date: Mon, 8 Aug 2022 23:05:23 +0200 Subject: [PATCH] working meme post and move file --- .../{not_published => published}/cat_spray.jpg | Bin .../e3fbbdda01292e42.jpg | Bin .../f433bb1e9e3bcf1c.png | Bin helpers/meme_poster_random.js | 16 ++++++++++++---- 4 files changed, 12 insertions(+), 4 deletions(-) rename assets/pictures/meme/{not_published => published}/cat_spray.jpg (100%) rename assets/pictures/meme/{not_published => published}/e3fbbdda01292e42.jpg (100%) rename assets/pictures/meme/{not_published => published}/f433bb1e9e3bcf1c.png (100%) diff --git a/assets/pictures/meme/not_published/cat_spray.jpg b/assets/pictures/meme/published/cat_spray.jpg similarity index 100% rename from assets/pictures/meme/not_published/cat_spray.jpg rename to assets/pictures/meme/published/cat_spray.jpg diff --git a/assets/pictures/meme/not_published/e3fbbdda01292e42.jpg b/assets/pictures/meme/published/e3fbbdda01292e42.jpg similarity index 100% rename from assets/pictures/meme/not_published/e3fbbdda01292e42.jpg rename to assets/pictures/meme/published/e3fbbdda01292e42.jpg diff --git a/assets/pictures/meme/not_published/f433bb1e9e3bcf1c.png b/assets/pictures/meme/published/f433bb1e9e3bcf1c.png similarity index 100% rename from assets/pictures/meme/not_published/f433bb1e9e3bcf1c.png rename to assets/pictures/meme/published/f433bb1e9e3bcf1c.png diff --git a/helpers/meme_poster_random.js b/helpers/meme_poster_random.js index b2b8c9d..d088a0f 100644 --- a/helpers/meme_poster_random.js +++ b/helpers/meme_poster_random.js @@ -4,12 +4,12 @@ import {getRandomElementOfArray, listFilesOfFolder} from './utils.js' import Masto from "mastodon"; const __dirname = path.resolve(); -const folderMemeUnpublished = 'assets/pictures/meme/not_published' +const folderMemeUnpublished = 'assets/pictures/meme/not_published/' +const folderMemePublished = 'assets/pictures/meme/published/' const list_unpublished_images = listFilesOfFolder(folderMemeUnpublished) -const reallySendPost = false; - -// const reallySendPost = true; +// const reallySendPost = false; +const reallySendPost = true; function postLink() { @@ -57,6 +57,7 @@ function postLink() { // console.log('rep', rep) console.log(`posté avec une nouvelle image, ${configPost.image} WOOT`) console.log("post has been sent, time to move image from unpublished folder: ", selectedImage) + moveImageToPublishedFolder(selectedImage) }, err => { console.error(err) console.log("erreur T_T") @@ -67,4 +68,11 @@ function postLink() { } } +/** + * move to published + * @param imageName + */ +function moveImageToPublishedFolder(imageName){ + return fs.renameSync(folderMemeUnpublished + imageName, folderMemePublished + imageName) +} postLink(); \ No newline at end of file