multi-account-post-schedule.../helpers/get_mentions.mjs

69 lines
2.3 KiB
JavaScript

import {createMastoFetcherWithAuthorLogin} from "./libs/utils.mjs";
import moment from 'moment'
moment.locale('fr')
console.log('<html>' +
'<head>' +
'<meta charset="utf-8"/>' +
'</head><body>' +
'<style>' +
'body{ width:80vw, padding: 2rem; margin: 0 auto; font-family: Arial, sans-serif; font-size: 1.5rem;}' +
'.block_account{ padding: 1.5rem;}' +
'.message{ padding: 1rem 2rem;}</style>' +
'.avatar{ margin-right: 1em; margin-bottom: 1em; width: 4rem; height: 4rem;}'+
'')
console.log('get mentions on all accounts managed')
export async function getMentionsOfAccount(accountToFetch) {
console.log('\n fetching account: ', accountToFetch)
const masto = createMastoFetcherWithAuthorLogin(accountToFetch)
let results = {}
results = await masto.get('notifications??exclude_types[]=follow&exclude_types[]=follow_request&exclude_types[]=favourite&exclude_types[]=reblog&exclude_types[]=poll&exclude_types[]=status&exclude_types[]=update&exclude_types[]=admin.sign_up&exclude_types[]=admin.report')
// console.log('results',results)
console.log('<div class="block_account"> # mentions du compte ' + accountToFetch)
results.data.forEach(item => {
if(item.type !=='follow'){
// if(item.type =='mention'){
// console.log('item', item)
console.log('\n <div class="message">from <strong>', item.account.username, '</strong>')
// console.log('in reply to ', item.status.in_reply_to_id )
// console.log('language', item.status.language )
if (item.status) {
console.log(`
<a href="${item.status.uri}">lien</a>`)
console.log('\n : ',item.type,' :', moment(item.status.created_at).format('dddd YYYY-MM-DD HH:ii:ss'))
console.log('\n <blockquote>', item.status.content, '</blockquote>')
}
else{
console.log('<pre>',item,'</pre>')
console.log('<img class="avatar" src="',item.account.avatar_static,'">')
}
console.log('</div>')
}
// }
})
console.log('</div>\n <hr>')
}
const accounts = [
'qzine',
'tykayn',
'curator',
'kurator',
// 'modominem',
'voixdunucleaire',
// 'voicesofnuclear',
'afis91'
]
accounts.forEach(item => getMentionsOfAccount(item))
console.log('</body>')
console.log('</html>')