Add Revolt publishing

This commit is contained in:
2024-07-31 18:14:48 +02:00
parent 5185f825e5
commit 93966ef430
2 changed files with 27 additions and 0 deletions
+6
View File
@@ -34,3 +34,9 @@ TELEGRAM_API_TOKEN=
DEEPL_URL=
DEEPL_KEY=
# Revolt
REVOLT_BOT_ID=
REVOLT_TARGET=
REVOLT_TOKEN=
@@ -10,6 +10,9 @@ const TELEGRAM_API_URL = 'https://api.telegram.org'
const TELEGRAM_CHAN_ID = process.env.TELEGRAM_CHAN_ID || null
const TELEGRAM_API_TOKEN = process.env.TELEGRAM_API_TOKEN || null
const MESSAGE_URL = `${TELEGRAM_API_URL}/bot${TELEGRAM_API_TOKEN}/sendMessage?chat_id=${TELEGRAM_CHAN_ID}&parse_mode=html`
const REVOLT_BOT_ID = process.env.REVOLT_BOT_ID || null
const REVOLT_TARGET = process.env.REVOLT_TARGET || null
const REVOLT_TOKEN = process.env.REVOLT_TOKEN || null
const getSlug = (artiste, parole) => {
return slugify(`${artiste}-${parole}`, {lower: true, remove: /[*#+~.()'"!:@]/g})
@@ -214,6 +217,24 @@ module.exports = {
if (TELEGRAM_API_TOKEN) {
await axios.post(`${MESSAGE_URL}&text=${message}`)
}
if (REVOLT_TOKEN && REVOLT_TARGET && REVOLT_BOT_ID) {
const revoltMessage = `Nouvelle publication !
\n${process.env.WEBSITE_URL}/paroles/${previousData.slug}`
const targetChannel = REVOLT_TARGET
const botToken = REVOLT_TOKEN
const url = `https://api.revolt.chat/channels/${targetChannel}/messages`
const config = {
headers: {
'X-Bot-Token': botToken,
'Content-Type': 'application/json'
}
}
await axios.post(url, {content: revoltMessage}, config)
}
}
}
},