1.1.1 • Published 1 year ago

telegram-message-send v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Telegram Message Send

Installation

With yarn

yarn add telegram-message-send

With NPM

npm install telegram-message-send

Getting Started

import {
  telegramSendMessage,
  telegramSendPhoto,
  telegramSendAudio,
  telegramSendDocument,
  telegramSendLocation,
  telegramSendContact,
  telegramSendPoll,
  telegramSendDice,
} from 'telegram-message-send'

const botKey = '#########'
const chatId = '#########'

telegramSendMessage(botKey, chatId, 'Hello World')
telegramSendPhoto(botKey, chatId, 'https://avatars.githubusercontent.com/u/100691616?s=200&v=4', 'Custom Caption')
telegramSendAudio(botKey, chatId, 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3', 'Custom Caption')
telegramSendDocument(
  botKey,
  chatId,
  'https://s2.q4cdn.com/175719177/files/doc_presentations/Placeholder-PDF.pdf',
  'Custom Caption',
)
telegramSendLocation(botKey, chatId, 41.084677113651814, 29.00455392606353)
telegramSendContact(botKey, chatId, 'Ilker Balcilar', '+905555555555')
telegramSendPoll(botKey, chatId, 'Which one would you prefer', ['Javascript', 'Typescript'])
telegramSendDice(botKey, chatId, 'dice')

Create a new Telegram bot with BotFather

Create a Telegram bot with BotFather before connecting your bot to Telegram.

  1. Start a new conversation with the BotFather.
  2. Send /newbot to create a new Telegram bot.
  3. When asked, enter a name for the bot.
  4. Copy and save the Telegram bot's access token for later steps.

Get your Get Your Telegram Chat ID

  1. In your Telegram account, search for “@myidbot” or open this link t.me/myidbot on your smartphone.
  2. Start a conversation with that bot and type /getid. You will get a reply back with your user ID.
  3. Note the user id.

In order to receive a message from the bot, you must first send a message to the bot and create a chat.

telegramSendMessage

PropRequiredTypeExample
botKeyyesstring#########
chatIdyesstring#########
textyesstringHello World

telegramSendMessage

PropRequiredTypeExample
botKeyyesstring#########
chatIdyesstring#########
photoURLyesstringhttps://avatars.githubusercontent.com/u/100691616?s=200&v=4
captionnostringCustom Caption

telegramSendAudio

PropRequiredTypeExample
botKeyyesstring#########
chatIdyesstring#########
audioURLyesstringhttps://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3
captionnostringCustom Caption

telegramSendDocument

PropRequiredTypeExample
botKeyyesstring#########
chatIdyesstring#########
documentURLyesstringhttps://s2.q4cdn.com/175719177/files/doc_presentations/Placeholder-PDF.pdf
captionnostringCustom Caption

telegramSendLocation

PropRequiredTypeExample
botKeyyesstring#########
chatIdyesstring#########
latitudeyesnumber41.084677113651814
longitudeyesnumber29.00455392606353

telegramSendContact

PropRequiredTypeExample
botKeyyesstring#########
chatIdyesstring#########
nameyesstringIlker Balcilar
phone_numberyesstring+905555555555

telegramSendPoll

PropRequiredTypeExample
botKeyyesstring#########
chatIdyesstring#########
questionyesstringWhich one would you prefer
optionsyesArray<string>["Javascript", "Typescript"]

telegramSendDice

PropRequiredTypeExample
botKeyyesstring#########
chatIdyesstring#########
typenostringdice / dart / bowling / basketball / football / slot
1.1.1

1 year ago

1.1.0

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago