Mailing users
This library was created for mailing users in the grammY framework
How to use
- Install library
yarn add grammy-mail
// or
npm i grammy-mail
- Use library
import { mailUsers } from 'grammy-mail';
bot.command('mail', async (ctx: Context) => {
const users = [1, 2, 3];
mailUsers<Context>(ctx, users, {
text: 'Hello, world!',
other: { parse_mode: 'HTML' },
messageSender: (userId: number) =>
ctx.api.sendMessage(userId, 'Hello, world!', { parse_mode: 'HTML' }),
onSend: (userId: number, isSuccess: boolean) =>
console.log(userId, isSuccess ? 'recieved' : 'not recieved', 'mail'),
onEnd: (success: number, failed: number) =>
ctx.reply(`Mail end. ${success} - success mails, ${failed} - failed mails`),
});
});