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

@darkwolf/telegram-bot.lazy.cjs

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@darkwolf/telegram-bot.lazy.cjs

Telegram Bot API

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Telegram Bot API

Install

ECMAScript (Node.js v12.x LTS or higher)

npm i --save @darkwolf/telegram-bot.mjs

CommonJS (Node.js v10.x LTS or higher)

npm i --save @darkwolf/telegram-bot.cjs

Lazy Loading CommonJS (Node.js v10.x LTS or higher)

npm i --save @darkwolf/telegram-bot.lazy.cjs

Using

// ECMAScript
import TelegramBot, {
  InputFile,
  InputMediaPhoto,
  InlineKeyboardMarkup,
  InlineKeyboardButton,
  MarkdownText,
  ParseMode
} from '@darkwolf/telegram-bot.mjs'

// CommonJS
const TelegramBot = require('@darkwolf/telegram-bot.cjs')
// Lazy Loading CommonJS
const TelegramBot = require('@darkwolf/telegram-bot.lazy.cjs')
const {
  InputFile,
  InputMediaPhoto,
  InlineKeyboardMarkup,
  InlineKeyboardButton,
  MarkdownText,
  ParseMode
} = TelegramBot

const bot = new TelegramBot(token, {
  agent: new Agent()
})

// Handling events
bot.on('request', request => {})
bot.on('response', response => {})
bot.on('error', error => {})

// Sending messages
const text = new MarkdownText()
  .addTitle(MarkdownText.escape('Ave, Darkwolf!'))
  .addItem('First Name', 'Pavel')
  .addItem('Last Name', 'Wolf')
const message = await bot.sendMessage(chatId, text, {
  parseMode: ParseMode.MARKDOWN,
  replyMarkup: new InlineKeyboardMarkup([
    [new InlineKeyboardButton('Ave, Darkwolf!', {
      callbackData: 'ave-darkwolf'
    })]
  ])
})
// Sending photo
const photoMessage = await bot.sendPhoto(chatId, new InputFile('photo.jpeg'))
// Sending media group
const messages = await bot.sendMediaGroup(chatId, [
  new InputMediaPhoto(new InputFile('first.jpeg')),
  new InputMediaPhoto(new InputFile('second.jpeg')),
  new InputMediaPhoto(new InputFile('third.jpeg'))
])
// Downloading files
const files = await Promise.all(messages.map(message => message.photo[0].getFile()))
const blobs = await Promise.all(files.map(file => file.download()))

API Documentation

Contact Me

GitHub: @PavelWolfDark
Telegram: @PavelWolfDark
Email: PavelWolfDark@gmail.com

Keywords

FAQs

Package last updated on 27 Dec 2020

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