up qzine post

This commit is contained in:
Tykayn 2022-11-21 16:15:32 +01:00 committed by tykayn
parent 57756ed85c
commit fff69f3181
6 changed files with 12 additions and 12 deletions

View File

@ -66,7 +66,7 @@ https://mastodon.cipherbliss.com
``` ```
12 12-14 * * * cd /home/tykayn/www/mastodon_multi_account && nvm use 16 && node helpers/tkblogPost.js | tee -a /home/tykayn/log_autopost.txt 2>&1 12 12-14 * * * cd /home/tykayn/www/mastodon_multi_account && nvm use 16 && node helpers/tkblogPost.js | tee -a /home/tykayn/log_autopost.txt 2>&1
0 7 * * * cd /home/tykayn/www/mastodon_multi_account && nvm use 16 && node helpers/wiki_osm.mjs | tee -a /home/tykayn/log_autopost.txt 2>&1 0 7 * * * cd /home/tykayn/www/mastodon_multi_account && nvm use 16 && node helpers/wiki_osm.mjs | tee -a /home/tykayn/log_autopost.txt 2>&1
0 0 * * * cd /home/tykayn/www/mastodon_multi_account && nvm use 16 && node helpers/postQzine.js | tee -a /home/tykayn/log_autopost.txt 2>&1 0 0 * * * cd /home/tykayn/www/mastodon_multi_account && nvm use 16 && node helpers/postQzine.mjs | tee -a /home/tykayn/log_autopost.txt 2>&1
# version avec scripts bash # version avec scripts bash
0 7 * * * su tykayn -c "bash /home/tykayn/wiki_osm.sh" 0 7 * * * su tykayn -c "bash /home/tykayn/wiki_osm.sh"
*/30 * * * * su tykayn -c "bash /home/tykayn/meme_poster_random.sh" */30 * * * * su tykayn -c "bash /home/tykayn/meme_poster_random.sh"

View File

@ -1,6 +1,6 @@
import fs from "fs"; import fs from "fs";
import path from 'path'; import path from 'path';
import {getRandomElementOfArray, listFilesOfFolder} from './utils.js' import {getRandomElementOfArray, listFilesOfFolder} from './utils.mjs'
import Masto from "mastodon"; import Masto from "mastodon";
const __dirname = path.resolve(); const __dirname = path.resolve();

View File

@ -1,9 +1,9 @@
import fs from "fs"; import fs from "fs";
import path from 'path'; import path from 'path';
import {sendPostMastodon} from './utils.js' import sendPostMastodon from './utils.mjs'
const __dirname = path.resolve(); const __dirname = path.resolve();
const list_posts_json = JSON.parse(fs.readFileSync(__dirname + "/assets/documents/tykayn_qzinewp_posts.json", 'utf-8')) const list_posts_json = JSON.parse(fs.readFileSync(__dirname + "/assets/documents/qzine_posts_all.json", 'utf-8'))
// const reallySendPost = false; // const reallySendPost = false;
const reallySendPost = true; const reallySendPost = true;
@ -14,16 +14,16 @@ export function getRandomElementOfArray(listItems) {
function getRandomLink() { function getRandomLink() {
let filteredLinks = list_posts_json.filter(elem => elem.post_status === 'publish') let filteredLinks = list_posts_json.filter(elem => elem.status === 'publish')
return getRandomElementOfArray(filteredLinks) return getRandomElementOfArray(filteredLinks)
} }
function postLink() { function postLink() {
let postObject = getRandomLink() let postObject = getRandomLink()
console.log("envoi de post par le compte Qzine") console.log("envoi de post par le compte Qzine - post n°" ,postObject.id)
let filteredExcerpt = postObject.post_content.replace(/<[^>]+>/g, '') let filteredExcerpt = postObject.excerpt.rendered.replace(/<[^>]+>/g, '')
let counterLength = filteredExcerpt.length; let counterLength = filteredExcerpt.length;
let limitExcerpt = 250 let limitExcerpt = 250
@ -35,9 +35,9 @@ function postLink() {
let configPost = { let configPost = {
author: 'qzine', author: 'qzine',
image: 'qzine_default.jpg', image: 'qzine_default.jpg',
message: `# [ !Qzine - ${postObject.post_title}](${postObject.guid}) message: `# [ !Qzine - ${postObject.title.rendered}](${postObject.link})
* ${postObject.post_date} - ${postObject.guid} * ${postObject.date} - ${postObject.link}
${filteredExcerpt} ${filteredExcerpt}
* #qzine #qzineblog #blog #sexe #relations #éducation #plaisir #sociologie`, * #qzine #qzineblog #blog #sexe #relations #éducation #plaisir #sociologie`,
reallySendPost reallySendPost

View File

@ -1,7 +1,7 @@
import fs from "fs"; import fs from "fs";
import path from 'path'; import path from 'path';
import {sendPostMastodon} from './utils.js' import {sendPostMastodon} from './utils.mjs'
const __dirname = path.resolve(); const __dirname = path.resolve();
const tkpostsjson = JSON.parse(fs.readFileSync(__dirname + "/assets/documents/tykayn_wptkblog_posts.json", 'utf-8')) const tkpostsjson = JSON.parse(fs.readFileSync(__dirname + "/assets/documents/tykayn_wptkblog_posts.json", 'utf-8'))

View File

@ -34,7 +34,7 @@ export function tokenForAuthorIsPresentInDotEnv(author) {
return process.env['TOKEN_' + author.toUpperCase()]; return process.env['TOKEN_' + author.toUpperCase()];
} }
export function sendPostMastodon(config) { export default function sendPostMastodon(config){
// override defaults with input argument // override defaults with input argument
config = { config = {

View File

@ -7,7 +7,7 @@ import rp from "request-promise";
import $ from "cheerio"; import $ from "cheerio";
import fs from "fs"; import fs from "fs";
import path from 'path'; import path from 'path';
import {randomIntFromInterval, sendPostMastodon} from "./utils.js"; import {randomIntFromInterval, sendPostMastodon} from "./utils.mjs";
const __dirname = path.resolve(); const __dirname = path.resolve();