1.0.6 • Published 1 year ago

grammy-mail v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Mailing users

This library was created for mailing users in the grammY framework

How to use

  1. Install library
yarn add grammy-mail
// or
npm i grammy-mail
  1. 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`),
  });
});
1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago