16 lines
513 B
JavaScript
16 lines
513 B
JavaScript
|
|
const { sendMessage, sendPhoto } = require('../api');
|
||
|
|
const { formatUser, safeExec } = require('../helpers');
|
||
|
|
|
||
|
|
const notifyUser = safeExec(async (user, text) => {
|
||
|
|
if (!user?.telegram_id) return;
|
||
|
|
const msg = `👋 Ciao ${formatUser(user)}\n${text}`;
|
||
|
|
await sendMessage(user.telegram_id, msg);
|
||
|
|
});
|
||
|
|
|
||
|
|
const sendUserPhoto = safeExec(async (user, photoUrl, caption) => {
|
||
|
|
if (!user?.telegram_id) return;
|
||
|
|
await sendPhoto(user.telegram_id, photoUrl, caption);
|
||
|
|
});
|
||
|
|
|
||
|
|
module.exports = { notifyUser, sendUserPhoto };
|