Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

moleculer-telegram-bot

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moleculer-telegram-bot

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

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

PropertyTypeDefaultDescription
telegramTokenStringrequiredTelegram Bot API Token. Visit How do I create a bot?.
telegramTargetString | Number-Telegram chat id as default target

Actions

sendMessage

Send a Telegram Message

Parameters
PropertyTypeDefaultDescription
messageStringrequiredMessage text
toString | Number-Message target (required if default target not set)
parse_modeString-Optional parse mode
disable_web_page_previewBoolean-Optional disable web page preview
disable_notificationBoolean-Optional disable notification
reply_to_message_idNumber-Optional reply to message id
reply_markupAny-Optional reply markup

sendPhoto

Send a Telegram Photo using URL.

Parameters
PropertyTypeDefaultDescription
photoStringrequiredPhoto URL
toString | Number-Photo target (required if default target not set)
parse_modeString-Optional parse mode
captionString-Optional photo caption
disable_notificationBoolean-Optional disable notification
reply_to_message_idNumber-Optional reply to message id
reply_markupAny-Optional reply markup
fileOpts.filenameString-Optional filename
fileOpts.contentTypeString-Optional file content type

sendDocument

Send a Telegram Document using URL.

Parameters
PropertyTypeDefaultDescription
docStringrequiredDocument URL
toString | Number-Document target (required if default target not set)
parse_modeString-Optional parse mode
captionString-Optional document caption
disable_notificationBoolean-Optional disable notification
reply_to_message_idNumber-Optional reply to message id
reply_markupAny-Optional reply markup
fileOpts.filenameString-Optional filename
fileOpts.contentTypeString-Optional file content type

Methods

sendMessage

Send a message

Parameters
PropertyTypeDefaultDescription
toString | Number-Message target
messageString-Body of the message
optsTelegramBot.SendMessageOptions-Send message options

sendPhoto

Send a photo

Parameters
PropertyTypeDefaultDescription
toString | Number-Message target
photoString | Stream | Buffer-Photo to send
optsTelegramBot.SendPhotoOptions-Send photo options
fileOptsTelegramBot.fileOpts-Send photo file options

sendDocument

Send a document

Parameters
PropertyTypeDefaultDescription
toString | Number-Message target
docString | Stream | Buffer-Document to send
optsTelegramBot.SendDocumentOptions-Send document options
fileOptsTelegramBot.fileOpts-Send document file options

Test

npm test

In development with watching

npm run ci

License

The project is available under the MIT license.

Keywords

FAQs

Package last updated on 26 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc