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 🙏

© 2024 – Pkg Stats / Ryan Hefner

moleculer-telegram-bot

v1.1.1

Published

Moleculer Framework Addons: Send Messages, Photos, and Documents to Telegram using Telegram Bot API

Downloads

8

Readme

moleculer-telegram-bot

Send Messages, Photos, and Documents to Telegram using Telegram Bot API with node-telegram-bot-api module.

unittest Coverage Status Codacy Badge Codacy Badge

Install

npm install moleculer-telegram-bot --save

Usage

Before use the example below, please set the TELEGRAM_TOKEN environment variables and optional TELEGRAM_TARGET for default target.

const { ServiceBroker } = require('moleculer');
const TelegramService = require('moleculer-telegram-bot');

// Create broker
const broker = new ServiceBroker({ logger: console });

// Load my service
broker.createService({
    name: 'telegram',
    mixins: [TelegramService()]
});

// Start server
broker.start().then(() => {
  broker
    .call('telegram.sendMessage', { message: 'Hello Telegram!' })
    .then(res => console.log('Telegram message sent.'))
    .catch(console.error);
});

Settings

| Property | Type | Default | Description | | -------- | ---- | ------- | ----------- | | telegramToken | String | required | Telegram Bot API Token. Visit How do I create a bot?. | | telegramTarget | String | Number | - | Telegram chat id as default target |

Actions

sendMessage

Send a Telegram Message

Parameters

| Property | Type | Default | Description | | -------- | ---- | ------- | ----------- | | message | String | required | Message text | | to | String | Number | - | Message target (required if default target not set) | | parse_mode | String | - | Optional parse mode | | disable_web_page_preview | Boolean | - | Optional disable web page preview | | disable_notification | Boolean | - | Optional disable notification | | reply_to_message_id | Number | - | Optional reply to message id | | reply_markup | Any | - | Optional reply markup |

sendPhoto

Send a Telegram Photo using URL.

Parameters

| Property | Type | Default | Description | | -------- | ---- | ------- | ----------- | | photo | String | required | Photo URL | | to | String | Number | - | Photo target (required if default target not set) | | parse_mode | String | - | Optional parse mode | | caption | String | - | Optional photo caption | | disable_notification | Boolean | - | Optional disable notification | | reply_to_message_id | Number | - | Optional reply to message id | | reply_markup | Any | - | Optional reply markup | | fileOpts.filename | String | - | Optional filename | | fileOpts.contentType | String | - | Optional file content type |

sendDocument

Send a Telegram Document using URL.

Parameters

| Property | Type | Default | Description | | -------- | ---- | ------- | ----------- | | doc | String | required | Document URL | | to | String | Number | - | Document target (required if default target not set) | | parse_mode | String | - | Optional parse mode | | caption | String | - | Optional document caption | | disable_notification | Boolean | - | Optional disable notification | | reply_to_message_id | Number | - | Optional reply to message id | | reply_markup | Any | - | Optional reply markup | | fileOpts.filename | String | - | Optional filename | | fileOpts.contentType | String | - | Optional file content type |

Methods

sendMessage

Send a message

Parameters

| Property | Type | Default | Description | | -------- | ---- | ------- | ----------- | | to | String | Number | - | Message target | | message | String | - | Body of the message | | opts | TelegramBot.SendMessageOptions | - | Send message options |

sendPhoto

Send a photo

Parameters

| Property | Type | Default | Description | | -------- | ---- | ------- | ----------- | | to | String | Number | - | Message target | | photo | String | Stream | Buffer | - | Photo to send | | opts | TelegramBot.SendPhotoOptions | - | Send photo options | | fileOpts | TelegramBot.fileOpts | - | Send photo file options |

sendDocument

Send a document

Parameters

| Property | Type | Default | Description | | -------- | ---- | ------- | ----------- | | to | String | Number | - | Message target | | doc | String | Stream | Buffer | - | Document to send | | opts | TelegramBot.SendDocumentOptions | - | Send document options | | fileOpts | TelegramBot.fileOpts | - | Send document file options |

Test

npm test

In development with watching

npm run ci

License

The project is available under the MIT license.