grammy-mail
v1.0.6
Published
Send your mails to users in the grammY framework
Downloads
42
Readme
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]; // user ids you want to mail
mailUsers<Context>(ctx, users, { // start mail
text: 'Hello, world!', // mail text
other: { parse_mode: 'HTML' }, // add other params to message (grammY api .reply)
messageSender: (userId: number) => // or use custom mail function
ctx.api.sendMessage(userId, 'Hello, world!', { parse_mode: 'HTML' }),
onSend: (userId: number, isSuccess: boolean) => // callback on every mail
console.log(userId, isSuccess ? 'recieved' : 'not recieved', 'mail'),
onEnd: (success: number, failed: number) => // callback on mail end
ctx.reply(`Mail end. ${success} - success mails, ${failed} - failed mails`),
});
});