Files
freeplanet_serverside/src/telegram/handlers/userHandler.js

16 lines
513 B
JavaScript
Raw Normal View History

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 };