wrzucamy śmietnik :DDDD
This commit is contained in:
parent
6d3524eed5
commit
cded4e036a
10 changed files with 2296 additions and 0 deletions
39
commands/slavista.js
Normal file
39
commands/slavista.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
const sanitizeHtml = require('sanitize-html')
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
"name": 'slavista',
|
||||
"usage": '',
|
||||
"description": 'Sends latest fediverse post made by slavistapl.'
|
||||
},
|
||||
async execute(event, bot) {
|
||||
const response = await fetch('https://500plus.slavistapl.eu.org/api/v1/accounts/AajrBXKHPBH47ggKFU/statuses?exclude_replies=false&with_muted=true');
|
||||
if (!response.ok) {
|
||||
event.reply("Couldn't fetch posts...")
|
||||
} else {
|
||||
const json = await response.json()
|
||||
let i = 0
|
||||
let done = false
|
||||
|
||||
do {
|
||||
if (i > json.length) {
|
||||
event.reply("Couldn't fetch posts...")
|
||||
done = true
|
||||
} else {
|
||||
if (json[i].content == "" && json[i].media_attachments.length == 0) {
|
||||
i++
|
||||
} else {
|
||||
let str = sanitizeHtml(`${json[i].content.toString()} | ${json[i].uri}`, {
|
||||
allowedTags: ['a'],
|
||||
allowedAttributes: {
|
||||
'a': ['href']
|
||||
}
|
||||
})
|
||||
event.reply(str)
|
||||
done = true
|
||||
}
|
||||
}
|
||||
} while (!done)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue