Add Revolt publishing
This commit is contained in:
@@ -34,3 +34,9 @@ TELEGRAM_API_TOKEN=
|
|||||||
|
|
||||||
DEEPL_URL=
|
DEEPL_URL=
|
||||||
DEEPL_KEY=
|
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_CHAN_ID = process.env.TELEGRAM_CHAN_ID || null
|
||||||
const TELEGRAM_API_TOKEN = process.env.TELEGRAM_API_TOKEN || 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 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) => {
|
const getSlug = (artiste, parole) => {
|
||||||
return slugify(`${artiste}-${parole}`, {lower: true, remove: /[*#+~.()'"!:@]/g})
|
return slugify(`${artiste}-${parole}`, {lower: true, remove: /[*#+~.()'"!:@]/g})
|
||||||
@@ -214,6 +217,24 @@ module.exports = {
|
|||||||
if (TELEGRAM_API_TOKEN) {
|
if (TELEGRAM_API_TOKEN) {
|
||||||
await axios.post(`${MESSAGE_URL}&text=${message}`)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user