Socket
Book a DemoInstallSign in
Socket

telerolo

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

telerolo

Send formatted messages to Telegram channels and chats via bot API. Lightweight TypeScript library with Markdown/HTML support and parameter validation

0.1.12
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Telerolo

npm version

A simple and lightweight Node.js library for sending messages to Telegram channels and chats using a bot.

๐Ÿ“‘ Table of Contents

โœจ Features

  • Simple class-based API
  • Written in TypeScript with full type support
  • Uses native fetch from Node.js
  • No unnecessary dependencies
  • Parameter validation
  • Support for various parsing modes (Markdown, HTML)

๐Ÿ“‹ Requirements

  • Node.js >= 18.0.0
  • Telegram Bot Token

๐Ÿ“ฆ Installation

npm install telerolo
# or
yarn add telerolo

๐Ÿš€ Quick Start

import { Telerolo } from 'telerolo';
import 'dotenv/config'; // To load environment variables

// Create a Telerolo instance with your bot token
const telerolo = new Telerolo({
  botToken: process.env.TELEGRAM_BOT_TOKEN,
});

// Send a message
async function sendMessage() {
  try {
    await telerolo.sendMessage({
      chatId: '-1001234567890', // Chat or channel ID
      message: 'Hello, world! ๐Ÿš€',
    });
    console.log('Message sent!');
  } catch (error) {
    console.error('Error sending message:', error);
  }
}

๐Ÿ“– Detailed Usage

Initialization

import { Telerolo } from 'telerolo';

const telerolo = new Telerolo({
  botToken: 'YOUR_BOT_TOKEN_HERE',
});

Send Simple Message

await telerolo.sendMessage({
  chatId: '@my_channel',
  message: 'Simple text message',
});

Send Formatted Message

// Markdown formatting
await telerolo.sendMessage({
  chatId: '@my_channel',
  message: '*Bold text* and _italic_',
  parseMode: 'Markdown',
});

// HTML formatting
await telerolo.sendMessage({
  chatId: '@my_channel',
  message: '<b>Bold text</b> and <i>italic</i>',
  parseMode: 'HTML',
});

// MarkdownV2 (recommended for complex formatting)
await telerolo.sendMessage({
  chatId: '@my_channel',
  message: '*Bold text* and _italic_ with [link](https://example.com)',
  parseMode: 'MarkdownV2',
});

Disable Web Page Preview

await telerolo.sendMessage({
  chatId: '@my_channel',
  message: 'Message with link https://example.com',
  disableWebPagePreview: true,
});

๐Ÿ”ง API Reference

TeleroloOptions

interface TeleroloOptions {
  botToken: string; // Your Telegram bot token
}

SendMessageParams

interface SendMessageParams {
  chatId: string;                    // Chat or channel ID
  message: string;                   // Message text
  parseMode?: ParseMode;             // Parsing mode (default: 'MarkdownV2')
  disableWebPagePreview?: boolean;   // Disable link preview
}

ParseMode

type ParseMode = 'Markdown' | 'MarkdownV2' | 'HTML';

๐Ÿ†” Getting Chat ID

Use our dedicated bot @get_my_channel_id_bot:

  • Add the bot to your channel or group as administrator
  • Send @get_my_channel_id_bot message to the channel/group
  • The bot will reply with the chat ID

Manual Method:

For Channel:

  • Add bot to channel as administrator
  • Send any message to the channel
  • Visit: https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
  • Find chat.id in the response

For Group:

  • Add bot to the group
  • Send a message to the group
  • Check updates via API as mentioned above

For Private Chat:

  • Chat ID will be a positive number (e.g., 123456789)
  • For channels and groups - negative number (e.g., -1001234567890)

๐Ÿ› ๏ธ Usage Examples

Deploy Notifications

async function notifyDeploy(environment, version) {
  await telerolo.sendMessage({
    chatId: '@deploy_notifications',
    message: `๐Ÿš€ *Deploy completed*\n\nEnvironment: \`${environment}\`\nVersion: \`${version}\`\nTime: ${new Date().toLocaleString()}`,
    parseMode: 'MarkdownV2',
  });
}

Error Monitoring

async function notifyError(error, context) {
  await telerolo.sendMessage({
    chatId: '@error_monitoring',
    message: `โŒ *Application Error*\n\nError: \`${error.message}\`\nContext: \`${context}\`\nTime: ${new Date().toISOString()}`,
    parseMode: 'MarkdownV2',
  });
}

Daily Reports

async function sendDailyReport(stats) {
  await telerolo.sendMessage({
    chatId: '@daily_reports',
    message: `๐Ÿ“Š *Daily Report*\n\nUsers: ${stats.users}\nOrders: ${stats.orders}\nRevenue: $${stats.revenue}`,
    parseMode: 'MarkdownV2',
  });
}

๐Ÿ”’ Security

  • Never commit bot token to repository
  • Use environment variables to store the token
  • Limit bot permissions to only necessary functions

๐Ÿงช Testing

npm run test

๐Ÿ“„ License

MIT

Keywords

telegram

FAQs

Package last updated on 30 Jul 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.