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

grammy

Package Overview
Dependencies
Maintainers
2
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grammy

grammY core package ported to Node.js

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23K
decreased by-8.57%
Maintainers
2
Weekly downloads
 
Created
Source

grammY

The grammY package lets you easily write Telegram bots. Here is a quickstart for you to get started, but note that a better explanation is in our repo on GitHub.

Quickstart

Talk to @BotFather to create a new Telegram bot and obtain a bot token.

Paste the following code into a new file bot.js.

import { Bot } from 'grammy'
// This works, too (CommonJS modules):
// const { Bot } = require('grammy')

// Create bot object
const bot = new Bot('') // <-- place your bot token inside this string

// Listen for messages
bot.command('start', ctx => ctx.reply('Welcome! Send me a photo!'))
bot.on('message:text', ctx => ctx.reply('That is text and not a photo!'))
bot.on('message:photo', ctx => ctx.reply('Nice photo! Is that you?'))
bot.on('edited_message', ctx => ctx.reply('Ha! Gotcha! You just edited this!', {
    reply_to_message_id: ctx.editedMessage.message_id
}))

// Launch!
bot.start()

Congratulations! You have successfully created your first Telegram bot.

You can run it like so:

node bot.js

Keywords

FAQs

Package last updated on 09 Apr 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