auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps, params, auths) => {
}
const Telegram = require('node-telegram-bot-api')
const bot = new Telegram(auths.telegram_bot_api.token)
bot.on('update', console.log)
const title = steps.trigger.event.subject
const source = steps.trigger.event.from
const text = steps.trigger.event.text
let textToSend = `
*${title}*
${source.map((addr) => `from: ${addr.name} <${addr.address}>`).concat("\n\r")}
${text}
`
textToSend = textToSend.replace(/\./g, "\\.").replace("<", "\\<").replace(">", "\\>")
try {
await bot.sendMessage(
params.telegram_bot_chat,
textToSend,
{
parse_mode: "MarkdownV2"
}
)
await Promise.all(event.attachments.map((file) =>
bot.sendDocument(
params.telegram_bot_chat,
new Buffer(file.content_b64, 'base64'),
{},
{
filename: file.fileName,
contentType: file.contentType
}
)
))
} catch (e) {
console.error(e)
}