CampFirePlay/commands/organization/orgMessage.js
Degradin baa0b5f3a9 global refactoring
Все переведено в модули
2023-10-08 23:43:12 +03:00

24 lines
943 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const {
Telegraf
} = require('telegraf')
const bot = new Telegraf(process.env.BOT_TOKEN)
const {
UserModel,
BusinessModel
} = require('/workspace/degradin/Dev/Telegram/CampFire Play/config')
module.exports = async (ctx) => {
if (!ctx.args[1]) return ctx.reply(`Не указан аргумент.`)
let business = await BusinessModel.findOne({
where: {
owner: ctx.from.id.toString()
}
})
if (business === null) return await ctx.reply(`У вас нет организации.`)
for (i = 0; i < business.users.length; i++) {
user = await UserModel.findByPk(business.users[i])
await bot.telegram.sendMessage(user.telegram_id, `Директор организации сообщает:\n ${ctx.payload}`)
}
console.log(`Директор организации сообщает:\n ${ctx.payload}`)
return await ctx.reply(`Сообщение отправлено.`)
}