posting qzine works
This commit is contained in:
parent
92845a6ad7
commit
1c597a2959
BIN
assets/qzine_default.jpg
Executable file
BIN
assets/qzine_default.jpg
Executable file
Binary file not shown.
After Width: | Height: | Size: 338 KiB |
@ -1,11 +1,49 @@
|
|||||||
var sqlite3 = require('sqlite3');
|
import fs from "fs";
|
||||||
var Masto = require('mastodon');
|
import path from 'path';
|
||||||
|
import {sendPostMastodon} from './utils.js'
|
||||||
|
|
||||||
// masto.post('statuses', {
|
const __dirname = path.resolve();
|
||||||
// status: status,
|
const list_posts_json = JSON.parse(fs.readFileSync(__dirname + "/assets/documents/tykayn_qzinewp_posts.json", 'utf-8'))
|
||||||
// media_ids: [id],
|
// const reallySendPost = false;
|
||||||
// account_id,
|
const reallySendPost = true;
|
||||||
// visibility,
|
|
||||||
// language,
|
|
||||||
// sensitive
|
export function getRandomElementOfArray(listItems) {
|
||||||
// }
|
return listItems[Math.floor(Math.random() * listItems.length)]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getRandomLink() {
|
||||||
|
let filteredLinks = list_posts_json.filter(elem => elem.post_status === 'publish')
|
||||||
|
return getRandomElementOfArray(filteredLinks)
|
||||||
|
}
|
||||||
|
|
||||||
|
function postLink() {
|
||||||
|
|
||||||
|
let postObject = getRandomLink()
|
||||||
|
console.log("envoi de post par le compte Qzine")
|
||||||
|
|
||||||
|
let filteredExcerpt = postObject.post_content.replace(/<[^>]+>/g, '')
|
||||||
|
let counterLength = filteredExcerpt.length;
|
||||||
|
|
||||||
|
let limitExcerpt = 250
|
||||||
|
filteredExcerpt = filteredExcerpt.substring(0, limitExcerpt)
|
||||||
|
if (filteredExcerpt && counterLength > limitExcerpt) {
|
||||||
|
filteredExcerpt = '> ' + filteredExcerpt + '… '
|
||||||
|
}
|
||||||
|
|
||||||
|
let configPost = {
|
||||||
|
author: 'qzine',
|
||||||
|
image: 'qzine_default.jpg',
|
||||||
|
message: `# [ !Qzine - ${postObject.post_title}](${postObject.guid})
|
||||||
|
|
||||||
|
* ${postObject.post_date} - ${postObject.guid}
|
||||||
|
${filteredExcerpt}
|
||||||
|
* #qzine #qzineblog #blog #sexe #relations #éducation #plaisir #sociologie`,
|
||||||
|
reallySendPost
|
||||||
|
}
|
||||||
|
console.log("configPost.message", configPost.message)
|
||||||
|
sendPostMastodon(configPost)
|
||||||
|
}
|
||||||
|
|
||||||
|
postLink();
|
Loading…
Reference in New Issue
Block a user