Skip to content

Satoshi-Engineering/telegram-sender

Repository files navigation

TelegramSender

by the #sathoshiengineeringcrew

MIT License Badge

Telegram Sender is a helper class designed to send messages to a Telegram chat via a bot. It simplifies the process of integrating Telegram messaging into applications by utilizing the Telegram API.

Overview

  • Sends messages to a specified Telegram chat
  • Uses Axios for API requests
  • Allows configuration of bot token, chat ID, message prefix, and maximum message length

Installation

npm i telegram-sender

Usage

First you need to create a bot and invite it to a Telegram chat according to Telegram's Bot FAQs

import TelegramSender from 'telegram-sender'

const telegramSender = new TelegramSender({
  token: 'YOUR_BOT_TOKEN',
  defaultChatId: 'TARGET_CHAT_ID',
  messagePrefix: 'Optional Prefix', // optional, will get prepended to every message: '[Optional Prefix]'
  messageMaxLength: 200, // default 500, longer messages will get truncated and marked with '(Message Truncated)'
})

const code = await telegramSender.sendMessage{{
  message: 'This message will be sent to your group.',
  chatId: 'ID_OF_THE_TARGET_CHAT', // optional, if you want to override the defaultChatId
}}

The sendMessage method returns 0 on success and 1 on error.

Tip Us

If you like this project, give it a star! If you love it, fork it and take it out for dinner. 🌟🍽️
And hey, why not send some tip love?

About

A simple helper class that sends messages to a telegram group via a bot.

Topics

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
license-badge.svg

Stars

Watchers

Forks

Contributors 2

  •  
  •