npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

nestjs-telegram-unlimit-message

v1.3.1

Published

Send message to Telegram unlimited with load balancing strategies

Downloads

17

Readme


Description

  • Telegram limit by: number of bots in groups upto 20, message sending frequency in group chats up to 20 messages per minute in the same chat. So with 1 minute each account can send up to 400 messages. In short, the limit per bot cannot be changed, but with more bots you can send more messages.
  • Based on Nginx load balancing strategies, select the appropriate bot to send messages (or perform the tasks you want with the bot). Strategies run completely separately for each group and bot
  • Use only effective, consistent and simple strategies to rotate bots.
  • Use Cache with redis if you have more than 1 service...

Installation

$ npm install nestjs-telegram-unlimit-message

Quick use

  • Using in module:
// For root
@Module({
  imports: [
    TelegramModule.forRoot({
      strategy: new RandomStrategy(InputRandomStrategyEnum.BOTH),
      bots: [
        new Bot('bot1', 0),
        new Bot('bot2', 20),
        new Bot('bot3', 100),
        new Bot('bot4', 0),
      ],
    })
  ]
})

// For root async
@Module({
  imports: [
    TelegramModule.forRootAsync({
      useFactory: async (configService: ConfigService, cacheService: CacheService) => ({
        strategy: new WeightedRoundRobinStrategy(),
        bots: [
          new Bot(configService.get('bot1'), 2),
          new Bot(configService.get('bot2')),
          new Bot(configService.get('bot3'), 1),
          new Bot(configService.get('bot4'), 2),
        ],
        cacheService, // [Recommend] CacheService class should have set, get, del methods
      }),
      inject: [ConfigService, CacheService],
    }),
  ],
})
  • Using in service:
@Injectable()
export class TestService {

  constructor(private readonly telegram: TelegramService) {
  }

  getMeBot(): Observable<TelegramUser> {
    return this.telegram.getMe();
  }

  async sendMessage() {
    await lastValueFrom(this.telegramService.sendMessage({
      chat_id: <string | number>('462374324348932034343...'),
      text: <string>job.data.message,
      parse_mode: 'markdown',
    }))
  }
}

Strategies


Random

  • inputRandom : How are proxies random?
- both : All proxy nodes are random
- has_weight : Only the weighted proxy node will be random
- no_weight : Only proxy nodes without weights can be random

Config:

TelegramModule.forRoot({
  strategy: new RandomStrategy(InputRandomStrategyEnum.BOTH),
  bots: [
    new Bot('bot1', 0),
    new Bot('bot2', 20),
    new Bot('bot3', 100),
    new Bot('bot4', 0),
  ],
})

Output(both):

+-------------+-------------+
| bot         | weight      |
+-------------+-------------+
| bot1        | 0           |
| bot2        | 20          |
| bot3        | 100         |
| bot3        | 100         |
+-------------+-------------+

Frequency

More efficient using sort node

TelegramModule.forRoot({
  strategy: new FrequencyStrategy(1, 0.4),
  bots: [
    new Bot('bot1', 2048),
    new Bot('bot2', 1024),
    new Bot('bot3', 512),
    new Bot('bot4', 256),
    new Bot('bot5', 64),
    new Bot('bot6', 32),
  ],
})

The probability of choosing nodes for Frequency can be visualized as follows::

+--------------+--------+
| bots         | chance |
+--------------+--------+
| bot1         | 40%    |
| bot2         | 40%    |
+--------------+--------+
| bot3         | 2.5%   |
| bot4         | 2.5%   |
| bot5         | 2.5%   |
| bot6         | 2.5%   |
+-----------+-----------+

Round Robin

The proxies will be rotated in turn (counter : start counting from somewhere)

TelegramModule.forRoot({
  strategy: new RoundRobinStrategy(),
  bots: [
    new Bot('bot1', 0),
    new Bot('bot2', 20),
    new Bot('bot3', 100),
    new Bot('bot4', 0),
  ],
})

Output:

+-------------+
| bot1        |
| bot2        |
| bot3        |
| bot4        |
| etc...      |
+-------------+
  • You can interfere with proxy usage for a certain period of time if the proxy is restricted from use.

Weighted Round Robin

The number of times this proxy node is called is the weight parameter passed in the initialization of the ProxyNode (counter : start counting from somewhere)

TelegramModule.forRoot({
  strategy: new WeightedRoundRobinStrategy(),
  bots: [
    new Bot('bot1', 1),
    new Bot('bot2', 1),
    new Bot('bot3', 2),
    new Bot('bot4', 0),
  ],
})

Output:

+-------------+
| bot1        |
| bot2        |
| bot3        |
| bot3        |
| etc...      |
+-------------+
  • Proxy Node without weight will not be used

Author


License

Package is MIT licensed.